X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fcommand%2Fsv_cmd.qc;h=5ff2d3472ae22ebbf2d3d898e0ecbd5f4ae4c910;hp=9ba78c32a0546cce999d177a6649adfa8e0f42fb;hb=af43b181a15f348a4de2045b716ebc7765ce8f9f;hpb=aa1c87cd3f79ddaf4e45ebf9428293cfdf2d6733 diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 9ba78c32a..5ff2d3472 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -88,7 +88,7 @@ void changematchtime(float delta, float mi, float ma) // Command Sub-Functions // ======================= -void GameCommand_adminmsg(float request, float argc) +void GameCommand_adminmsg(int request, int argc) { switch (request) { @@ -160,7 +160,7 @@ void GameCommand_adminmsg(float request, float argc) } } -void GameCommand_allready(float request) +void GameCommand_allready(int request) { switch (request) { @@ -180,7 +180,7 @@ void GameCommand_allready(float request) } } -void GameCommand_allspec(float request, float argc) +void GameCommand_allspec(int request, int argc) { switch (request) { @@ -209,7 +209,7 @@ void GameCommand_allspec(float request, float argc) } } -void GameCommand_anticheat(float request, float argc) +void GameCommand_anticheat(int request, int argc) { switch (request) { @@ -240,7 +240,7 @@ void GameCommand_anticheat(float request, float argc) } } -void GameCommand_bbox(float request) +void GameCommand_bbox(int request) { switch (request) { @@ -313,7 +313,7 @@ void GameCommand_bbox(float request) } } -void GameCommand_bot_cmd(float request, float argc, string command) +void GameCommand_bot_cmd(int request, int argc, string command) { switch (request) { @@ -330,6 +330,7 @@ void GameCommand_bot_cmd(float request, float argc, string command) { cvar_settemp("bot_vs_human", "0"); cvar_settemp("minplayers", "0"); + cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", "0"); bot_fixcount(); cvar_settemp("bot_number", argv(2)); @@ -362,6 +363,7 @@ void GameCommand_bot_cmd(float request, float argc, string command) { cvar_settemp("bot_vs_human", "0"); cvar_settemp("minplayers", "0"); + cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", "0"); bot_fixcount(); cvar_settemp("bot_number", argv(3)); @@ -445,7 +447,7 @@ void GameCommand_bot_cmd(float request, float argc, string command) } } -void GameCommand_cointoss(float request, float argc) +void GameCommand_cointoss(int request, int argc) { switch (request) { @@ -469,7 +471,7 @@ void GameCommand_cointoss(float request, float argc) } } -void GameCommand_database(float request, float argc) +void GameCommand_database(int request, int argc) { switch (request) { @@ -512,7 +514,7 @@ void GameCommand_database(float request, float argc) } } -void GameCommand_defer_clear(float request, float argc) +void GameCommand_defer_clear(int request, int argc) { switch (request) { @@ -549,14 +551,14 @@ void GameCommand_defer_clear(float request, float argc) } } -void GameCommand_defer_clear_all(float request) +void GameCommand_defer_clear_all(int request) { switch (request) { case CMD_REQUEST_COMMAND: { int n = 0; - float argc; + int argc; FOREACH_CLIENT(true, { argc = tokenize_console(strcat("defer_clear ", ftos(etof(it)))); @@ -578,7 +580,7 @@ void GameCommand_defer_clear_all(float request) } } -void GameCommand_delrec(float request, float argc) // perhaps merge later with records and printstats and such? +void GameCommand_delrec(int request, int argc) // perhaps merge later with records and printstats and such? { switch (request) { @@ -605,7 +607,14 @@ void GameCommand_delrec(float request, float argc) // perhaps merge later with } } -void GameCommand_effectindexdump(float request) +void print_Effect_Index(int d, string effect_name) +{ + // this is inside a function to avoid expanding it on compilation everytime + LOG_INFO("effect ", effect_name, " is ", ftos(_particleeffectnum(effect_name)), "\n"); + db_put(d, effect_name, "1"); +} + +void GameCommand_effectindexdump(int request) { switch (request) { @@ -616,78 +625,43 @@ void GameCommand_effectindexdump(float request) d = db_create(); LOG_INFO("begin of effects list"); - db_put(d, "TE_GUNSHOT", "1"); - LOG_INFO("effect TE_GUNSHOT is ", ftos(_particleeffectnum("TE_GUNSHOT"))); - db_put(d, "TE_GUNSHOTQUAD", "1"); - LOG_INFO("effect TE_GUNSHOTQUAD is ", ftos(_particleeffectnum("TE_GUNSHOTQUAD"))); - db_put(d, "TE_SPIKE", "1"); - LOG_INFO("effect TE_SPIKE is ", ftos(_particleeffectnum("TE_SPIKE"))); - db_put(d, "TE_SPIKEQUAD", "1"); - LOG_INFO("effect TE_SPIKEQUAD is ", ftos(_particleeffectnum("TE_SPIKEQUAD"))); - db_put(d, "TE_SUPERSPIKE", "1"); - LOG_INFO("effect TE_SUPERSPIKE is ", ftos(_particleeffectnum("TE_SUPERSPIKE"))); - db_put(d, "TE_SUPERSPIKEQUAD", "1"); - LOG_INFO("effect TE_SUPERSPIKEQUAD is ", ftos(_particleeffectnum("TE_SUPERSPIKEQUAD"))); - db_put(d, "TE_WIZSPIKE", "1"); - LOG_INFO("effect TE_WIZSPIKE is ", ftos(_particleeffectnum("TE_WIZSPIKE"))); - db_put(d, "TE_KNIGHTSPIKE", "1"); - LOG_INFO("effect TE_KNIGHTSPIKE is ", ftos(_particleeffectnum("TE_KNIGHTSPIKE"))); - db_put(d, "TE_EXPLOSION", "1"); - LOG_INFO("effect TE_EXPLOSION is ", ftos(_particleeffectnum("TE_EXPLOSION"))); - db_put(d, "TE_EXPLOSIONQUAD", "1"); - LOG_INFO("effect TE_EXPLOSIONQUAD is ", ftos(_particleeffectnum("TE_EXPLOSIONQUAD"))); - db_put(d, "TE_TAREXPLOSION", "1"); - LOG_INFO("effect TE_TAREXPLOSION is ", ftos(_particleeffectnum("TE_TAREXPLOSION"))); - db_put(d, "TE_TELEPORT", "1"); - LOG_INFO("effect TE_TELEPORT is ", ftos(_particleeffectnum("TE_TELEPORT"))); - db_put(d, "TE_LAVASPLASH", "1"); - LOG_INFO("effect TE_LAVASPLASH is ", ftos(_particleeffectnum("TE_LAVASPLASH"))); - db_put(d, "TE_SMALLFLASH", "1"); - LOG_INFO("effect TE_SMALLFLASH is ", ftos(_particleeffectnum("TE_SMALLFLASH"))); - db_put(d, "TE_FLAMEJET", "1"); - LOG_INFO("effect TE_FLAMEJET is ", ftos(_particleeffectnum("TE_FLAMEJET"))); - db_put(d, "EF_FLAME", "1"); - LOG_INFO("effect EF_FLAME is ", ftos(_particleeffectnum("EF_FLAME"))); - db_put(d, "TE_BLOOD", "1"); - LOG_INFO("effect TE_BLOOD is ", ftos(_particleeffectnum("TE_BLOOD"))); - db_put(d, "TE_SPARK", "1"); - LOG_INFO("effect TE_SPARK is ", ftos(_particleeffectnum("TE_SPARK"))); - db_put(d, "TE_PLASMABURN", "1"); - LOG_INFO("effect TE_PLASMABURN is ", ftos(_particleeffectnum("TE_PLASMABURN"))); - db_put(d, "TE_TEI_G3", "1"); - LOG_INFO("effect TE_TEI_G3 is ", ftos(_particleeffectnum("TE_TEI_G3"))); - db_put(d, "TE_TEI_SMOKE", "1"); - LOG_INFO("effect TE_TEI_SMOKE is ", ftos(_particleeffectnum("TE_TEI_SMOKE"))); - db_put(d, "TE_TEI_BIGEXPLOSION", "1"); - LOG_INFO("effect TE_TEI_BIGEXPLOSION is ", ftos(_particleeffectnum("TE_TEI_BIGEXPLOSION"))); - db_put(d, "TE_TEI_PLASMAHIT", "1"); - LOG_INFO("effect TE_TEI_PLASMAHIT is ", ftos(_particleeffectnum("TE_TEI_PLASMAHIT"))); - db_put(d, "EF_STARDUST", "1"); - LOG_INFO("effect EF_STARDUST is ", ftos(_particleeffectnum("EF_STARDUST"))); - db_put(d, "TR_ROCKET", "1"); - LOG_INFO("effect TR_ROCKET is ", ftos(_particleeffectnum("TR_ROCKET"))); - db_put(d, "TR_GRENADE", "1"); - LOG_INFO("effect TR_GRENADE is ", ftos(_particleeffectnum("TR_GRENADE"))); - db_put(d, "TR_BLOOD", "1"); - LOG_INFO("effect TR_BLOOD is ", ftos(_particleeffectnum("TR_BLOOD"))); - db_put(d, "TR_WIZSPIKE", "1"); - LOG_INFO("effect TR_WIZSPIKE is ", ftos(_particleeffectnum("TR_WIZSPIKE"))); - db_put(d, "TR_SLIGHTBLOOD", "1"); - LOG_INFO("effect TR_SLIGHTBLOOD is ", ftos(_particleeffectnum("TR_SLIGHTBLOOD"))); - db_put(d, "TR_KNIGHTSPIKE", "1"); - LOG_INFO("effect TR_KNIGHTSPIKE is ", ftos(_particleeffectnum("TR_KNIGHTSPIKE"))); - db_put(d, "TR_VORESPIKE", "1"); - LOG_INFO("effect TR_VORESPIKE is ", ftos(_particleeffectnum("TR_VORESPIKE"))); - db_put(d, "TR_NEHAHRASMOKE", "1"); - LOG_INFO("effect TR_NEHAHRASMOKE is ", ftos(_particleeffectnum("TR_NEHAHRASMOKE"))); - db_put(d, "TR_NEXUIZPLASMA", "1"); - LOG_INFO("effect TR_NEXUIZPLASMA is ", ftos(_particleeffectnum("TR_NEXUIZPLASMA"))); - db_put(d, "TR_GLOWTRAIL", "1"); - LOG_INFO("effect TR_GLOWTRAIL is ", ftos(_particleeffectnum("TR_GLOWTRAIL"))); - db_put(d, "TR_SEEKER", "1"); - LOG_INFO("effect TR_SEEKER is ", ftos(_particleeffectnum("TR_SEEKER"))); - db_put(d, "SVC_PARTICLE", "1"); - LOG_INFO("effect SVC_PARTICLE is ", ftos(_particleeffectnum("SVC_PARTICLE"))); + + print_Effect_Index(d, "TE_GUNSHOT"); + print_Effect_Index(d, "TE_GUNSHOTQUAD"); + print_Effect_Index(d, "TE_SPIKE"); + print_Effect_Index(d, "TE_SPIKEQUAD"); + print_Effect_Index(d, "TE_SUPERSPIKE"); + print_Effect_Index(d, "TE_SUPERSPIKEQUAD"); + print_Effect_Index(d, "TE_WIZSPIKE"); + print_Effect_Index(d, "TE_KNIGHTSPIKE"); + print_Effect_Index(d, "TE_EXPLOSION"); + print_Effect_Index(d, "TE_EXPLOSIONQUAD"); + print_Effect_Index(d, "TE_TAREXPLOSION"); + print_Effect_Index(d, "TE_TELEPORT"); + print_Effect_Index(d, "TE_LAVASPLASH"); + print_Effect_Index(d, "TE_SMALLFLASH"); + print_Effect_Index(d, "TE_FLAMEJET"); + print_Effect_Index(d, "EF_FLAME"); + print_Effect_Index(d, "TE_BLOOD"); + print_Effect_Index(d, "TE_SPARK"); + print_Effect_Index(d, "TE_PLASMABURN"); + print_Effect_Index(d, "TE_TEI_G3"); + print_Effect_Index(d, "TE_TEI_SMOKE"); + print_Effect_Index(d, "TE_TEI_BIGEXPLOSION"); + print_Effect_Index(d, "TE_TEI_PLASMAHIT"); + print_Effect_Index(d, "EF_STARDUST"); + print_Effect_Index(d, "TR_ROCKET"); + print_Effect_Index(d, "TR_GRENADE"); + print_Effect_Index(d, "TR_BLOOD"); + print_Effect_Index(d, "TR_WIZSPIKE"); + print_Effect_Index(d, "TR_SLIGHTBLOOD"); + print_Effect_Index(d, "TR_KNIGHTSPIKE"); + print_Effect_Index(d, "TR_VORESPIKE"); + print_Effect_Index(d, "TR_NEHAHRASMOKE"); + print_Effect_Index(d, "TR_NEXUIZPLASMA"); + print_Effect_Index(d, "TR_GLOWTRAIL"); + print_Effect_Index(d, "TR_SEEKER"); + print_Effect_Index(d, "SVC_PARTICLE"); fh = fopen("effectinfo.txt", FILE_READ); while ((s = fgets(fh))) @@ -719,7 +693,7 @@ void GameCommand_effectindexdump(float request) } } -void GameCommand_extendmatchtime(float request) +void GameCommand_extendmatchtime(int request) { switch (request) { @@ -740,7 +714,7 @@ void GameCommand_extendmatchtime(float request) } } -void GameCommand_gametype(float request, float argc) +void GameCommand_gametype(int request, int argc) { switch (request) { @@ -790,7 +764,7 @@ void GameCommand_gametype(float request, float argc) } } -void GameCommand_gettaginfo(float request, float argc) +void GameCommand_gettaginfo(int request, int argc) { switch (request) { @@ -820,8 +794,8 @@ void GameCommand_gettaginfo(float request, float argc) { v = gettaginfo(tmp_entity, i); LOG_INFOF( - "model %s frame %s tag %s index %s parent %s", - tmp_entity.model, ftos(tmp_entity.frame), gettaginfo_name, ftos(i), ftos(gettaginfo_parent) + "model %s frame %s tag %s index %s parent %s", + tmp_entity.model, ftos(tmp_entity.frame), gettaginfo_name, ftos(i), ftos(gettaginfo_parent) ); LOG_INFOF(" vector = %s %s %s", ftos(v.x), ftos(v.y), ftos(v.z)); LOG_INFOF(" offset = %s %s %s", ftos(gettaginfo_offset.x), ftos(gettaginfo_offset.y), ftos(gettaginfo_offset.z)); @@ -855,7 +829,7 @@ void GameCommand_gettaginfo(float request, float argc) } } -void GameCommand_animbench(float request, float argc) +void GameCommand_animbench(int request, int argc) { switch (request) { @@ -914,7 +888,7 @@ void GameCommand_animbench(float request, float argc) } } -void GameCommand_gotomap(float request, float argc) +void GameCommand_gotomap(int request, int argc) { switch (request) { @@ -939,7 +913,7 @@ void GameCommand_gotomap(float request, float argc) } } -void GameCommand_lockteams(float request) +void GameCommand_lockteams(int request) { switch (request) { @@ -968,7 +942,7 @@ void GameCommand_lockteams(float request) } } -void GameCommand_make_mapinfo(float request) +void GameCommand_make_mapinfo(int request) { switch (request) { @@ -994,7 +968,7 @@ void GameCommand_make_mapinfo(float request) } } -void GameCommand_moveplayer(float request, float argc) +void GameCommand_moveplayer(int request, int argc) { switch (request) { @@ -1052,8 +1026,8 @@ void GameCommand_moveplayer(float request, float argc) { // set up float team_id; - float save = client.team_forced; - client.team_forced = 0; + int save = Player_GetForcedTeamIndex(client); + Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT); // find the team to move the player to team_id = Team_ColorToTeam(destination); @@ -1073,7 +1047,7 @@ void GameCommand_moveplayer(float request, float argc) { balance = TeamBalance_CheckAllowedTeams(client); } - client.team_forced = save; + Player_SetForcedTeamIndex(client, save); // Check to see if the destination team is even available switch (team_id) @@ -1130,7 +1104,7 @@ void GameCommand_moveplayer(float request, float argc) } // If so, lets continue and finally move the player - client.team_forced = 0; + Player_SetForcedTeamIndex(client, TEAM_FORCE_DEFAULT); if (MoveToTeam(client, Team_TeamToIndex(team_id), 6)) { successful = strcat(successful, (successful ? ", " : ""), playername(client, false)); @@ -1179,7 +1153,7 @@ void GameCommand_moveplayer(float request, float argc) } } -void GameCommand_nospectators(float request) +void GameCommand_nospectators(int request) { switch (request) { @@ -1208,7 +1182,7 @@ void GameCommand_nospectators(float request) } } -void GameCommand_printstats(float request) +void GameCommand_printstats(int request) { switch (request) { @@ -1229,7 +1203,7 @@ void GameCommand_printstats(float request) } } -void GameCommand_radarmap(float request, float argc) +void GameCommand_radarmap(int request, int argc) { switch (request) { @@ -1251,7 +1225,7 @@ void GameCommand_radarmap(float request, float argc) } } -void GameCommand_reducematchtime(float request) +void GameCommand_reducematchtime(int request) { switch (request) { @@ -1272,7 +1246,7 @@ void GameCommand_reducematchtime(float request) } } -void GameCommand_setbots(float request, float argc) +void GameCommand_setbots(int request, int argc) { switch (request) { @@ -1281,6 +1255,7 @@ void GameCommand_setbots(float request, float argc) if (argc >= 2) { cvar_settemp("minplayers", "0"); + cvar_settemp("minplayers_per_team", "0"); cvar_settemp("bot_number", argv(1)); bot_fixcount(); return; @@ -1299,50 +1274,61 @@ void GameCommand_setbots(float request, float argc) } } -void GameCommand_shuffleteams(float request) +void shuffleteams() { - switch (request) + if (!teamplay) { - case CMD_REQUEST_COMMAND: + LOG_INFO("Can't shuffle teams when currently not playing a team game."); + return; + } + + FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, { + if (Player_HasRealForcedTeam(it)) { + // we could theoretically assign forced players to their teams + // and shuffle the rest to fill the empty spots but in practise + // either all players or none are gonna have forced teams + LOG_INFO("Can't shuffle teams because at least one player has a forced team."); + return; + } + }); + + int number_of_teams = 0; + entity balance = TeamBalance_CheckAllowedTeams(NULL); + for (int i = 1; i <= NUM_TEAMS; ++i) + { + if (TeamBalance_IsTeamAllowed(balance, i)) { - if (!teamplay) - { - LOG_INFO("Can't shuffle teams when currently not playing a team game."); - return; - } + number_of_teams = max(i, number_of_teams); + } + } + TeamBalance_Destroy(balance); - FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, { - if (it.team_forced) { - // we could theoretically assign forced players to their teams - // and shuffle the rest to fill the empty spots but in practise - // either all players or none are gonna have forced teams - LOG_INFO("Can't shuffle teams because at least one player has a forced team."); - return; - } - }); + int team_index = 0; + FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, { + int target_team_index = team_index + 1; + if (Entity_GetTeamIndex(it) != target_team_index) + { + MoveToTeam(it, target_team_index, 6); + } + team_index = (team_index + 1) % number_of_teams; + }); + + bprint("Successfully shuffled the players around randomly.\n"); +} - int number_of_teams = 0; - entity balance = TeamBalance_CheckAllowedTeams(NULL); - for (int i = 1; i <= NUM_TEAMS; ++i) +void GameCommand_shuffleteams(int request) +{ + switch (request) + { + case CMD_REQUEST_COMMAND: + { + if (shuffleteams_on_reset_map) { - if (TeamBalance_IsTeamAllowed(balance, i)) - { - number_of_teams = max(i, number_of_teams); - } + bprint("Players will be shuffled when this round is over.\n"); + shuffleteams_on_reset_map = true; } - TeamBalance_Destroy(balance); - - int team_index = 0; - FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, { - int target_team_index = team_index + 1; - if (Entity_GetTeamIndex(it) != target_team_index) - { - MoveToTeam(it, target_team_index, 6); - } - team_index = (team_index + 1) % number_of_teams; - }); - - bprint("Successfully shuffled the players around randomly.\n"); + else + shuffleteams(); return; } @@ -1357,7 +1343,7 @@ void GameCommand_shuffleteams(float request) } } -void GameCommand_stuffto(float request, float argc) +void GameCommand_stuffto(int request, int argc) { // This... is a fairly dangerous and powerful command... - It allows any arguments to be sent to a client via rcon. // Because of this, it is disabled by default and must be enabled by the server owner when doing compilation. That way, @@ -1406,7 +1392,7 @@ void GameCommand_stuffto(float request, float argc) #endif } -void GameCommand_trace(float request, float argc) +void GameCommand_trace(int request, int argc) { switch (request) { @@ -1582,7 +1568,7 @@ void GameCommand_trace(float request, float argc) } } -void GameCommand_unlockteams(float request) +void GameCommand_unlockteams(int request) { switch (request) { @@ -1611,7 +1597,7 @@ void GameCommand_unlockteams(float request) } } -void GameCommand_warp(float request, float argc) +void GameCommand_warp(int request, int argc) { switch (request) { @@ -1650,7 +1636,7 @@ void GameCommand_warp(float request, float argc) /* use this when creating a new command, making sure to place it in alphabetical order... also, ** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! -void GameCommand_(float request) +void GameCommand_(int request) { switch(request) { @@ -1713,7 +1699,7 @@ void GameCommand_macro_help() FOREACH(SERVER_COMMANDS, true, { LOG_INFOF(" ^2%s^7: %s", it.m_name, it.m_description); }); } -float GameCommand_macro_command(float argc, string command) +float GameCommand_macro_command(int argc, string command) { string c = strtolower(argv(0)); FOREACH(SERVER_COMMANDS, it.m_name == c, { @@ -1723,7 +1709,7 @@ float GameCommand_macro_command(float argc, string command) return false; } -float GameCommand_macro_usage(float argc) +float GameCommand_macro_usage(int argc) { string c = strtolower(argv(1)); FOREACH(SERVER_COMMANDS, it.m_name == c, { @@ -1746,7 +1732,7 @@ void GameCommand_macro_write_aliases(float fh) void GameCommand(string command) { - float argc = tokenize_console(command); + int argc = tokenize_console(command); // Guide for working with argc arguments by example: // argc: 1 - 2 - 3 - 4