/* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // // m_mp_start.c // #include "m_local.h" /* ============================================================================= START SERVER MENU ============================================================================= */ typedef struct m_startServerMenu_s { // Local info char **mapNames; int numMaps; // Menu items uiFrameWork_t frameWork; uiImage_t banner; uiAction_t start_action; uiAction_t dmflags_action; uiField_t timelimit_field; uiField_t fraglimit_field; uiField_t maxclients_field; uiField_t hostname_field; uiList_t startmap_list; uiList_t rules_box; uiAction_t back_action; } m_startServerMenu_t; static m_startServerMenu_t m_startServerMenu; static void DMFlagsFunc (void *self) { self = self; if (m_startServerMenu.rules_box.curValue == 1) return; UI_DMFlagsMenu_f (); } static void RulesChangeFunc (void *self) { self = self; // DM if (m_startServerMenu.rules_box.curValue == 0) { m_startServerMenu.maxclients_field.generic.statusBar = NULL; m_startServerMenu.dmflags_action.generic.statusBar = NULL; } else if (m_startServerMenu.rules_box.curValue == 1) { // coop // PGM m_startServerMenu.maxclients_field.generic.statusBar = "4 maximum for cooperative"; if (atoi (m_startServerMenu.maxclients_field.buffer) > 4) Q_strncpyz (m_startServerMenu.maxclients_field.buffer, "4", sizeof (m_startServerMenu.maxclients_field.buffer)); m_startServerMenu.dmflags_action.generic.statusBar = "N/A for cooperative"; } // ROGUE else if (cg.currGameMod == GAME_MOD_ROGUE) { if (m_startServerMenu.rules_box.curValue == 2) { // tag m_startServerMenu.maxclients_field.generic.statusBar = NULL; m_startServerMenu.dmflags_action.generic.statusBar = NULL; } } } static void StartServerActionFunc (void *self) { char startmap[1024]; int timelimit; int fraglimit; int maxclients; char *spot; self = self; Q_strncpyz (startmap, strchr (m_startServerMenu.mapNames[m_startServerMenu.startmap_list.curValue], '\n') + 1, sizeof (startmap)); maxclients = atoi (m_startServerMenu.maxclients_field.buffer); timelimit = atoi (m_startServerMenu.timelimit_field.buffer); fraglimit = atoi (m_startServerMenu.fraglimit_field.buffer); cgi.Cvar_SetValue ("maxclients", clamp (maxclients, 0, maxclients), qFalse); cgi.Cvar_SetValue ("timelimit", clamp (timelimit, 0, timelimit), qFalse); cgi.Cvar_SetValue ("fraglimit", clamp (fraglimit, 0, fraglimit), qFalse); cgi.Cvar_Set ("hostname", m_startServerMenu.hostname_field.buffer, qFalse); if (m_startServerMenu.rules_box.curValue < 2 || cg.currGameMod != GAME_MOD_ROGUE) { cgi.Cvar_SetValue ("deathmatch", !m_startServerMenu.rules_box.curValue, qFalse); cgi.Cvar_SetValue ("coop", m_startServerMenu.rules_box.curValue, qFalse); cgi.Cvar_SetValue ("gamerules", 0, qFalse); } else { cgi.Cvar_SetValue ("deathmatch", 1, qFalse); // deathmatch is always true for rogue games, right? cgi.Cvar_SetValue ("coop", 0, qFalse); cgi.Cvar_SetValue ("gamerules", m_startServerMenu.rules_box.curValue, qFalse); } spot = NULL; if (m_startServerMenu.rules_box.curValue == 1) { if (!Q_stricmp (startmap, "bunk1")) spot = "start"; else if (!Q_stricmp (startmap, "mintro")) spot = "start"; else if (!Q_stricmp (startmap, "fact1")) spot = "start"; else if (!Q_stricmp (startmap, "power1")) spot = "pstart"; else if (!Q_stricmp (startmap, "biggun")) spot = "bstart"; else if (!Q_stricmp (startmap, "hangar1")) spot = "unitstart"; else if (!Q_stricmp (startmap, "city1")) spot = "unitstart"; else if (!Q_stricmp (startmap, "boss1")) spot = "bosstart"; } if (spot) { if (cgi.Com_ServerState ()) cgi.Cbuf_AddText ("disconnect\n"); cgi.Cbuf_AddText (Q_VarArgs ("gamemap \"*%s$%s\"\n", startmap, spot)); } else cgi.Cbuf_AddText (Q_VarArgs ("map %s\n", startmap)); M_ForceMenuOff (); } /* ============= UI_FreeMapNames ============= */ static void UI_FreeMapNames (void) { if (m_startServerMenu.mapNames) { int i; for (i=0 ; i