From 33ad72ca7b8839d52f55e5721d42fbd28bf1e119 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Fri, 6 Feb 2015 14:55:34 +0100 Subject: [PATCH] Use int and bool in minigame code --- qcsrc/client/hud.qc | 2 +- qcsrc/client/hud.qh | 12 +- qcsrc/common/minigames/cl_minigames.qc | 23 ++-- qcsrc/common/minigames/cl_minigames.qh | 12 +- qcsrc/common/minigames/cl_minigames_hud.qc | 19 +-- qcsrc/common/minigames/minigame/all.qh | 4 +- qcsrc/common/minigames/minigame/nmm.qc | 141 ++++++++++----------- qcsrc/common/minigames/minigame/ttt.qc | 124 +++++++++--------- qcsrc/common/minigames/minigames.qc | 38 +++--- qcsrc/common/minigames/minigames.qh | 50 ++++---- qcsrc/common/minigames/sv_minigames.qc | 22 ++-- qcsrc/common/minigames/sv_minigames.qh | 10 +- qcsrc/common/notifications.qh | 2 +- 13 files changed, 223 insertions(+), 236 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 073789a08..de7cda425 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4457,7 +4457,7 @@ Main HUD system ================== */ -float HUD_Panel_CheckFlags(float showflags) +bool HUD_Panel_CheckFlags(int showflags) { if ( HUD_Minigame_Showpanels() ) return showflags & PANEL_SHOW_MINIGAME; diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index 10cc1bc3c..d850a9af2 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -103,12 +103,12 @@ float current_player; float GetPlayerColorForce(int i); float GetPlayerColor(int i); -.float panel_showflags; -const float PANEL_SHOW_NEVER = 0x00; -const float PANEL_SHOW_MAINGAME = 0x01; -const float PANEL_SHOW_MINIGAME = 0x02; -const float PANEL_SHOW_ALWAYS = 0xff; -float HUD_Panel_CheckFlags(float showflags); +.int panel_showflags; +const int PANEL_SHOW_NEVER = 0x00; +const int PANEL_SHOW_MAINGAME = 0x01; +const int PANEL_SHOW_MINIGAME = 0x02; +const int PANEL_SHOW_ALWAYS = 0xff; +bool HUD_Panel_CheckFlags(int showflags); #define HUD_PANELS(HUD_PANEL) \ HUD_PANEL(WEAPONS , HUD_Weapons , weapons, PANEL_SHOW_MAINGAME ) \ diff --git a/qcsrc/common/minigames/cl_minigames.qc b/qcsrc/common/minigames/cl_minigames.qc index f6af765b7..8a715555c 100644 --- a/qcsrc/common/minigames/cl_minigames.qc +++ b/qcsrc/common/minigames/cl_minigames.qc @@ -36,7 +36,7 @@ vector minigame_hud_normalize(vector v, vector pos, vector mySize) } // Check if the mouse is inside the given area -float minigame_hud_mouse_in(vector pos, vector sz) +bool minigame_hud_mouse_in(vector pos, vector sz) { return mousepos_x >= pos_x && mousepos_x < pos_x + sz_x && mousepos_y >= pos_y && mousepos_y < pos_y + sz_y ; @@ -99,7 +99,7 @@ void minigame_autoclean_entity(entity e) } void HUD_MinigameMenu_CurrentButton(); -float auto_close_minigamemenu; +bool auto_close_minigamemenu; void deactivate_minigame() { if ( !active_minigame ) @@ -263,10 +263,10 @@ void ent_read_minigame() string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw) { - float last_word; + int last_word; string s; - float take_until; - float skip = 0; + int take_until; + int skip = 0; s = getWrappedLine_remaining; @@ -281,8 +281,7 @@ string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_ if ( take_until > strlen(s) ) take_until = strlen(s); - float i; - for ( i = 0; i < take_until; i++ ) + for ( int i = 0; i < take_until; i++ ) if ( substring(s,i,1) == "\n" ) { take_until = i; @@ -320,7 +319,7 @@ string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_ } vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text, - vector fontsize, vector color, float theAlpha, float drawflags, float align ) + vector fontsize, vector color, float theAlpha, int drawflags, float align ) { getWrappedLine_remaining = text; vector mypos = pos; @@ -339,7 +338,7 @@ vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text, } vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos, - string text, vector fontsize, float theAlpha, float drawflags, float align ) + string text, vector fontsize, float theAlpha, int drawflags, float align ) { getWrappedLine_remaining = text; vector mypos = pos; @@ -358,21 +357,21 @@ vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos, } void minigame_drawstring_trunc(float maxwidth, vector pos, string text, - vector fontsize, vector color, float theAlpha, float drawflags ) + vector fontsize, vector color, float theAlpha, int drawflags ) { string line = textShortenToWidth(text,maxwidth,fontsize,stringwidth_nocolors); drawstring(pos, line, fontsize, color, theAlpha, drawflags); } void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, - vector fontsize, float theAlpha, float drawflags ) + vector fontsize, float theAlpha, int drawflags ) { string line = textShortenToWidth(text,maxwidth,fontsize,stringwidth_colors); drawcolorcodedstring(pos, line, fontsize, theAlpha, drawflags); } void minigame_drawpic_centered( vector pos, string texture, vector sz, - vector color, float thealpha, float drawflags ) + vector color, float thealpha, int drawflags ) { drawpic( pos-sz/2, texture, sz, color, thealpha, drawflags ); } diff --git a/qcsrc/common/minigames/cl_minigames.qh b/qcsrc/common/minigames/cl_minigames.qh index 404f24a61..6bd307777 100644 --- a/qcsrc/common/minigames/cl_minigames.qh +++ b/qcsrc/common/minigames/cl_minigames.qh @@ -41,31 +41,31 @@ vector minigame_hud_denormalize(vector v, vector pos, vector mySize); vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize); // Check if the mouse is inside the given area -float minigame_hud_mouse_in(vector pos, vector sz); +bool minigame_hud_mouse_in(vector pos, vector sz); // Like drawstring, but wrapping words to fit maxwidth // returns the size of the drawn area // align selects the string alignment (0 = left, 0.5 = center, 1 = right) vector minigame_drawstring_wrapped( float maxwidth, vector pos, string text, - vector fontsize, vector color, float theAlpha, float drawflags, float align ); + vector fontsize, vector color, float theAlpha, int drawflags, float align ); // Like drawcolorcodedstring, but wrapping words to fit maxwidth // returns the size of the drawn area // align selects the string alignment (0 = left, 0.5 = center, 1 = right) vector minigame_drawcolorcodedstring_wrapped( float maxwidth, vector pos, - string text, vector fontsize, float theAlpha, float drawflags, float align ); + string text, vector fontsize, float theAlpha, int drawflags, float align ); // Like drawstring but truncates the text to fit maxwidth void minigame_drawstring_trunc(float maxwidth, vector pos, string text, - vector fontsize, vector color, float theAlpha, float drawflags ); + vector fontsize, vector color, float theAlpha, int drawflags ); // Like drawcolorcodedstring but truncates the text to fit maxwidth void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, - vector fontsize, float theAlpha, float drawflags ); + vector fontsize, float theAlpha, int drawflags ); // like drawpic but pos represent the center rather than the topleft corner void minigame_drawpic_centered( vector pos, string texture, vector sz, - vector color, float thealpha, float drawflags ); + vector color, float thealpha, int drawflags ); // Get full path of a minigame texture string minigame_texture(string name); diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 7df760979..fd6e9bc67 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -170,7 +170,7 @@ void HUD_MinigameMenu_ClickCreate_Entry() // Helper click action for collapsible entries // returns true when you have to create the sub-entries -float HUD_MinigameMenu_Click_ExpandCollapse() +bool HUD_MinigameMenu_Click_ExpandCollapse() { entity e; if ( self.flags & 2 ) @@ -277,10 +277,9 @@ void HUD_MinigameMenu_ClickInvite() { if ( HUD_MinigameMenu_Click_ExpandCollapse() ) { - float i; entity e; entity prev = self; - for(i = 0; i < maxclients; ++i) + for(int i = 0; i < maxclients; ++i) { if ( player_localnum != i && playerslots[i] && GetPlayerName(i) != "" && !findfloat(world,minigame_playerslot,i+1) && playerslots[i].ping ) @@ -329,7 +328,7 @@ void HUD_MinigameMenu_ClickCurrentGame() } } // Whether the minigame menu panel is open -float HUD_MinigameMenu_IsOpened() +bool HUD_MinigameMenu_IsOpened() { return !!HUD_MinigameMenu_entries; } @@ -480,12 +479,11 @@ void HUD_MinigameMenu () HUD_MinigameMenu_DrawEntry(panel_pos,_("Minigames"),hud_fontsize*2,'0.25 0.47 0.72'); panel_pos_y += hud_fontsize_y*2; - entity e; vector color; vector offset; float itemh; vector imgsz = '22 22 0'; // NOTE: if changed, edit where HUD_MinigameMenu_activeitem is selected - for ( e = HUD_MinigameMenu_entries; e != world; e = e.list_next ) + for ( entity e = HUD_MinigameMenu_entries; e != world; e = e.list_next ) { color = e.colormod; @@ -574,7 +572,6 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary } else { - if(bInputType == 0) { if(nPrimary == K_ALT) hudShiftState |= S_ALT; if(nPrimary == K_CTRL) hudShiftState |= S_CTRL; @@ -592,11 +589,9 @@ float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary // allow some binds string con_keys; - float keys; - float i; con_keys = findkeysforcommand("toggleconsole", 0); - keys = tokenize(con_keys); // findkeysforcommand returns data for this - for (i = 0; i < keys; ++i) + int keys = tokenize(con_keys); // findkeysforcommand returns data for this + for (int i = 0; i < keys; ++i) { if(nPrimary == stof(argv(i))) return false; @@ -693,7 +688,7 @@ void HUD_Minigame_Mouse() cursorsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } -float HUD_Minigame_Showpanels() +bool HUD_Minigame_Showpanels() { return HUD_MinigameMenu_IsOpened() && ( autocvar__hud_configure || minigame_isactive() ); } diff --git a/qcsrc/common/minigames/minigame/all.qh b/qcsrc/common/minigames/minigame/all.qh index e550ff468..72e8edda4 100644 --- a/qcsrc/common/minigames/minigame/all.qh +++ b/qcsrc/common/minigames/minigame/all.qh @@ -17,7 +17,7 @@ Required functions ------------------ SVQC: - float minigame_event_(entity minigame, string event, ...count) + int minigame_event_(entity minigame, string event, ...count) see ../minigames.qh for a detailed explanation CSQC: void minigame_hud_board_(vector pos, vector mySize) @@ -27,7 +27,7 @@ CSQC: draws the game status panel inside the rectangle defined by pos and mySize (That rectangle is expressed in window coordinates) This panel shows eg scores, captured pieces and so on - float minigame_event_(entity minigame, string event, ...count) + int minigame_event_(entity minigame, string event, ...count) see ../minigames.qh for a detailed explanation Managing entities diff --git a/qcsrc/common/minigames/minigame/nmm.qc b/qcsrc/common/minigames/minigame/nmm.qc index aaebe690e..eb27646fd 100644 --- a/qcsrc/common/minigames/minigame/nmm.qc +++ b/qcsrc/common/minigames/minigame/nmm.qc @@ -1,19 +1,19 @@ -const float NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board -const float NMM_TURN_MOVE = 0x0200; // player has to move a piece by one tile -const float NMM_TURN_FLY = 0x0400; // player has to move a piece anywhere -const float NMM_TURN_TAKE = 0x0800; // player has to take a non-mill piece -const float NMM_TURN_TAKEANY=0x1000; // combine with NMM_TURN_TAKE, can take mill pieces -const float NMM_TURN_WIN = 0x2000; // player has won -const float NMM_TURN_TYPE = 0xff00; -const float NMM_TURN_TEAM1 = 0x0001; -const float NMM_TURN_TEAM2 = 0x0002; -const float NMM_TURN_TEAM = 0x00ff; +const int NMM_TURN_PLACE = 0x0100; // player has to place a piece on the board +const int NMM_TURN_MOVE = 0x0200; // player has to move a piece by one tile +const int NMM_TURN_FLY = 0x0400; // player has to move a piece anywhere +const int NMM_TURN_TAKE = 0x0800; // player has to take a non-mill piece +const int NMM_TURN_TAKEANY=0x1000; // combine with NMM_TURN_TAKE, can take mill pieces +const int NMM_TURN_WIN = 0x2000; // player has won +const int NMM_TURN_TYPE = 0xff00; +const int NMM_TURN_TEAM1 = 0x0001; +const int NMM_TURN_TEAM2 = 0x0002; +const int NMM_TURN_TEAM = 0x00ff; -const float NMM_PIECE_DEAD = 0x0; // captured by the enemy -const float NMM_PIECE_HOME = 0x1; // not yet placed -const float NMM_PIECE_BOARD = 0x2; // placed on the board +const int NMM_PIECE_DEAD = 0x0; // captured by the enemy +const int NMM_PIECE_HOME = 0x1; // not yet placed +const int NMM_PIECE_BOARD = 0x2; // placed on the board -.float nmm_tile_distance; +.int nmm_tile_distance; .entity nmm_tile_piece; .string nmm_tile_hmill; .string nmm_tile_vmill; @@ -21,11 +21,11 @@ const float NMM_PIECE_BOARD = 0x2; // placed on the board // build a string containing the indices of the tile to check for a horizontal mill string nmm_tile_build_hmill(entity tile) { - float number = minigame_tile_number(tile.netname); - float letter = minigame_tile_letter(tile.netname); + int number = minigame_tile_number(tile.netname); + int letter = minigame_tile_letter(tile.netname); if ( number == letter || number+letter == 6 ) { - float add = letter < 3 ? 1 : -1; + int add = letter < 3 ? 1 : -1; return strcat(tile.netname," ", minigame_tile_buildname(letter+add*tile.nmm_tile_distance,number)," ", minigame_tile_buildname(letter+add*2*tile.nmm_tile_distance,number) ); @@ -47,11 +47,11 @@ string nmm_tile_build_hmill(entity tile) // build a string containing the indices of the tile to check for a vertical mill string nmm_tile_build_vmill(entity tile) { - float letter = minigame_tile_letter(tile.netname); - float number = minigame_tile_number(tile.netname); + int letter = minigame_tile_letter(tile.netname); + int number = minigame_tile_number(tile.netname); if ( letter == number || letter+number == 6 ) { - float add = number < 3 ? 1 : -1; + int add = number < 3 ? 1 : -1; return strcat(tile.netname," ", minigame_tile_buildname(letter,number+add*tile.nmm_tile_distance)," ", minigame_tile_buildname(letter,number+add*2*tile.nmm_tile_distance) ); @@ -74,7 +74,7 @@ string nmm_tile_build_vmill(entity tile) // \param id Tile index (eg: a1) // \param minig Owner minigame instance // \param distance Distance from adjacent tiles -void nmm_spawn_tile(string id, entity minig, float distance) +void nmm_spawn_tile(string id, entity minig, int distance) { // TODO global variable + list_next for simpler tile loops entity e = spawn(); @@ -92,15 +92,14 @@ void nmm_spawn_tile(string id, entity minig, float distance) // \param minig Owner minigame instance // \param offset Index offset (eg: 1 to start the square at b2, 0 at a1 etc.) // \param skip Number of indices to skip between tiles (eg 1: a1, a3) -void nmm_spawn_tile_square( entity minig, float offset, float skip ) +void nmm_spawn_tile_square( entity minig, int offset, int skip ) { - float letter = offset; - float number = offset; - float i, j; - for ( i = 0; i < 3; i++ ) + int letter = offset; + int number = offset; + for ( int i = 0; i < 3; i++ ) { number = offset; - for ( j = 0; j < 3; j++ ) + for ( int j = 0; j < 3; j++ ) { if ( i != 1 || j != 1 ) nmm_spawn_tile(strzone(minigame_tile_buildname(letter,number)),minig, skip+1); @@ -144,45 +143,44 @@ entity nmm_find_tile(entity minig, string id) } // Check whether two tiles are adjacent -float nmm_tile_adjacent(entity tile1, entity tile2) +bool nmm_tile_adjacent(entity tile1, entity tile2) { - float dnumber = fabs ( minigame_tile_number(tile1.netname) - minigame_tile_number(tile2.netname) ); - float dletter = fabs ( minigame_tile_letter(tile1.netname) - minigame_tile_letter(tile2.netname) ); + int dnumber = fabs ( minigame_tile_number(tile1.netname) - minigame_tile_number(tile2.netname) ); + int dletter = fabs ( minigame_tile_letter(tile1.netname) - minigame_tile_letter(tile2.netname) ); return ( dnumber == 0 && ( dletter == 1 || dletter == tile1.nmm_tile_distance ) ) || ( dletter == 0 && ( dnumber == 1 || dnumber == tile1.nmm_tile_distance ) ); } // Returns 1 if there is at least 1 free adjacent tile -float nmm_tile_canmove(entity tile) +bool nmm_tile_canmove(entity tile) { entity e = world; while ( ( e = findentity(e,owner,tile.owner) ) ) if ( e.classname == "minigame_nmm_tile" && !e.nmm_tile_piece && nmm_tile_adjacent(e,tile) ) { - return 1; + return true; } - return 0; + return false; } // Check if the given tile id appears in the string -float nmm_in_mill_string(entity tile, string s) +bool nmm_in_mill_string(entity tile, string s) { - float argc = tokenize(s); - float i; - for ( i = 0; i < argc; i++ ) + int argc = tokenize(s); + for ( int i = 0; i < argc; i++ ) { entity e = nmm_find_tile(tile.owner,argv(i)); if ( !e || !e.nmm_tile_piece || e.nmm_tile_piece.team != tile.nmm_tile_piece.team ) - return 0; + return false; } - return 1; + return true; } // Check if a tile is in a mill -float nmm_in_mill(entity tile) +bool nmm_in_mill(entity tile) { return tile.nmm_tile_piece && ( nmm_in_mill_string(tile,tile.nmm_tile_hmill) || @@ -192,7 +190,7 @@ float nmm_in_mill(entity tile) #ifdef SVQC // Find a NMM piece matching some of the given flags and team number -entity nmm_find_piece(entity start, entity minigame, float teamn, float pieceflags) +entity nmm_find_piece(entity start, entity minigame, int teamn, int pieceflags) { entity e = start; while ( ( e = findentity(e,owner,minigame) ) ) @@ -203,9 +201,9 @@ entity nmm_find_piece(entity start, entity minigame, float teamn, float piecefla } // Count NMM pieces matching flags and team number -float nmm_count_pieces(entity minigame, float teamn, float pieceflags) +int nmm_count_pieces(entity minigame, int teamn, int pieceflags) { - float n = 0; + int n = 0; entity e = world; while (( e = nmm_find_piece(e,minigame, teamn, pieceflags) )) n++; @@ -213,15 +211,14 @@ float nmm_count_pieces(entity minigame, float teamn, float pieceflags) } // required function, handle server side events -float minigame_event_nmm(entity minigame, string event, ...) +int minigame_event_nmm(entity minigame, string event, ...) { if ( event == "start" ) { minigame.minigame_flags = NMM_TURN_PLACE|NMM_TURN_TEAM1; nmm_init_tiles(minigame); - float i; entity e; - for ( i = 0; i < 7; i++ ) + for ( int i = 0; i < 7; i++ ) { e = msle_spawn(minigame,"minigame_board_piece"); e.team = 1; @@ -239,7 +236,7 @@ float minigame_event_nmm(entity minigame, string event, ...) } else if ( event == "join" ) { - float n = 0; + int n = 0; entity e; for ( e = minigame.minigame_players; e; e = e.list_next ) n++; @@ -252,10 +249,10 @@ float minigame_event_nmm(entity minigame, string event, ...) else if ( event == "cmd" ) { entity e = ...(0,entity); - float argc = ...(1,float); + int argc = ...(1,int); entity tile = world; entity piece = world; - float move_ok = 0; + bool move_ok = false; if ( e && argc >= 2 && argv(0) == "move" && ( minigame.minigame_flags & NMM_TURN_TEAM ) == e.team ) @@ -263,7 +260,7 @@ float minigame_event_nmm(entity minigame, string event, ...) tile = nmm_find_tile(minigame,argv(1)); if ( !tile ) { - move_ok = 0; + move_ok = false; } else if ( minigame.minigame_flags & NMM_TURN_PLACE ) { @@ -274,7 +271,7 @@ float minigame_event_nmm(entity minigame, string event, ...) piece.minigame_flags = NMM_PIECE_BOARD; piece.origin = tile.origin; piece.SendFlags |= MINIG_SF_UPDATE; - move_ok = 1; + move_ok = true; } } else if ( minigame.minigame_flags & NMM_TURN_MOVE ) @@ -290,7 +287,7 @@ float minigame_event_nmm(entity minigame, string event, ...) piece.origin = tile2.origin; piece.SendFlags |= MINIG_SF_UPDATE; tile = tile2; - move_ok = 1; + move_ok = true; } } @@ -308,7 +305,7 @@ float minigame_event_nmm(entity minigame, string event, ...) piece.origin = tile2.origin; piece.SendFlags |= MINIG_SF_UPDATE; tile = tile2; - move_ok = 1; + move_ok = true; } } @@ -321,12 +318,12 @@ float minigame_event_nmm(entity minigame, string event, ...) tile.nmm_tile_piece = world; piece.minigame_flags = NMM_PIECE_DEAD; piece.SendFlags |= MINIG_SF_UPDATE; - move_ok = 1; + move_ok = true; } } - float nextteam = e.team % 2 + 1; - float npieces = nmm_count_pieces(minigame,nextteam,NMM_PIECE_HOME|NMM_PIECE_BOARD); + int nextteam = e.team % 2 + 1; + int npieces = nmm_count_pieces(minigame,nextteam,NMM_PIECE_HOME|NMM_PIECE_BOARD); if ( npieces < 3 ) { @@ -338,7 +335,7 @@ float minigame_event_nmm(entity minigame, string event, ...) if ( !(minigame.minigame_flags & NMM_TURN_TAKE) && nmm_in_mill(tile) ) { minigame.minigame_flags = NMM_TURN_TAKE|e.team; - float takemill = NMM_TURN_TAKEANY; + int takemill = NMM_TURN_TAKEANY; entity f = world; while ( ( f = findentity(f,owner,minigame) ) ) if ( f.classname == "minigame_nmm_tile" && f.nmm_tile_piece && @@ -387,20 +384,20 @@ vector nmm_boardpos; vector nmm_boardsize; // whether the given tile is a valid selection -float nmm_valid_selection(entity tile) +bool nmm_valid_selection(entity tile) { if ( ( tile.owner.minigame_flags & NMM_TURN_TEAM ) != minigame_self.team ) - return 0; // not our turn + return false; // not our turn if ( tile.owner.minigame_flags & NMM_TURN_PLACE ) return !tile.nmm_tile_piece; // need to put a piece on an empty spot if ( tile.owner.minigame_flags & NMM_TURN_MOVE ) { if ( tile.nmm_tile_piece && tile.nmm_tile_piece.team == minigame_self.team && nmm_tile_canmove(tile) ) - return 1; // movable tile + return true; // movable tile if ( nmm_fromtile ) // valid destination return !tile.nmm_tile_piece && nmm_tile_adjacent(nmm_fromtile,tile); - return 0; + return false; } if ( tile.owner.minigame_flags & NMM_TURN_FLY ) { @@ -412,19 +409,19 @@ float nmm_valid_selection(entity tile) if ( tile.owner.minigame_flags & NMM_TURN_TAKE ) return tile.nmm_tile_piece && tile.nmm_tile_piece.team != minigame_self.team && ( (tile.owner.minigame_flags & NMM_TURN_TAKEANY) || !nmm_in_mill(tile) ); - return 0; + return false; } // whether it should highlight valid tile selections -float nmm_draw_avaliable(entity tile) +bool nmm_draw_avaliable(entity tile) { if ( ( tile.owner.minigame_flags & NMM_TURN_TEAM ) != minigame_self.team ) - return 0; + return false; if ( (tile.owner.minigame_flags & NMM_TURN_TAKE) ) - return 1; + return true; if ( (tile.owner.minigame_flags & (NMM_TURN_FLY|NMM_TURN_MOVE)) && nmm_fromtile ) return !tile.nmm_tile_piece; - return 0; + return false; } // Required function, draw the game board @@ -595,7 +592,7 @@ void nmm_make_move(entity minigame) nmm_fromtile = world; } -string nmm_turn_to_string(float turnflags) +string nmm_turn_to_string(int turnflags) { if ( turnflags & NMM_TURN_WIN ) { @@ -619,7 +616,7 @@ string nmm_turn_to_string(float turnflags) } // Required function, handle client events -float minigame_event_nmm(entity minigame, string event, ...) +int minigame_event_nmm(entity minigame, string event, ...) { if ( event == "activate" ) { @@ -634,7 +631,7 @@ float minigame_event_nmm(entity minigame, string event, ...) } else if ( event == "key_pressed" && (minigame.minigame_flags&NMM_TURN_TEAM) == minigame_self.team ) { - switch ( ...(0,float) ) + switch ( ...(0,int) ) { case K_RIGHTARROW: case K_KP_RIGHTARROW: @@ -704,7 +701,7 @@ float minigame_event_nmm(entity minigame, string event, ...) } return 0; } - else if ( event == "mouse_pressed" && ...(0,float) == K_MOUSE1 ) + else if ( event == "mouse_pressed" && ...(0,int) == K_MOUSE1 ) { nmm_make_move(minigame); return 1; @@ -731,7 +728,7 @@ float minigame_event_nmm(entity minigame, string event, ...) } else if ( event == "network_receive" ) { - if ( self.classname == "minigame_board_piece" && ( ...(1,float) & MINIG_SF_UPDATE ) ) + if ( self.classname == "minigame_board_piece" && ( ...(1,int) & MINIG_SF_UPDATE ) ) { entity e; string tileid = ""; @@ -748,7 +745,7 @@ float minigame_event_nmm(entity minigame, string event, ...) } } } - else if ( self.classname == "minigame" && ( ...(1,float) & MINIG_SF_UPDATE ) ) + else if ( self.classname == "minigame" && ( ...(1,int) & MINIG_SF_UPDATE ) ) { self.message = nmm_turn_to_string(self.minigame_flags); if ( self.minigame_flags & minigame_self.team ) diff --git a/qcsrc/common/minigames/minigame/ttt.qc b/qcsrc/common/minigames/minigame/ttt.qc index e2dc0a06a..e8313d4f5 100644 --- a/qcsrc/common/minigames/minigame/ttt.qc +++ b/qcsrc/common/minigames/minigame/ttt.qc @@ -1,20 +1,20 @@ -const float TTT_TURN_PLACE = 0x0100; // player has to place a piece on the board -const float TTT_TURN_WIN = 0x0200; // player has won -const float TTT_TURN_DRAW = 0x0400; // no moves are possible -const float TTT_TURN_NEXT = 0x0800; // a player wants to start a new match -const float TTT_TURN_TYPE = 0x0f00; // turn type mask +const int TTT_TURN_PLACE = 0x0100; // player has to place a piece on the board +const int TTT_TURN_WIN = 0x0200; // player has won +const int TTT_TURN_DRAW = 0x0400; // no moves are possible +const int TTT_TURN_NEXT = 0x0800; // a player wants to start a new match +const int TTT_TURN_TYPE = 0x0f00; // turn type mask -const float TTT_TURN_TEAM1 = 0x0001; -const float TTT_TURN_TEAM2 = 0x0002; -const float TTT_TURN_TEAM = 0x000f; // turn team mask +const int TTT_TURN_TEAM1 = 0x0001; +const int TTT_TURN_TEAM2 = 0x0002; +const int TTT_TURN_TEAM = 0x000f; // turn team mask // send flags -const float TTT_SF_PLAYERSCORE = MINIG_SF_CUSTOM; // send minigame_player scores (won matches) -const float TTT_SF_SINGLEPLAYER = MINIG_SF_CUSTOM<<1;// send minigame.ttt_ai +const int TTT_SF_PLAYERSCORE = MINIG_SF_CUSTOM; // send minigame_player scores (won matches) +const int TTT_SF_SINGLEPLAYER = MINIG_SF_CUSTOM<<1;// send minigame.ttt_ai -.float ttt_npieces; // (minigame) number of pieces on the board (simplifies checking a draw) -.float ttt_nexteam; // (minigame) next team (used to change the starting team on following matches) -.float ttt_ai; // (minigame) when non-zero, singleplayer vs AI +.int ttt_npieces; // (minigame) number of pieces on the board (simplifies checking a draw) +.int ttt_nexteam; // (minigame) next team (used to change the starting team on following matches) +.int ttt_ai; // (minigame) when non-zero, singleplayer vs AI // find tic tac toe piece given its tile name entity ttt_find_piece(entity minig, string tile) @@ -27,43 +27,43 @@ entity ttt_find_piece(entity minig, string tile) } // Checks if the given piece completes a row -float ttt_winning_piece(entity piece) +bool ttt_winning_piece(entity piece) { - float number = minigame_tile_number(piece.netname); - float letter = minigame_tile_letter(piece.netname); + int number = minigame_tile_number(piece.netname); + int letter = minigame_tile_letter(piece.netname); if ( ttt_find_piece(piece.owner,minigame_tile_buildname(0,number)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(1,number)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(2,number)).team == piece.team ) - return 1; + return true; if ( ttt_find_piece(piece.owner,minigame_tile_buildname(letter,0)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(letter,1)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(letter,2)).team == piece.team ) - return 1; + return true; if ( number == letter ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(0,0)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(1,1)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(2,2)).team == piece.team ) - return 1; + return true; if ( number == 2-letter ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(0,2)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(1,1)).team == piece.team ) if ( ttt_find_piece(piece.owner,minigame_tile_buildname(2,0)).team == piece.team ) - return 1; + return true; - return 0; + return false; } // check if the tile name is valid (3x3 grid) -float ttt_valid_tile(string tile) +bool ttt_valid_tile(string tile) { if ( !tile ) return 0; - float number = minigame_tile_number(tile); - float letter = minigame_tile_letter(tile); + int number = minigame_tile_number(tile); + int letter = minigame_tile_letter(tile); return 0 <= number && number < 3 && 0 <= letter && letter < 3; } @@ -125,7 +125,7 @@ void ttt_next_match(entity minigame, entity player) // required function, handle server side events -float minigame_event_ttt(entity minigame, string event, ...) +int minigame_event_ttt(entity minigame, string event, ...) { switch(event) { @@ -147,7 +147,7 @@ float minigame_event_ttt(entity minigame, string event, ...) } case "join": { - float pl_num = minigame_count_players(minigame); + int pl_num = minigame_count_players(minigame); // Don't allow joining a single player match if ( (minigame.ttt_ai) && pl_num > 0 ) @@ -168,7 +168,7 @@ float minigame_event_ttt(entity minigame, string event, ...) switch(argv(0)) { case "move": - ttt_move(minigame, ...(0,entity), ...(1,float) == 2 ? argv(1) : string_null ); + ttt_move(minigame, ...(0,entity), ...(1,int) == 2 ? argv(1) : string_null ); return true; case "next": ttt_next_match(minigame,...(0,entity)); @@ -187,7 +187,7 @@ float minigame_event_ttt(entity minigame, string event, ...) case "network_send": { entity sent = ...(0,entity); - float sf = ...(1,float); + int sf = ...(1,int); if ( sent.classname == "minigame_player" && (sf & TTT_SF_PLAYERSCORE ) ) { WriteByte(MSG_ENTITY,sent.minigame_flags); @@ -209,7 +209,7 @@ float minigame_event_ttt(entity minigame, string event, ...) string ttt_curr_pos; // identifier of the tile under the mouse vector ttt_boardpos; // HUD board position vector ttt_boardsize;// HUD board size -.float ttt_checkwin; // Used to optimize checks to display a win +.int ttt_checkwin; // Used to optimize checks to display a win // Required function, draw the game board void minigame_hud_board_ttt(vector pos, vector mySize) @@ -306,7 +306,7 @@ void minigame_hud_status_ttt(vector pos, vector mySize) } // Turn a set of flags into a help message -string ttt_turn_to_string(float turnflags) +string ttt_turn_to_string(int turnflags) { if ( turnflags & TTT_TURN_DRAW ) return _("Draw"); @@ -334,18 +334,18 @@ string ttt_turn_to_string(float turnflags) return ""; } -const float TTT_AI_POSFLAG_A1 = 0x0001; -const float TTT_AI_POSFLAG_A2 = 0x0002; -const float TTT_AI_POSFLAG_A3 = 0x0004; -const float TTT_AI_POSFLAG_B1 = 0x0008; -const float TTT_AI_POSFLAG_B2 = 0x0010; -const float TTT_AI_POSFLAG_B3 = 0x0020; -const float TTT_AI_POSFLAG_C1 = 0x0040; -const float TTT_AI_POSFLAG_C2 = 0x0080; -const float TTT_AI_POSFLAG_C3 = 0x0100; +const int TTT_AI_POSFLAG_A1 = 0x0001; +const int TTT_AI_POSFLAG_A2 = 0x0002; +const int TTT_AI_POSFLAG_A3 = 0x0004; +const int TTT_AI_POSFLAG_B1 = 0x0008; +const int TTT_AI_POSFLAG_B2 = 0x0010; +const int TTT_AI_POSFLAG_B3 = 0x0020; +const int TTT_AI_POSFLAG_C1 = 0x0040; +const int TTT_AI_POSFLAG_C2 = 0x0080; +const int TTT_AI_POSFLAG_C3 = 0x0100; // convert a flag to a position -string ttt_ai_piece_flag2pos(float pieceflag) +string ttt_ai_piece_flag2pos(int pieceflag) { switch(pieceflag) { @@ -375,13 +375,13 @@ string ttt_ai_piece_flag2pos(float pieceflag) } } -float ttt_ai_checkmask(float piecemask, float checkflags) +bool ttt_ai_checkmask(int piecemask, int checkflags) { return checkflags && (piecemask & checkflags) == checkflags; } // get the third flag if the mask matches two of them -float ttt_ai_1of3(float piecemask, float flag1, float flag2, float flag3) +int ttt_ai_1of3(int piecemask, int flag1, int flag2, int flag3) { if ( ttt_ai_checkmask(piecemask,flag1|flag2|flag3) ) return 0; @@ -399,17 +399,16 @@ float ttt_ai_1of3(float piecemask, float flag1, float flag2, float flag3) } // Select a random flag in the mask -float ttt_ai_random(float piecemask) +int ttt_ai_random(int piecemask) { if ( !piecemask ) return 0; - float i; - float f = 1; + int f = 1; RandomSelection_Init(); - for ( i = 0; i < 9; i++ ) + for ( int i = 0; i < 9; i++ ) { if ( piecemask & f ) RandomSelection_Add(world, f, string_null, 1, 1); @@ -422,9 +421,9 @@ float ttt_ai_random(float piecemask) } // Block/complete a 3 i na row -float ttt_ai_block3 ( float piecemask, float piecemask_free ) +int ttt_ai_block3 ( int piecemask, int piecemask_free ) { - float r = 0; + int r = 0; r |= ttt_ai_1of3(piecemask,TTT_AI_POSFLAG_A1,TTT_AI_POSFLAG_A2,TTT_AI_POSFLAG_A3); r |= ttt_ai_1of3(piecemask,TTT_AI_POSFLAG_B1,TTT_AI_POSFLAG_B2,TTT_AI_POSFLAG_B3); @@ -443,9 +442,9 @@ float ttt_ai_block3 ( float piecemask, float piecemask_free ) // 1) tries to win the game if possible // 2) tries to block the opponent if they have 2 in a row // 3) places a piece randomly -string ttt_ai_choose_simple(float piecemask_self, float piecemask_opponent, float piecemask_free ) +string ttt_ai_choose_simple(int piecemask_self, int piecemask_opponent, int piecemask_free ) { - float move = 0; + int move = 0; dprint("TTT AI: checking winning move\n"); if (( move = ttt_ai_block3(piecemask_self,piecemask_free) )) @@ -480,15 +479,14 @@ void ttt_aimove(entity minigame) * '---'---'---' * A B C */ - float piecemask_self = 0; - float piecemask_opponent = 0; - float piecemask_free = 0; - float pieceflag = 1; + int piecemask_self = 0; + int piecemask_opponent = 0; + int piecemask_free = 0; + int pieceflag = 1; string pos; - float i,j; - for ( i = 0; i < 3; i++ ) - for ( j = 0; j < 3; j++ ) + for ( int i = 0; i < 3; i++ ) + for ( int j = 0; j < 3; j++ ) { pos = minigame_tile_buildname(i,j); entity piece = ttt_find_piece(minigame,pos); @@ -542,7 +540,7 @@ void ttt_set_curr_pos(string s) } // Required function, handle client events -float minigame_event_ttt(entity minigame, string event, ...) +int minigame_event_ttt(entity minigame, string event, ...) { switch(event) { @@ -556,7 +554,7 @@ float minigame_event_ttt(entity minigame, string event, ...) { if((minigame.minigame_flags & TTT_TURN_TEAM) == minigame_self.team) { - switch ( ...(0,float) ) + switch ( ...(0,int) ) { case K_RIGHTARROW: case K_KP_RIGHTARROW: @@ -598,7 +596,7 @@ float minigame_event_ttt(entity minigame, string event, ...) } case "mouse_pressed": { - if(...(0,float) == K_MOUSE1) + if(...(0,int) == K_MOUSE1) { ttt_make_move(minigame); return true; @@ -619,7 +617,7 @@ float minigame_event_ttt(entity minigame, string event, ...) case "network_receive": { entity sent = ...(0,entity); - float sf = ...(1,float); + int sf = ...(1,int); if ( sent.classname == "minigame" ) { if ( sf & MINIG_SF_UPDATE ) @@ -631,8 +629,8 @@ float minigame_event_ttt(entity minigame, string event, ...) if ( (sf & TTT_SF_SINGLEPLAYER) ) { - float ai = ReadByte(); - float spawnai = ai && !sent.ttt_ai; + int ai = ReadByte(); + bool spawnai = ai && !sent.ttt_ai; sent.ttt_ai = ai; if ( spawnai ) diff --git a/qcsrc/common/minigames/minigames.qc b/qcsrc/common/minigames/minigames.qc index 46f0a9c57..a8daa4484 100644 --- a/qcsrc/common/minigames/minigames.qc +++ b/qcsrc/common/minigames/minigames.qc @@ -10,7 +10,7 @@ entity minigame_get_descriptor(string id) } // Get letter index of a tile name -float minigame_tile_letter(string id) +int minigame_tile_letter(string id) { return str2chr(substring(id,0,1),0)-'a'; } @@ -19,29 +19,29 @@ float minigame_tile_letter(string id) // Note: this is 0 based, useful for mathematical operations // Note: Since the tile notation starts from the bottom left, // you may want to do number_of_rows - what_this_function_returns or something -float minigame_tile_number(string id) +int minigame_tile_number(string id) { return stof(substring(id,1,-1)) -1 ; } // Get relative position of the center of a given tile -vector minigame_tile_pos(string id, float rows, float columns) +vector minigame_tile_pos(string id, int rows, int columns) { return eX*(minigame_tile_letter(id)+0.5)/columns + eY - eY*(minigame_tile_number(id)+0.5)/rows; } // Get a tile name from indices -string minigame_tile_buildname(float letter, float number) +string minigame_tile_buildname(int letter, int number) { return strcat(chr2str('a'+letter),ftos(number+1)); } // Get the id of a tile relative to the given one -string minigame_relative_tile(string start_id, float dx, float dy, float rows, float columns) +string minigame_relative_tile(string start_id, int dx, int dy, int rows, int columns) { - float letter = minigame_tile_letter(start_id); - float number = minigame_tile_number(start_id); + int letter = minigame_tile_letter(start_id); + int number = minigame_tile_number(start_id); letter = (letter+dx) % columns; number = (number+dy) % rows; if ( letter < 0 ) @@ -52,25 +52,25 @@ string minigame_relative_tile(string start_id, float dx, float dy, float rows, f } // Get tile name from a relative position (matches the tile covering a square area) -string minigame_tile_name(vector pos, float rows, float columns) +string minigame_tile_name(vector pos, int rows, int columns) { if ( pos_x < 0 || pos_x > 1 || pos_y < 0 || pos_y > 1 ) return ""; // no tile - float letter = floor(pos_x * columns); - float number = floor((1-pos_y) * rows); + int letter = floor(pos_x * columns); + int number = floor((1-pos_y) * rows); return minigame_tile_buildname(letter, number); } // Get the next team number (note: team numbers are between 1 and n_teams, inclusive) -float minigame_next_team(float curr_team, float n_teams) +int minigame_next_team(int curr_team, int n_teams) { return curr_team % n_teams + 1; } // set send flags only when on server // (for example in game logic which can be used both in client and server -void minigame_server_sendflags(entity ent, float mgflags) +void minigame_server_sendflags(entity ent, int mgflags) { #ifdef SVQC ent.SendFlags |= mgflags; @@ -92,32 +92,32 @@ entity msle_spawn(entity minigame_session, string class_name) return e; } -const float msle_base_id = 2; -float msle_id(string class_name) +const int msle_base_id = 2; +int msle_id(string class_name) { if ( class_name == "minigame" ) return 1; if ( class_name == "minigame_player" ) return 2; - float i = msle_base_id; + int i = msle_base_id; #define MSLE(Name, Fields) i++; if ( class_name == #Name ) return i; MINIGAME_SIMPLELINKED_ENTITIES #undef MSLE return 0; } -string msle_classname(float id) +string msle_classname(int id) { if ( id == 1 ) return "minigame"; if ( id == 2 ) return "minigame_player"; - float i = msle_base_id; + int i = msle_base_id; #define MSLE(Name, Fields) i++; if ( id == i ) return #Name; MINIGAME_SIMPLELINKED_ENTITIES #undef MSLE return ""; } -float minigame_count_players(entity minigame) +int minigame_count_players(entity minigame) { - float pl_num = 0; + int pl_num = 0; entity e; #ifdef SVQC for(e = minigame.minigame_players; e; e = e.list_next) diff --git a/qcsrc/common/minigames/minigames.qh b/qcsrc/common/minigames/minigames.qh index 3b8bbafb4..6d3201c51 100644 --- a/qcsrc/common/minigames/minigames.qh +++ b/qcsrc/common/minigames/minigames.qh @@ -11,35 +11,35 @@ entity minigame_descriptors; entity minigame_get_descriptor(string id); // Get letter index of a tile name -float minigame_tile_letter(string id); +int minigame_tile_letter(string id); // Get number index of a tile name // Note: this is 0 based, useful for mathematical operations // Note: Since the tile notation starts from the bottom left, // you may want to do number_of_rows - what_this_function_returns or something -float minigame_tile_number(string id); +int minigame_tile_number(string id); // Get relative position of the center of a given tile -vector minigame_tile_pos(string id, float rows, float columns); +vector minigame_tile_pos(string id, int rows, int columns); // Get a tile name from indices -string minigame_tile_buildname(float letter, float number); +string minigame_tile_buildname(int letter, int number); // Get the id of a tile relative to the given one -string minigame_relative_tile(string start_id, float dx, float dy, float rows, float columns); +string minigame_relative_tile(string start_id, int dx, int dy, int rows, int columns); // Get tile name from a relative position (matches the tile covering a square area) -string minigame_tile_name(vector pos, float rows, float columns); +string minigame_tile_name(vector pos, int rows, int columns); // Get the next team number (note: team numbers are between 1 and n_teams, inclusive) -float minigame_next_team(float curr_team, float n_teams); +int minigame_next_team(int curr_team, int n_teams); // set send flags only when on server // (for example in game logic which can be used both in client and server -void minigame_server_sendflags(entity ent, float mgflags); +void minigame_server_sendflags(entity ent, int mgflags); // count the number of players in a minigame session -float minigame_count_players(entity minigame); +int minigame_count_players(entity minigame); /// For minigame sessions: minigame descriptor object .entity descriptor; @@ -48,17 +48,17 @@ float minigame_count_players(entity minigame); /// Client events: /// mouse_moved(vector mouse_pos) /// return 1 to handle input, 0 to discard -/// mouse_pressed/released(float K_Keycode) +/// mouse_pressed/released(int K_Keycode) /// return 1 to handle input, 0 to discard /// note: see dpdefs/keycodes.qc for values -/// key_pressed/released(float K_Keycode) +/// key_pressed/released(int K_Keycode) /// return 1 to handle input, 0 to discard /// note: see dpdefs/keycodes.qc for values /// activate() /// executed when the minigame is activated for the current client /// deactivate() /// executed when the minigame is deactivated for the current client -/// network_receive(entity received,float flags) +/// network_receive(entity received,int flags) /// executed each time a networked entity is received /// note: when this is called self == ...(0,entity) /// You can use the MINIG_SF_ constants to check the send flags @@ -78,38 +78,38 @@ float minigame_count_players(entity minigame); /// return the player team number to accept the new player, 0 to discard /// part(entity player) /// executed when a player is going to leave the session -/// network_send(entity sent,float flags) +/// network_send(entity sent,int flags) /// executed each time a networked entity is sent /// note: when this is called self == ...(0,entity) /// You can use the MINIG_SF_ constants to check the send flags /// IMPORTANT: always read in client everything you send from the server! -/// cmd(entity minigame_player, float argc, string command) +/// cmd(entity minigame_player, int argc, string command) /// self = client entity triggering this /// argv(n) = console token /// argc: number of console tokens /// command: full command string /// triggered when a player does "cmd minigame ..." with some unrecognized command /// return 1 if the minigame has handled the command -/// impulse(entity minigame_player,float impulse) +/// impulse(entity minigame_player,int impulse) /// self = client entity triggering this /// triggered when a player does "impulse ..." /// return 1 if the minigame has handled the impulse -.float(entity,string,...) minigame_event; +.int(entity,string,...) minigame_event; // For run-time gameplay entities: Whether to be removed when the game is deactivated -.float minigame_autoclean; +.bool minigame_autoclean; // For run-time gameplay entities: some place to store flags safely -.float minigame_flags; +.int minigame_flags; // Send flags, set to .SendFlags on networked entities to send entity information // Flag values for customized events must be powers of 2 in the range // [MINIG_SF_CUSTOM, MINIG_SF_MAX] (inclusive) -const float MINIG_SF_CREATE = 0x01; // Create a new object -const float MINIG_SF_UPDATE = 0x02; // miscellaneous entity update -const float MINIG_SF_CUSTOM = 0x10; // a customized networked event -const float MINIG_SF_MAX = 0x80; // maximum flag value sent over the network -const float MINIG_SF_ALL = 0xff; // use to resend everything +const int MINIG_SF_CREATE = 0x01; // Create a new object +const int MINIG_SF_UPDATE = 0x02; // miscellaneous entity update +const int MINIG_SF_CUSTOM = 0x10; // a customized networked event +const int MINIG_SF_MAX = 0x80; // maximum flag value sent over the network +const int MINIG_SF_ALL = 0xff; // use to resend everything // Spawn linked entity on the server or local entity on the client @@ -118,7 +118,7 @@ entity msle_spawn(entity minigame_session, string class_name); #include "minigame/all.qh" -float msle_id(string class_name); -string msle_classname(float id); +int msle_id(string class_name); +string msle_classname(int id); #endif diff --git a/qcsrc/common/minigames/sv_minigames.qc b/qcsrc/common/minigames/sv_minigames.qc index 1953e9674..f6be414fc 100644 --- a/qcsrc/common/minigames/sv_minigames.qc +++ b/qcsrc/common/minigames/sv_minigames.qc @@ -60,7 +60,7 @@ void minigame_rmplayer(entity minigame_session, entity player) // Send an entity to a client // only use on minigame entities or entities with a minigame owner -float minigame_SendEntity(entity to, float sf) +bool minigame_SendEntity(entity to, int sf) { WriteByte(MSG_ENTITY, ENT_CLIENT_MINIGAME); WriteByte(MSG_ENTITY, sf); @@ -97,7 +97,7 @@ float minigame_SendEntity(entity to, float sf) minigame_ent.minigame_event(minigame_ent,"network_send",self,sf); - return 1; + return true; } #undef FIELD @@ -115,16 +115,16 @@ void minigame_resend(entity minigame) } } -float minigame_CheckSend() +bool minigame_CheckSend() { entity e; for ( e = self.owner.minigame_players; e != world; e = e.list_next ) if ( e.minigame_players == other ) - return 1; - return 0; + return true; + return false; } -float minigame_addplayer(entity minigame_session, entity player) +int minigame_addplayer(entity minigame_session, entity player) { if ( player.active_minigame ) { @@ -133,7 +133,7 @@ float minigame_addplayer(entity minigame_session, entity player) minigame_rmplayer(player.active_minigame,player); } - float mgteam = minigame_session.minigame_event(minigame_session,"join",player); + int mgteam = minigame_session.minigame_event(minigame_session,"join",player); if ( mgteam ) { @@ -316,19 +316,19 @@ entity minigame_find_player(entity client) return world; } -float MinigameImpulse(float imp) +bool MinigameImpulse(int imp) { entity e = minigame_find_player(self); if ( imp && self.active_minigame && e ) { return self.active_minigame.minigame_event(self.active_minigame,"impulse",e,imp); } - return 0; + return false; } -void ClientCommand_minigame(float request, float argc, string command) +void ClientCommand_minigame(int request, int argc, string command) { if ( !autocvar_sv_minigames ) { @@ -407,7 +407,7 @@ void ClientCommand_minigame(float request, float argc, string command) { entity e = minigame_find_player(self); string subcommand = substring(command,argv_end_index(0),-1); - float arg_c = tokenize_console(subcommand); + int arg_c = tokenize_console(subcommand); if ( self.active_minigame.minigame_event(self.active_minigame,"cmd",e,arg_c,subcommand) ) return; diff --git a/qcsrc/common/minigames/sv_minigames.qh b/qcsrc/common/minigames/sv_minigames.qh index c9591bb13..246440d39 100644 --- a/qcsrc/common/minigames/sv_minigames.qh +++ b/qcsrc/common/minigames/sv_minigames.qh @@ -27,13 +27,13 @@ void end_minigames(); // Only sends entities to players who joined the minigame // Use on customizeentityforclient for gameplay entities -float minigame_CheckSend(); +bool minigame_CheckSend(); // Check for minigame impulses -float MinigameImpulse(float imp); +bool MinigameImpulse(int imp); // Parse a client command ( cmd minigame ... ) -void ClientCommand_minigame(float request, float argc, string command); +void ClientCommand_minigame(int request, int argc, string command); // Find the minigame_player entity for the given client entity entity minigame_find_player(entity client); @@ -47,8 +47,6 @@ entity minigame_find_player(entity client); entity minigame_sessions; -float minigame_SendEntity(entity to, float sf); - -var void remove(entity e); +bool minigame_SendEntity(entity to, int sf); #endif diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 0a81a2c65..d3a19d4c8 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -1473,7 +1473,7 @@ float notif_global_error; .string nent_iconargs; #define MULTIICON_INFO(default,name,strnum,flnum,args,hudargs,iconargs,icon,normal,gentle) \ NOTIF_ADD_AUTOCVAR(name, default) \ - float name; \ + int name; \ void RegisterNotification_##name() \ { \ SET_FIELD_COUNT(name, NOTIF_FIRST, NOTIF_INFO_COUNT) \ -- 2.39.2