X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fminigames%2Fminigame%2Fc4.qc;h=c8f8184f5b0bd019862d1b73ecc631faea5084f1;hb=bc50c2d7ca3e0a44ed1712400ef8e170e6df8210;hp=98020972a742ee5a59e4eef24e69a7a483f6e69c;hpb=120ad19fdf46b7096a0f90b940e590f1909ad22c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/minigames/minigame/c4.qc b/qcsrc/common/minigames/minigame/c4.qc index 98020972a..c8f8184f5 100644 --- a/qcsrc/common/minigames/minigame/c4.qc +++ b/qcsrc/common/minigames/minigame/c4.qc @@ -1,9 +1,9 @@ +#include "c4.qh" REGISTER_MINIGAME(c4, "Connect Four"); const float C4_TURN_PLACE = 0x0100; // player has to place a piece on the board const float C4_TURN_WIN = 0x0200; // player has won const float C4_TURN_DRAW = 0x0400; // no moves are possible -const float C4_TURN_TYPE = 0x0f00; // turn type mask const float C4_TURN_TEAM1 = 0x0001; const float C4_TURN_TEAM2 = 0x0002; @@ -25,11 +25,11 @@ const int C4_TEAMS = 2; // find connect 4 piece given its tile name entity c4_find_piece(entity minig, string tile) { - entity e = world; + entity e = NULL; while ( ( e = findentity(e,owner,minig) ) ) if ( e.classname == "minigame_board_piece" && e.netname == tile ) return e; - return world; + return NULL; } // Checks if the given piece completes a row @@ -197,12 +197,12 @@ int c4_server_event(entity minigame, string event, ...) } case "end": { - entity e = world; + entity e = NULL; while( (e = findentity(e, owner, minigame)) ) if(e.classname == "minigame_board_piece") { - if(e.netname) { strunzone(e.netname); } - remove(e); + strfree(e.netname); + delete(e); } return false; } @@ -299,22 +299,22 @@ void c4_hud_board(vector pos, vector mySize) if ( active_minigame.minigame_flags & C4_TURN_WIN ) { vector winfs = hud_fontsize*2; - string playername = ""; + string pname = ""; FOREACH_MINIGAME_ENTITY(e) if ( e.classname == "minigame_player" && e.team == (active_minigame.minigame_flags & C4_TURN_TEAM) ) - playername = GetPlayerName(e.minigame_playerslot-1); + pname = entcs_GetName(e.minigame_playerslot-1); vector win_pos = pos+eY*(mySize_y-winfs_y)/2; vector win_sz; win_sz = minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, 0, DRAWFLAG_NORMAL, 0.5); drawfill(win_pos-eY*hud_fontsize_y,win_sz+2*eY*hud_fontsize_y,'1 1 1',0.5,DRAWFLAG_ADDITIVE); minigame_drawcolorcodedstring_wrapped(mySize_x,win_pos, - sprintf("%s^7 won the game!",playername), + sprintf("%s^7 won the game!",pname), winfs, panel_fg_alpha, DRAWFLAG_NORMAL, 0.5); } } @@ -323,7 +323,7 @@ void c4_hud_board(vector pos, vector mySize) // Required function, draw the game status panel void c4_hud_status(vector pos, vector mySize) { - HUD_Panel_DrawBg(1); + HUD_Panel_DrawBg(); vector ts; ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message, hud_fontsize * 2, '0.25 0.47 0.72', panel_fg_alpha, DRAWFLAG_NORMAL,0.5); @@ -353,7 +353,7 @@ void c4_hud_status(vector pos, vector mySize) if ( e.team == 2 ) mypos_y += player_fontsize_y + ts_y; minigame_drawcolorcodedstring_trunc(mySize_x,mypos, - GetPlayerName(e.minigame_playerslot-1), + entcs_GetName(e.minigame_playerslot-1), player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); mypos_y += player_fontsize_y; @@ -399,8 +399,7 @@ void c4_make_move(entity minigame) void c4_set_curr_pos(string s) { - if ( c4_curr_pos ) - strunzone(c4_curr_pos); + strfree(c4_curr_pos); if ( s ) s = strzone(s); c4_curr_pos = s;