Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Add caller tracking for Cbuf_AddText
Browse files Browse the repository at this point in the history
  • Loading branch information
hobgoblin committed Feb 10, 2015
1 parent 4005b4d commit 926cf79
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 67 deletions.
2 changes: 1 addition & 1 deletion cl_main.c
Expand Up @@ -396,7 +396,7 @@ void CL_NextDemo (void)
}

sprintf (str,"playdemo %s\n", cls.demos[cls.demonum]);
Cbuf_InsertText (str);
Cbuf_InsertText (str, "playdemo");
cls.demonum++;
}

Expand Down
2 changes: 1 addition & 1 deletion cl_parse.c
Expand Up @@ -1091,7 +1091,7 @@ void CL_ParseServerMessage (void)
break;

case svc_stufftext:
Cbuf_AddText (MSG_ReadString ());
Cbuf_AddText (MSG_ReadString (), "CL_ParseServerMessage: svc_stufftext");
break;

case svc_damage:
Expand Down
19 changes: 10 additions & 9 deletions cmd.c
Expand Up @@ -90,15 +90,15 @@ Cbuf_AddText
Adds command text at the end of the buffer
============
*/
void Cbuf_AddText (char *text)
void Cbuf_AddText (char *text, char *caller) //qb: report calling info
{
int l;

l = Q_strlen (text);

if (cmd_text.cursize + l >= cmd_text.maxsize)
{
Con_Printf ("Cbuf_AddText: overflow on %i\n", cmd_text.cursize);
Con_Printf ("Cbuf_AddText: %s overflow on %i\n", caller, cmd_text.cursize);
return;
}

Expand All @@ -115,11 +115,12 @@ Adds a \n to the text
FIXME: actually change the command buffer to do less copying
============
*/
void Cbuf_InsertText (char *text)
void Cbuf_InsertText (char *text, char *caller)
{
char *temp;
int templen;


// copy off any commands still remaining in the exec buffer
templen = cmd_text.cursize;
if (templen)
Expand All @@ -132,7 +133,7 @@ void Cbuf_InsertText (char *text)
temp = NULL; // shut up compiler

// add the entire text of the file
Cbuf_AddText (text);
Cbuf_AddText (text, caller);

// add the copied off data
if (templen)
Expand Down Expand Up @@ -246,7 +247,7 @@ void Cmd_StuffCmds_f (void)
}
cmds[j] = 0;

Cbuf_InsertText (cmds);
Cbuf_InsertText (cmds, "Cmd_StuffCmds_f");
}


Expand Down Expand Up @@ -298,12 +299,12 @@ void Cmd_Exec_f (void)
f = (char *)fileinfo->data; // 2001-09-12 Returning information about loaded file by Maddes
Con_DPrintf ("execing %s\n",Cmd_Argv(1)); // edited

Cbuf_InsertText ("\n"); // Manoel Kasimier - for files that doesn't end with a newline
Cbuf_InsertText (f);
Cbuf_InsertText ("\n", "Cmd_Exec_f newline"); // Manoel Kasimier - for files that doesn't end with a newline
Cbuf_InsertText (f, Cmd_Argv(1));
// Manoel Kasimier - begin
// skip a frame to prevent possible crashes when the engine is started with the "-map" parameter
// if (!Q_strcmp(Cmd_Argv(1), "quake.rc"))
Cbuf_InsertText ("wait\n");
Cbuf_InsertText ("wait\n", "Cmd_Exec_f wait");
// Manoel Kasimier - end
Hunk_FreeToLowMark (mark);
}
Expand Down Expand Up @@ -1363,7 +1364,7 @@ void Cmd_ExecuteString (char *text, cmd_source_t src)
{
if (!Q_strcasecmp (cmd_argv[0], a->name))
{
Cbuf_InsertText (a->value);
Cbuf_InsertText (a->value, "Cmd_ExecuteString");
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd.h
Expand Up @@ -37,11 +37,11 @@ The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
void Cbuf_Init (void);
// allocates an initial text buffer that will grow as needed

void Cbuf_AddText (char *text);
void Cbuf_AddText (char *text, char *caller);
// as new commands are generated from the console or keybindings,
// the text is added to the end of the command buffer.

void Cbuf_InsertText (char *text);
void Cbuf_InsertText (char *text, char *caller); //qb: added caller for debugging
// when a command wants to issue other commands immediately, the text is
// inserted at the beginning of the buffer, before any remaining unexecuted
// commands.
Expand Down
4 changes: 2 additions & 2 deletions host.c
Expand Up @@ -756,7 +756,7 @@ void Host_GetConsoleCommands (void)
cmd = Sys_ConsoleInput ();
if (!cmd)
break;
Cbuf_AddText (cmd);
Cbuf_AddText (cmd, "Host_GetConsoleCommands");
}
}

Expand Down Expand Up @@ -1061,7 +1061,7 @@ void Host_Init (quakeparms_t *parms)

//SCR_Adjust(); // Manoel Kasimier - screen positioning
//M_Credits_f(); // Manoel Kasimier //qb: go straight to demo
Cbuf_InsertText ("exec quake.rc\n"); //qb: go straight to demo
Cbuf_InsertText ("exec quake.rc\n", "exec quake.rc"); //qb: go straight to demo

Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
host_hunklevel = Hunk_LowMark ();
Expand Down
2 changes: 1 addition & 1 deletion host_cmd.c
Expand Up @@ -1971,7 +1971,7 @@ void Host_Startdemos_f (void)
if (cls.state == ca_dedicated)
{
if (!sv.active)
Cbuf_AddText ("map start\n");
Cbuf_AddText ("map start\n", "map start");
return;
}

Expand Down
26 changes: 13 additions & 13 deletions keys.c
Expand Up @@ -170,8 +170,8 @@ void Key_Console (int key)
// enter command
if (key == K_ENTER || key == K_DC_Y) // Manoel Kasimier - controller functionality to the console - edited
{
Cbuf_AddText (key_lines[edit_line]+1); // skip the >
Cbuf_AddText ("\n");
Cbuf_AddText (key_lines[edit_line]+1, "key_lines"); // skip the >
Cbuf_AddText ("\n", "-");
Con_Printf ("%s\n",key_lines[edit_line]);
edit_line = (edit_line + 1) & 31;
history_line = edit_line;
Expand Down Expand Up @@ -330,11 +330,11 @@ void Key_Message (int key)
if (key == K_ENTER)
{
if (team_message)
Cbuf_AddText ("say_team \"");
Cbuf_AddText ("say_team \"", "-");
else
Cbuf_AddText ("say \"");
Cbuf_AddText(chat_buffer);
Cbuf_AddText("\"\n");
Cbuf_AddText ("say \"", "-");
Cbuf_AddText(chat_buffer, "Key_Message: chat_buffer");
Cbuf_AddText("\"\n", "-");

key_dest = key_game;
chat_bufferlen = 0;
Expand Down Expand Up @@ -991,22 +991,22 @@ void Key_Event (int key, qboolean down)
if (kb && kb[0] == '+')
{
sprintf (cmd, "-%s %i\n", kb+1, key);
Cbuf_AddText (cmd);
Cbuf_AddText (cmd, "shiftbindings");
}
// Manoel Kasimier - function shift - end
kb = keybindings[key];
if (kb && kb[0] == '+')
{
sprintf (cmd, "-%s %i\n", kb+1, key);
Cbuf_AddText (cmd);
Cbuf_AddText (cmd, "keybindings");
}
if (keyshift[key] != key)
{
kb = keybindings[keyshift[key]];
if (kb && kb[0] == '+')
{
sprintf (cmd, "-%s %i\n", kb+1, key);
Cbuf_AddText (cmd);
Cbuf_AddText (cmd, "keybindings2");
}
}
return;
Expand Down Expand Up @@ -1039,12 +1039,12 @@ void Key_Event (int key, qboolean down)
if (kb[0] == '+')
{ // button commands add keynum as a parm
sprintf (cmd, "%s %i\n", kb, key);
Cbuf_AddText (cmd);
Cbuf_AddText (cmd, "keybindings3");
}
else
{
Cbuf_AddText (kb);
Cbuf_AddText ("\n");
Cbuf_AddText (kb, "kb");
Cbuf_AddText ("\n", "keybindings return");
}
}
return;
Expand All @@ -1053,7 +1053,7 @@ void Key_Event (int key, qboolean down)
// Manoel Kasimier - function shift - begin
if (key_dest == key_menu)
if (keybindings[key] && !Q_strcmp(keybindings[key], "+shift"))
Cbuf_AddText (va("+shift %i\n", key)); // hack for the "customize controls" menu
Cbuf_AddText (va("+shift %i\n", key), "key_menu"); // hack for the "customize controls" menu
// Manoel Kasimier - function shift - end

// if (!down) // Manoel Kasimier - removed - there's a return earlier on this function
Expand Down
52 changes: 26 additions & 26 deletions menu.c
Expand Up @@ -851,7 +851,7 @@ void M_PopUp_Draw (void)
void M_PopUp_Key (int key)
{
if (m_inp_yes && popup_command)
Cbuf_AddText(popup_command);
Cbuf_AddText(popup_command, "popup_command");
else if (!m_inp_no)
return;

Expand Down Expand Up @@ -1034,11 +1034,11 @@ static void StartNewGame (void)
{
key_dest = key_game;
if (sv.active)
Cbuf_AddText ("disconnect\n");
Cbuf_AddText ("maxplayers 1\n");
Cbuf_AddText ("disconnect\n", "disconnect");
Cbuf_AddText ("maxplayers 1\n", "maxplayers");
Cvar_SetValue (teamplay.name, 0); //qb: cleanups from Levent
Cvar_SetValue (coop.name, 0);
Cbuf_AddText ("map start\n");
Cbuf_AddText ("map start\n", "StartNewGame");
}

void M_SinglePlayer_Key (int key)
Expand Down Expand Up @@ -1429,7 +1429,7 @@ void M_Save_Key (int k)
{
//qb: removed refresh. simply exit menu instead
Cbuf_AddText (va ("save%s %s%c%i%i.sav\n", (m_state==m_savesmall)?"small":"", savename.string,
(m_state==m_savesmall)?'G':'S', i/10, i%10)); //qb: switch to .sav extension
(m_state==m_savesmall)?'G':'S', i/10, i%10), "m_savesmall"); //qb: switch to .sav extension
}
else
M_PopUp_f ((m_state==m_savesmall)?"Overwrite saved game?":"Overwrite saved state?", va ("save%s %s%c%i%i.sav\n",
Expand All @@ -1442,7 +1442,7 @@ void M_Save_Key (int k)
// Host_Loadgame_f can't bring up the loading plaque because too much
// stack space has been used, so do it now
SCR_BeginLoadingPlaque ();
Cbuf_AddText (va ("load%s %s%c%i%i.sav\n", (m_state==m_loadsmall)?"small":"", savename.string, (m_state==m_loadsmall)?'G':'S', i/10, i%10) );
Cbuf_AddText (va ("load%s %s%c%i%i.sav\n", (m_state==m_loadsmall)?"small":"", savename.string, (m_state==m_loadsmall)?'G':'S', i/10, i%10), "m_loadsmall" );
fade_level = 0; // BlackAura - Menu background fading
return;
// Manoel Kasimier - begin
Expand Down Expand Up @@ -1955,7 +1955,7 @@ void M_GameOptions_Key (int key)
maxplayers, !o_deathmatch, o_deathmatch, o_teamplay, o_skill, o_fraglimit, o_timelimit, o_samelevel, s));
else
Cbuf_AddText(va("disconnect\nlisten 0\nmaxplayers %u\ncoop %i\ndeathmatch %i\nteamplay %i\nskill %i\nfraglimit %i\ntimelimit %i\nsamelevel %i\nmap %s\n",
maxplayers, !o_deathmatch, o_deathmatch, o_teamplay, o_skill, o_fraglimit, o_timelimit, o_samelevel, s));
maxplayers, !o_deathmatch, o_deathmatch, o_teamplay, o_skill, o_fraglimit, o_timelimit, o_samelevel, s), "serverstats");
free(s);
// Manoel Kasimier - end
}
Expand Down Expand Up @@ -2127,7 +2127,7 @@ void M_MapList_Key (int key)
case K_ENTER:
S_LocalSound ("misc/menu2.wav");
strcpy(nombreFile, listaFiles[posArrow]);
Cbuf_AddText (va("map %s\n", strtok(nombreFile, ".bsp")));
Cbuf_AddText (va("map %s\n", strtok(nombreFile, ".bsp")), "numbered files");
break;
}
}
Expand Down Expand Up @@ -2358,12 +2358,12 @@ void M_Setup_Key (int k)
// Manoel Kasimier - update player setup on exit - begin
#if NET_MENUS // Manoel Kasimier - removed multiplayer menus
if (Q_strcmp(cl_name.string, setup_hostname) != 0)
Cbuf_AddText ( va ("hostname \"%s\"\n", setup_hostname) );
Cbuf_AddText ( va ("hostname \"%s\"\n", setup_hostname), "hostname" );
#endif
if (Q_strcmp(cl_name.string, setup_myname) != 0)
Cbuf_AddText ( va ("name \"%s\"\n", setup_myname) );
Cbuf_AddText ( va ("name \"%s\"\n", setup_myname), "setup_myname" );
if (setup_top != setup_oldtop || setup_bottom != setup_oldbottom)
Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom) );
Cbuf_AddText( va ("color %i %i\n", setup_top, setup_bottom), "color" );
Cvar_SetValue ("crosshair", setup_crosshair);
Cvar_SetValue ("crosshair_color", setup_crosshair_color);
if (m_inp_off)
Expand Down Expand Up @@ -2838,7 +2838,7 @@ void M_Keys_Key (int k)
else
// Manoel Kasimier - end
sprintf (cmd, "bind \"%s\" \"%s\"\n", Key_KeynumToString (k), bindnames[cmd_for_position[m_cursor[m_state]]][0]); // Manoel Kasimier - edited
Cbuf_InsertText (cmd);
Cbuf_InsertText (cmd, "M_Keys_Key");
bind_grab = false;
}
return;
Expand Down Expand Up @@ -3269,9 +3269,9 @@ void M_Audio_Change (int dir)
if (c == i++) playLooping = !playLooping;
if (c == i++) (!playing && wasPlaying) ? CDAudio_Resume() : CDAudio_Pause();
if (c == i++) CDAudio_Stop();
if (c == i++) Cbuf_AddText ("cd eject\n");
if (c == i++) Cbuf_AddText ("cd close\n");
if (c == i++) Cbuf_AddText ("cd reset\n");
if (c == i++) Cbuf_AddText ("cd eject\n", "cd eject");
if (c == i++) Cbuf_AddText ("cd close\n", "cd close");
if (c == i++) Cbuf_AddText ("cd reset\n", "cd reset");

}
void M_Audio_Key (int k)
Expand Down Expand Up @@ -3490,16 +3490,16 @@ void M_Developer_Change (int dir)
if (c == i++)
{
M_Off();
Cbuf_AddText ("timedemo demo1.dem\n");
Cbuf_AddText ("timedemo demo1.dem\n", "timedemo demo1");
}
if (c == i++) Cbuf_AddText ("noclip\n");
if (c == i++) Cbuf_AddText ("fly\n");
if (c == i++) Cbuf_AddText ("notarget\n");
if (c == i++) Cbuf_AddText ("god\n");
if (c == i++) Cbuf_AddText ("noclip\n", "noclip");
if (c == i++) Cbuf_AddText ("fly\n", "fly");
if (c == i++) Cbuf_AddText ("notarget\n", "notarget");
if (c == i++) Cbuf_AddText ("god\n", "god");
if (c == i++)
{
M_Off();
Cbuf_AddText ("impulse 9\n");
Cbuf_AddText ("impulse 9\n", "impulse 9");
}
}
void M_Developer_Key (int k)
Expand Down Expand Up @@ -3551,7 +3551,7 @@ void M_Credits_Key (int key)
{
m_cursor[m_state] += 1;
m_credits_starttime = realtime-8.0;//8.5
Cbuf_InsertText ("exec quake.rc\n");
Cbuf_InsertText ("exec quake.rc\n", "exec quake.rc");
}
else if (m_cursor[m_state] == 3)
M_Off ();
Expand Down Expand Up @@ -4066,7 +4066,7 @@ void M_LanConfig_Key (int key)
fade_level = 0;
key_dest = key_game;
m_state = m_none;
Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname) );
Cbuf_AddText ( va ("connect \"%s\"\n", lanConfig_joinname), "lanConfig_joinname" );
break;
}

Expand Down Expand Up @@ -4288,7 +4288,7 @@ void M_ServerList_Key (int k)
fade_level = 0;
key_dest = key_game;
m_state = m_none;
Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) );
Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname), "M_ServerList_Key: connect" );
break;

default:
Expand All @@ -4301,7 +4301,7 @@ void M_ConfigureNetSubsystem(void)
{
// enable/disable net systems to match desired config

Cbuf_AddText ("stopdemo\n");
Cbuf_AddText ("stopdemo\n", "stopdemo");

if (IPXConfig || TCPIPConfig)
net_hostport = lanConfig_port;
Expand Down Expand Up @@ -4518,7 +4518,7 @@ void M_Keydown (int key)
#ifdef _WIN32
if (key == '-')
{
Cbuf_AddText ("vid_minimize\n");
Cbuf_AddText ("vid_minimize\n", "vid_minimize");
return;
}
#endif
Expand Down

0 comments on commit 926cf79

Please sign in to comment.