From 295ada9c7258bb60e79f0217dbfba11b9af0deea Mon Sep 17 00:00:00 2001 From: div0 Date: Wed, 8 Jul 2009 15:46:36 +0000 Subject: [PATCH] fix warnings git-svn-id: svn://svn.icculus.org/nexuiz/trunk@7165 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/client/miscfunctions.qc | 14 +- data/qcsrc/client/movetypes.qc | 2 +- data/qcsrc/client/sbar.qc | 8 +- data/qcsrc/server/bots_scripting.qc | 295 +++++++++--------- .../server/tturrets/system/system_misc.qc | 18 +- 5 files changed, 174 insertions(+), 163 deletions(-) diff --git a/data/qcsrc/client/miscfunctions.qc b/data/qcsrc/client/miscfunctions.qc index 46c203d25..4dc6c71a7 100644 --- a/data/qcsrc/client/miscfunctions.qc +++ b/data/qcsrc/client/miscfunctions.qc @@ -335,7 +335,7 @@ void drawborderlines(float thickness, vector pos, vector dim, vector color, floa drawfill(pos + (dim_y + thickness) * '0 1 0', line_dim, color, alpha, drawflag); } -void drawpic_tiled(vector pos, string pic, vector size, vector area, vector color, float alpha, float drawflag) +void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color, float alpha, float drawflag) { vector current_pos, end_pos, new_size, ratio; end_pos = pos + area; @@ -346,14 +346,14 @@ void drawpic_tiled(vector pos, string pic, vector size, vector area, vector colo current_pos_x = pos_x; while (current_pos_x < end_pos_x) { - new_size_x = min(size_x, end_pos_x - current_pos_x); - new_size_y = min(size_y, end_pos_y - current_pos_y); - ratio_x = new_size_x / size_x; - ratio_y = new_size_y / size_y; + new_size_x = min(sz_x, end_pos_x - current_pos_x); + new_size_y = min(sz_y, end_pos_y - current_pos_y); + ratio_x = new_size_x / sz_x; + ratio_y = new_size_y / sz_y; drawsubpic(current_pos, new_size, pic, '0 0 0', ratio, color, alpha, drawflag); - current_pos_x += size_x; + current_pos_x += sz_x; } - current_pos_y += size_y; + current_pos_y += sz_y; } } diff --git a/data/qcsrc/client/movetypes.qc b/data/qcsrc/client/movetypes.qc index 3bde89ab8..f2d8b39d8 100644 --- a/data/qcsrc/client/movetypes.qc +++ b/data/qcsrc/client/movetypes.qc @@ -359,7 +359,7 @@ void _Movetype_Physics_Frame(float movedt) void Movetype_Physics_NoMatchServer() // optimized { - float n, i, dt, movedt; + float movedt; movedt = time - self.move_time; self.move_time = time; diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 3acb8ca56..d11136e08 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -894,7 +894,7 @@ void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_num * Makes a table for a team (for all playing players in DM) and fills it */ -vector Sbar_Scoreboard_MakeTable(vector pos, entity tm, float teamplay, vector rgb, vector bg_size) +vector Sbar_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size) { float body_table_height, i, pos_x_save; vector tmp, column_dim; @@ -1023,7 +1023,7 @@ void Sbar_DrawScoreboard() { vector rgb, pos, tmp, sbar_save; entity pl, tm; - float specs, i; + float specs; float center_x; if(time > lastpingstime + 10) @@ -1077,7 +1077,7 @@ void Sbar_DrawScoreboard() if(ts_primary != ts_secondary) Sbar_DrawXNum(sbar + pos - '4.5 0 0' * sbar_fontsize_y + '0 2.5 0' * sbar_fontsize_y, tm.(teamscores[ts_secondary]), 4, sbar_fontsize_y * 1, rgb, 0, 1, 1, DRAWFLAG_NORMAL); - pos = Sbar_Scoreboard_MakeTable(pos, tm, teamplay, rgb, bg_size); + pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size); } } else @@ -1088,7 +1088,7 @@ void Sbar_DrawScoreboard() tm = teams.sort_next; - pos = Sbar_Scoreboard_MakeTable(pos, tm, teamplay, rgb, bg_size); + pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size); } tmp = pos + '0 1.5 0' * sbar_fontsize_y; diff --git a/data/qcsrc/server/bots_scripting.qc b/data/qcsrc/server/bots_scripting.qc index bf04476e6..11633b5f7 100755 --- a/data/qcsrc/server/bots_scripting.qc +++ b/data/qcsrc/server/bots_scripting.qc @@ -65,8 +65,8 @@ float bot_havecommand(entity bot, float idx) #define MAX_BOT_PLACES 4 .float bot_places_count; -.entity bot_places[MAX_BOT_PLACES]; -.string bot_placenames[MAX_BOT_PLACES]; +.entity bot_places[MAX_BOT_PLACES]; FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(bot_places); +.string bot_placenames[MAX_BOT_PLACES]; FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(bot_placenames); entity bot_getplace(string placename) { entity e; @@ -1119,164 +1119,173 @@ void bot_resetqueues() bot_barriertime = time; } -// This function should be (the only) called directly from the bot ai loop -// It maps commands to functions and deal with complex interactions between commands and execution states -// NOTE: Of course you need to include your commands here too :) -float bot_execute_commands() +float bot_execute_commands_once() { local float status, ispressingkey; - do - { - - if(self.deadflag!=DEAD_NO) - return FALSE; - - // Find command - bot_setcurrentcommand(); + if(self.deadflag!=DEAD_NO) + return 0; - // Keep pressing keys raised by the "presskey" command - ispressingkey = bot_presskeys(); + // Find command + bot_setcurrentcommand(); - if(bot_cmd==world) - return ispressingkey; + // Keep pressing keys raised by the "presskey" command + ispressingkey = !!bot_presskeys(); - // Ignore all commands except continue when the bot is paused - if(self.bot_exec_status & BOT_EXEC_STATUS_PAUSED) - if(bot_cmd.bot_cmd_type!=BOT_CMD_CONTINUE) - { - if(bot_cmd.bot_cmd_type!=BOT_CMD_NULL) - { - bot_command_executed(TRUE); - print( "WARNING: Commands are ignored while the bot is paused. Use the command 'continue' instead.\n"); - } - return TRUE; - } + if(bot_cmd==world) + return ispressingkey; - // Handle conditions - if not(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE) - if(self.bot_cmd_condition_status & CMD_CONDITION_TRUE && self.bot_cmd_condition_status & CMD_CONDITION_FALSE_BLOCK) - { - bot_command_executed(TRUE); - continue; - } - else if(self.bot_cmd_condition_status & CMD_CONDITION_FALSE && self.bot_cmd_condition_status & CMD_CONDITION_TRUE_BLOCK) + // Ignore all commands except continue when the bot is paused + if(self.bot_exec_status & BOT_EXEC_STATUS_PAUSED) + if(bot_cmd.bot_cmd_type!=BOT_CMD_CONTINUE) + { + if(bot_cmd.bot_cmd_type!=BOT_CMD_NULL) { bot_command_executed(TRUE); - continue; + print( "WARNING: Commands are ignored while the bot is paused. Use the command 'continue' instead.\n"); } + return 1; + } - // Map commands to functions - switch(bot_cmd.bot_cmd_type) - { - case BOT_CMD_NULL: - return ispressingkey; - break; - case BOT_CMD_PAUSE: - status = bot_cmd_pause(); - break; - case BOT_CMD_CONTINUE: - status = bot_cmd_continue(); - break; - case BOT_CMD_WAIT: - status = bot_cmd_wait(); - break; - case BOT_CMD_WAIT_UNTIL: - status = bot_cmd_wait_until(); - break; - case BOT_CMD_TURN: - status = bot_cmd_turn(); - break; - case BOT_CMD_MOVETO: - status = bot_cmd_moveto(); - break; - case BOT_CMD_MOVETOTARGET: - status = bot_cmd_movetotarget(); - break; - case BOT_CMD_RESETGOAL: - status = bot_cmd_resetgoal(); - break; - case BOT_CMD_CC: - status = bot_cmd_cc(); - break; - case BOT_CMD_IF: - status = bot_cmd_if(); - break; - case BOT_CMD_ELSE: - status = bot_cmd_else(); - break; - case BOT_CMD_FI: - status = bot_cmd_fi(); - break; - case BOT_CMD_RESETAIM: - status = bot_cmd_resetaim(); - break; - case BOT_CMD_AIM: - status = bot_cmd_aim(); - break; - case BOT_CMD_AIMTARGET: - status = bot_cmd_aimtarget(); - break; - case BOT_CMD_PRESSKEY: - status = bot_cmd_presskey(); - break; - case BOT_CMD_RELEASEKEY: - status = bot_cmd_releasekey(); - break; - case BOT_CMD_SELECTWEAPON: - status = bot_cmd_select_weapon(); - break; - case BOT_CMD_IMPULSE: - status = bot_cmd_impulse(); - break; - case BOT_CMD_BARRIER: - status = bot_cmd_barrier(); - break; - case BOT_CMD_CONSOLE: - localcmd(strcat(bot_cmd.bot_cmd_parm_string, "\n")); - status = CMD_STATUS_FINISHED; - break; - default: - print(strcat("ERROR: Invalid command on queue with id '",ftos(bot_cmd.bot_cmd_type),"'\n")); - return FALSE; - } + // Handle conditions + if not(bot_cmd.bot_cmd_type==BOT_CMD_FI||bot_cmd.bot_cmd_type==BOT_CMD_ELSE) + if(self.bot_cmd_condition_status & CMD_CONDITION_TRUE && self.bot_cmd_condition_status & CMD_CONDITION_FALSE_BLOCK) + { + bot_command_executed(TRUE); + return -1; + } + else if(self.bot_cmd_condition_status & CMD_CONDITION_FALSE && self.bot_cmd_condition_status & CMD_CONDITION_TRUE_BLOCK) + { + bot_command_executed(TRUE); + return -1; + } - if (status==CMD_STATUS_ERROR) - print(strcat("ERROR: The command '",bot_cmd_string[bot_cmd.bot_cmd_type],"' returned an error status\n")); + // Map commands to functions + switch(bot_cmd.bot_cmd_type) + { + case BOT_CMD_NULL: + return ispressingkey; + break; + case BOT_CMD_PAUSE: + status = bot_cmd_pause(); + break; + case BOT_CMD_CONTINUE: + status = bot_cmd_continue(); + break; + case BOT_CMD_WAIT: + status = bot_cmd_wait(); + break; + case BOT_CMD_WAIT_UNTIL: + status = bot_cmd_wait_until(); + break; + case BOT_CMD_TURN: + status = bot_cmd_turn(); + break; + case BOT_CMD_MOVETO: + status = bot_cmd_moveto(); + break; + case BOT_CMD_MOVETOTARGET: + status = bot_cmd_movetotarget(); + break; + case BOT_CMD_RESETGOAL: + status = bot_cmd_resetgoal(); + break; + case BOT_CMD_CC: + status = bot_cmd_cc(); + break; + case BOT_CMD_IF: + status = bot_cmd_if(); + break; + case BOT_CMD_ELSE: + status = bot_cmd_else(); + break; + case BOT_CMD_FI: + status = bot_cmd_fi(); + break; + case BOT_CMD_RESETAIM: + status = bot_cmd_resetaim(); + break; + case BOT_CMD_AIM: + status = bot_cmd_aim(); + break; + case BOT_CMD_AIMTARGET: + status = bot_cmd_aimtarget(); + break; + case BOT_CMD_PRESSKEY: + status = bot_cmd_presskey(); + break; + case BOT_CMD_RELEASEKEY: + status = bot_cmd_releasekey(); + break; + case BOT_CMD_SELECTWEAPON: + status = bot_cmd_select_weapon(); + break; + case BOT_CMD_IMPULSE: + status = bot_cmd_impulse(); + break; + case BOT_CMD_BARRIER: + status = bot_cmd_barrier(); + break; + case BOT_CMD_CONSOLE: + localcmd(strcat(bot_cmd.bot_cmd_parm_string, "\n")); + status = CMD_STATUS_FINISHED; + break; + default: + print(strcat("ERROR: Invalid command on queue with id '",ftos(bot_cmd.bot_cmd_type),"'\n")); + return 0; + } - // Move execution pointer - if(status==CMD_STATUS_EXECUTING) - { - return TRUE; - } - else + if (status==CMD_STATUS_ERROR) + print(strcat("ERROR: The command '",bot_cmd_string[bot_cmd.bot_cmd_type],"' returned an error status\n")); + + // Move execution pointer + if(status==CMD_STATUS_EXECUTING) + { + return 1; + } + else + { + if(cvar("g_debug_bot_commands")) { - if(cvar("g_debug_bot_commands")) + local string parms; + + switch(bot_cmd_parm_type[bot_cmd.bot_cmd_type]) { - local string parms; - - switch(bot_cmd_parm_type[bot_cmd.bot_cmd_type]) - { - case BOT_CMD_PARAMETER_FLOAT: - parms = ftos(bot_cmd.bot_cmd_parm_float); - break; - case BOT_CMD_PARAMETER_STRING: - parms = bot_cmd.bot_cmd_parm_string; - break; - case BOT_CMD_PARAMETER_VECTOR: - parms = vtos(bot_cmd.bot_cmd_parm_vector); - break; - default: - parms = ""; - break; - } - clientcommand(self,strcat("say ^7", bot_cmd_string[bot_cmd.bot_cmd_type]," ",parms,"\n")); + case BOT_CMD_PARAMETER_FLOAT: + parms = ftos(bot_cmd.bot_cmd_parm_float); + break; + case BOT_CMD_PARAMETER_STRING: + parms = bot_cmd.bot_cmd_parm_string; + break; + case BOT_CMD_PARAMETER_VECTOR: + parms = vtos(bot_cmd.bot_cmd_parm_vector); + break; + default: + parms = ""; + break; } - - bot_command_executed(TRUE); + clientcommand(self,strcat("say ^7", bot_cmd_string[bot_cmd.bot_cmd_type]," ",parms,"\n")); } - } while(status==CMD_STATUS_FINISHED); + bot_command_executed(TRUE); + } + + if(status == CMD_STATUS_FINISHED) + return -1; - return status; + return CMD_STATUS_ERROR; +} + +// This function should be (the only) called directly from the bot ai loop +// It maps commands to functions and deal with complex interactions between commands and execution states +// NOTE: Of course you need to include your commands here too :) +float bot_execute_commands() +{ + float f; + do + { + f = bot_execute_commands_once(); + } + while(f < 0); + return f; } diff --git a/data/qcsrc/server/tturrets/system/system_misc.qc b/data/qcsrc/server/tturrets/system/system_misc.qc index ec5f2fe6e..93e859383 100644 --- a/data/qcsrc/server/tturrets/system/system_misc.qc +++ b/data/qcsrc/server/tturrets/system/system_misc.qc @@ -365,6 +365,15 @@ void FireImoBeam (vector start,vector end,vector smin,vector smax, trace_endpos = endpoint; } +void turrets_precache_debug_models() +{ + precache_model ("models/turrets/c512.md3"); + precache_model ("models/pathlib/goodsquare.md3"); + precache_model ("models/pathlib/badsquare.md3"); + precache_model ("models/pathlib/square.md3"); + precache_model ("models/pathlib/edge.md3"); +} + void turrets_precash() { precache_model ("models/turrets/base-gib1.md3"); @@ -395,12 +404,5 @@ void turrets_precash() //precache_model ("models/turrets/plasma.md3"); //precache_model ("models/turrets/tesla_head.md3"); //precache_model ("models/turrets/tesla_base.md3"); - -#if 0 - precache_model ("models/turrets/c512.md3"); - precache_model ("models/pathlib/goodsquare.md3"); - precache_model ("models/pathlib/badsquare.md3"); - precache_model ("models/pathlib/square.md3"); - precache_model ("models/pathlib/edge.md3"); -#endif + //turrets_precache_debug_models(); } -- 2.39.2