diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 44a24dcd..8e5bf3fa 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -26,7 +26,7 @@ vector players; // other clients int lastmillis = 0, totalmillis = 0; int lasthit = 0; int curtime = 0; -string clientmap; +string clientmap = ""; int spawnpermission = SP_WRONGMAP; char *getclientmap() { return clientmap; } @@ -732,7 +732,6 @@ playerent *getclient(int cn) // ensure valid entity void initclient() { - clientmap[0] = 0; newname("unarmed"); player1->team = TEAM_SPECT; } diff --git a/source/src/main.cpp b/source/src/main.cpp index db987688..f08b9097 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -752,193 +752,192 @@ int main(int argc, char **argv) else conoutf("unknown commandline argument"); } } - if(!quitdirectly) - { - i18nmanager i18n("AC", path("packages/locale", true)); + if(quitdirectly) return EXIT_SUCCESS; - initing = NOT_INITING; + i18nmanager i18n("AC", path("packages/locale", true)); - initlog("sdl"); - int par = 0; - #ifdef _DEBUG - par = SDL_INIT_NOPARACHUTE; - #endif - if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|par)<0) fatal("Unable to initialize SDL"); + initing = NOT_INITING; - #if 0 - if(highprocesspriority) setprocesspriority(true); - #endif + initlog("sdl"); + int par = 0; + #ifdef _DEBUG + par = SDL_INIT_NOPARACHUTE; + #endif + if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|par)<0) fatal("Unable to initialize SDL"); - initlog("net"); - if(enet_initialize()<0) fatal("Unable to initialise network module"); + #if 0 + if(highprocesspriority) setprocesspriority(true); + #endif - initclient(); - initserver(dedicated); // never returns if dedicated + initlog("net"); + if(enet_initialize()<0) fatal("Unable to initialise network module"); - initlog("world"); - empty_world(7, true); + initclient(); + initserver(dedicated); // never returns if dedicated - initlog("video: sdl"); - if(SDL_InitSubSystem(SDL_INIT_VIDEO)<0) fatal("Unable to initialize SDL Video"); + initlog("world"); + empty_world(7, true); - initlog("video: mode"); - int usedcolorbits = 0, useddepthbits = 0, usedfsaa = 0; - setupscreen(usedcolorbits, useddepthbits, usedfsaa); + initlog("video: sdl"); + if(SDL_InitSubSystem(SDL_INIT_VIDEO)<0) fatal("Unable to initialize SDL Video"); - initlog("video: misc"); - SDL_WM_SetCaption("AssaultCube", NULL); - keyrepeat(false); - SDL_ShowCursor(0); + initlog("video: mode"); + int usedcolorbits = 0, useddepthbits = 0, usedfsaa = 0; + setupscreen(usedcolorbits, useddepthbits, usedfsaa); - initlog("gl"); - gl_checkextensions(); - gl_init(scr_w, scr_h, usedcolorbits, useddepthbits, usedfsaa); + initlog("video: misc"); + SDL_WM_SetCaption("AssaultCube", NULL); + keyrepeat(false); + SDL_ShowCursor(0); - notexture = noworldtexture = textureload("packages/misc/notexture.jpg"); - if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)"); + initlog("gl"); + gl_checkextensions(); + gl_init(scr_w, scr_h, usedcolorbits, useddepthbits, usedfsaa); - initlog("console"); - persistidents = false; - if(!execfile("config/font.cfg")) fatal("cannot find font definitions"); - if(!setfont("default")) fatal("no default font specified"); + notexture = noworldtexture = textureload("packages/misc/notexture.jpg"); + if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)"); - loadingscreen(); + initlog("console"); + persistidents = false; + if(!execfile("config/font.cfg")) fatal("cannot find font definitions"); + if(!setfont("default")) fatal("no default font specified"); - particleinit(); + loadingscreen(); - initlog("sound"); - audiomgr.initsound(); + particleinit(); - initlog("cfg"); - extern void *scoremenu, *teammenu, *ctfmenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu; - scoremenu = addmenu("score", "frags\tdeath\tratio\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); - teammenu = addmenu("team score", "frags\tdeath\tratio\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); - ctfmenu = addmenu("ctf score", "flags\tfrags\tdeath\tratio\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); - servmenu = addmenu("server", NULL, true, refreshservers, serverskey); - searchmenu = addmenu("search", NULL, true, refreshservers, serverskey); - serverinfomenu = addmenu("serverinfo", NULL, true, refreshservers, serverinfokey); - kickmenu = addmenu("kick player", NULL, true, refreshsopmenu); - banmenu = addmenu("ban player", NULL, true, refreshsopmenu); - forceteammenu = addmenu("force team", NULL, true, refreshsopmenu); - giveadminmenu = addmenu("give admin", NULL, true, refreshsopmenu); - docmenu = addmenu("reference", NULL, true, renderdocmenu); - applymenu = addmenu("apply", "apply changes now?", true, refreshapplymenu); + initlog("sound"); + audiomgr.initsound(); - exec("config/scontext.cfg"); - exec("config/locale.cfg"); - exec("config/keymap.cfg"); - exec("config/menus.cfg"); - exec("config/scripts.cfg"); - exec("config/prefabs.cfg"); - exec("config/sounds.cfg"); - exec("config/securemaps.cfg"); - exec("config/admin.cfg"); - execfile("config/servers.cfg"); - persistidents = true; + initlog("cfg"); + extern void *scoremenu, *teammenu, *ctfmenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu; + scoremenu = addmenu("score", "frags\tdeath\tratio\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); + teammenu = addmenu("team score", "frags\tdeath\tratio\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); + ctfmenu = addmenu("ctf score", "flags\tfrags\tdeath\tratio\tpj\tping\tcn\tname", false, renderscores, NULL, false, true); + servmenu = addmenu("server", NULL, true, refreshservers, serverskey); + searchmenu = addmenu("search", NULL, true, refreshservers, serverskey); + serverinfomenu = addmenu("serverinfo", NULL, true, refreshservers, serverinfokey); + kickmenu = addmenu("kick player", NULL, true, refreshsopmenu); + banmenu = addmenu("ban player", NULL, true, refreshsopmenu); + forceteammenu = addmenu("force team", NULL, true, refreshsopmenu); + giveadminmenu = addmenu("give admin", NULL, true, refreshsopmenu); + docmenu = addmenu("reference", NULL, true, renderdocmenu); + applymenu = addmenu("apply", "apply changes now?", true, refreshapplymenu); - static char resdata[] = { 112, 97, 99, 107, 97, 103, 101, 115, 47, 116, 101, 120, 116, 117, 114, 101, 115, 47, 107, 117, 114, 116, 47, 107, 108, 105, 116, 101, 50, 46, 106, 112, 103, 0 }; - stream *f = opengzfile(resdata, "rb"); - if(f) + exec("config/scontext.cfg"); + exec("config/locale.cfg"); + exec("config/keymap.cfg"); + exec("config/menus.cfg"); + exec("config/scripts.cfg"); + exec("config/prefabs.cfg"); + exec("config/sounds.cfg"); + exec("config/securemaps.cfg"); + exec("config/admin.cfg"); + execfile("config/servers.cfg"); + persistidents = true; + + static char resdata[] = { 112, 97, 99, 107, 97, 103, 101, 115, 47, 116, 101, 120, 116, 117, 114, 101, 115, 47, 107, 117, 114, 116, 47, 107, 108, 105, 116, 101, 50, 46, 106, 112, 103, 0 }; + stream *f = opengzfile(resdata, "rb"); + if(f) + { + int n = f->getlil(); + loopi(n) { - int n = f->getlil(); - loopi(n) - { - string s; - f->read(s, sizeof(string)); - enet_uint32 c = f->getlil(); - setresdata(s, c); - } + string s; + f->read(s, sizeof(string)); + enet_uint32 c = f->getlil(); + setresdata(s, c); + } delete f; - } + } - initing = INIT_LOAD; - if(!execfile("config/saved.cfg")) + initing = INIT_LOAD; + if(!execfile("config/saved.cfg")) + { + exec("config/defaults.cfg"); + firstrun = true; + } + execfile("config/autoexec.cfg"); + execute("addallfavcatmenus"); // exec here, to add all categories (including those defined in autoexec.cfg) + initing = NOT_INITING; + + initlog("models"); + preload_playermodels(); + preload_hudguns(); + preload_entmodels(); + + initlog("docs"); + persistidents = false; + execfile("config/docs.cfg"); + persistidents = true; + + initlog("localconnect"); + extern string clientmap; + copystring(clientmap, "ac_complex"); + localconnect(); + + if(initscript) execute(initscript); + + initlog("mainloop"); + + inputgrab(grabinput = true); + + inmainloop = true; +#ifdef _DEBUG + int lastflush = 0; +#endif + for(;;) + { + static int frames = 0; + static float fps = 10.0f; + int millis = SDL_GetTicks() - clockrealbase; + if(clockfix) millis = int(millis*(double(clockerror)/1000000)); + millis += clockvirtbase; + if(milliso.x, camera1->o.y, dynfov()); + if(frames>3) { - static int frames = 0; - static float fps = 10.0f; - int millis = SDL_GetTicks() - clockrealbase; - if(clockfix) millis = int(millis*(double(clockerror)/1000000)); - millis += clockvirtbase; - if(milliso.x, camera1->o.y, dynfov()); - if(frames>3) - { - gl_drawframe(screen->w, screen->h, fpshighfps ? fps/highfps : 1.0f), fps); - if(frames>4) SDL_GL_SwapBuffers(); - } - - if(needsautoscreenshot) makeautoscreenshot(); - - #ifdef _DEBUG - if(millis>lastflush+60000) { - fflush(stdout); lastflush = millis; - } - #endif + gl_drawframe(screen->w, screen->h, fpshighfps ? fps/highfps : 1.0f), fps); + if(frames>4) SDL_GL_SwapBuffers(); } - quit(); - } + if(needsautoscreenshot) makeautoscreenshot(); + +#ifdef _DEBUG + if(millis>lastflush+60000) { + fflush(stdout); lastflush = millis; + } +#endif + } + + quit(); return EXIT_SUCCESS; #if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)