From 3016ac98a407610ee682abc183b2c2d56f2d973a Mon Sep 17 00:00:00 2001 From: driAn Date: Thu, 14 Sep 2006 19:13:37 +0000 Subject: [PATCH] spawndelay drinn, botkick on mapstart drinn, akimbo msg draussen.. git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@382 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/autoexec.cfg | 28 ++++++++++--- config/menus.cfg | 15 +++---- config/prefabs.cfg | 60 ++++++++++++++-------------- config/servers.cfg | 1 + docs/known_issues.txt | 5 +++ source/src/bot/ac_bot.cpp | 18 ++++----- source/src/bot/ac_bot.h | 2 +- source/src/bot/bot.h | 2 +- source/src/bot/bot_waypoint.cpp | 16 ++++---- source/src/bot/botmanager.cpp | 24 +++++++++--- source/src/client.cpp | 8 ++-- source/src/clientextras.cpp | 4 +- source/src/clientgame.cpp | 67 +++++++++++++++++++------------- source/src/clients2c.cpp | 48 ++++++++++------------- source/src/command.cpp | 12 +++--- source/src/console.cpp | 6 +-- source/src/cube.h | 6 ++- source/src/entities.cpp | 13 +++---- source/src/main.cpp | 10 +++-- source/src/protos.h | 1 + source/src/renderextras.cpp | 33 +++++++++++++--- source/src/rendergl.cpp | 8 ++-- source/src/savegamedemo.cpp | 6 +-- source/src/server.cpp | 26 ++++++------- source/src/serverutil.cpp | 4 +- source/src/sound.cpp | 28 ++++++++++--- source/src/tools.h | 6 +-- source/src/weapon.cpp | 4 +- source/src/world.cpp | 13 +------ source/src/worldio.cpp | 16 ++++---- source/vcpp/cube.suo | Bin 17920 -> 23552 bytes source/vcpp/cube.vcproj | 2 +- 32 files changed, 281 insertions(+), 211 deletions(-) diff --git a/config/autoexec.cfg b/config/autoexec.cfg index 66e85a9d..ca820402 100755 --- a/config/autoexec.cfg +++ b/config/autoexec.cfg @@ -10,10 +10,7 @@ sensitivityscale 10 fov 100 -alias only_menu_music 1 -alias menu_music ac.ogg - -musicvol 0 // set higher if you want (max 255) +alias maxmusicvol 120 // set higher if you want (max 255) soundvol 150 fpsrange 30 40 // *don't modify* unless you understand it fully @@ -83,7 +80,6 @@ bind R reload // bind MOUSE2 [ altattack ] bind MOUSE2 [ altattack; onrelease [ altattack ] ] // click and hold = Scope ON, release button = Scope OFF - alias delta_edit_0 [ editheight $flrceil $arg1 ] alias delta_edit_1 [ if $flrceil [ vdelta $arg1 ] [ vdelta (- 0 $arg1) ] ] alias delta_edit_2 [ edittex $flrceil $arg1 ] @@ -94,3 +90,25 @@ alias delta_edit_5 [ entproperty 0 $arg1 ] // and the others alias delta_game_0 [ if (= $arg1 1) [ shiftweapon 1 ] [ shiftweapon -1 ] ] + +music ac.ogg +musicvol $maxmusicvol + +alias fade [ // 0=in, 1=out + alias stepsize 5 + alias numsteps (div $maxmusicvol $stepsize) + loop (+ $numsteps 1) [ + alias curvol (* $i $stepsize) + if (= $arg1 1) [ alias curvol (- $maxmusicvol $curvol) ] + concat musicvol ($curvol) + sleep (* $i 100) $s + ] +] + +alias start_intermission [ + fade 0 + sleep 10000 [ fade 1 ] +] + +// play once (1:40) +sleep 100000 [ fade 1 ] \ No newline at end of file diff --git a/config/menus.cfg b/config/menus.cfg index b4b92032..59f34846 100755 --- a/config/menus.cfg +++ b/config/menus.cfg @@ -91,10 +91,12 @@ menuitem "Disconnect" "disconnect" newmenu gamemode menuitem "Team Deathmatch" "mode 0; showmenu maps" -menuitem "Team Survivor" "mode 4; showmenu maps" -menuitem "Capture the Flag" "mode 5; showmenu maps_ctf" menuitem "Deathmatch" "mode 2; showmenu maps" -menuitem "Deathmatch Arena (LMS)" "mode 3; showmenu maps" +menuitem "Team Survivor" "mode 4; showmenu maps" +menuitem "Survivor" "mode 3; showmenu maps" +menuitem "Last Swiss Standing" "mode 9; showmenu maps" +menuitem "Capture the Flag" "mode 5; showmenu maps_ctf" + // bot menus and tools @@ -159,10 +161,9 @@ alias genenemyitems [ genenemyitems "2 3 5 9 17 33" 0 - -newmenu "team enemies" - -genenemyitems "2 4 6 8 16 32" 1 +// teamplay note mature yet +//newmenu "team enemies" +//genenemyitems "2 4 6 8 16 32" 1 newmenu botmaps diff --git a/config/prefabs.cfg b/config/prefabs.cfg index 8fcbf680..3a71e764 100755 --- a/config/prefabs.cfg +++ b/config/prefabs.cfg @@ -1,30 +1,30 @@ -// this cfg defines the shapes of heightfield prefabs, i.e. arches and such - -// arch of 2xN cubes, i.e. 3 vertices [0..2] -// archvertex -// vertices not defined have a 0 delta - -alias av [ - loop $arg1 [ - at $arg2 $i - archvertex (+ $arg1 1) (+ $i 1) $s - ] -] - -av 1 "2" -av 2 "4 4" -av 3 "5 6 5" -av 4 "5 6 6 5" -av 5 "5 7 8 7 5" -av 6 "5 7 8 8 7 5" -av 7 "7 11 13 14 13 11 7" -av 8 "7 11 13 14 14 13 11 7" -av 9 "7 11 13 14 14 14 13 11 7" -av 10 "7 11 13 14 14 14 14 13 11 7" -av 11 "8 13 16 18 19 19 19 18 16 13 8" -av 12 "8 13 16 18 19 19 19 19 18 16 13 8" -av 13 "8 13 16 18 19 19 19 19 19 18 16 13 8" // these last few can be improved -av 14 "8 13 16 18 19 19 19 19 19 19 18 16 13 8" -av 15 "8 13 16 18 19 19 19 19 19 19 19 18 16 13 8" - -// add wider arches here! :) +// this cfg defines the shapes of heightfield prefabs, i.e. arches and such + +// arch of 2xN cubes, i.e. 3 vertices [0..2] +// archvertex +// vertices not defined have a 0 delta + +alias av [ + loop $arg1 [ + at $arg2 $i + archvertex (+ $arg1 1) (+ $i 1) $s + ] +] + +av 1 "2" +av 2 "4 4" +av 3 "5 6 5" +av 4 "5 6 6 5" +av 5 "5 7 8 7 5" +av 6 "5 7 8 8 7 5" +av 7 "7 11 13 14 13 11 7" +av 8 "7 11 13 14 14 13 11 7" +av 9 "7 11 13 14 14 14 13 11 7" +av 10 "7 11 13 14 14 14 14 13 11 7" +av 11 "8 13 16 18 19 19 19 18 16 13 8" +av 12 "8 13 16 18 19 19 19 19 18 16 13 8" +av 13 "8 13 16 18 19 19 19 19 19 18 16 13 8" // these last few can be improved +av 14 "8 13 16 18 19 19 19 19 19 19 18 16 13 8" +av 15 "8 13 16 18 19 19 19 19 19 19 19 18 16 13 8" + +// add wider arches here! :) \ No newline at end of file diff --git a/config/servers.cfg b/config/servers.cfg index aa8e2948..08bbd490 100755 --- a/config/servers.cfg +++ b/config/servers.cfg @@ -1,2 +1,3 @@ // servers connected to are added here automatically +addserver localhost diff --git a/docs/known_issues.txt b/docs/known_issues.txt index e69de29b..5cf162e3 100644 --- a/docs/known_issues.txt +++ b/docs/known_issues.txt @@ -0,0 +1,5 @@ +known issues: + +- the sourcecode is messed up +- bots do not use the akimbo and grenades +- demo recording is disabled \ No newline at end of file diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp index 31db5d8a..6922fc6f 100644 --- a/source/src/bot/ac_bot.cpp +++ b/source/src/bot/ac_bot.cpp @@ -135,7 +135,7 @@ void CACBot::Spawn() ResetWaypointVars(); } -void CACBot::BotPain(int damage, dynent *d) +void CACBot::BotPain(int damage, dynent *d, bool gib) { if(m_pMyEnt->state!=CS_ALIVE || editmode || intermission) return; //fixmebot @@ -153,26 +153,26 @@ void CACBot::BotPain(int damage, dynent *d) if(isteam(player1->team, m_pMyEnt->team)) { frags = -1; - conoutf("you fragged a teammate (%s)", (int)m_pMyEnt->name); + conoutf("you fragged a teammate (%s)", m_pMyEnt->name); } else { frags = 1; - conoutf("you fragged %s", (int)m_pMyEnt->name); + conoutf("you fragged %s", m_pMyEnt->name); } addmsg(1, 2, SV_FRAGS, player1->frags += frags); addmsg(1, 4, SV_BOTDIED, BotManager.GetBotIndex(m_pMyEnt), -1, false); - if(player1->gunselect==GUN_KNIFE) addgib(m_pMyEnt); + if(gib) addgib(m_pMyEnt); } else if (d->monsterstate) - conoutf("%s got killed by %s", (int)m_pMyEnt->name, (int)d->name); + conoutf("%s got killed by %s", m_pMyEnt->name, d->name); else { int KillerIndex = -1; if (d == m_pMyEnt) { - conoutf("%s suicided", (int)d->name); + conoutf("%s suicided", d->name); KillerIndex = BotManager.GetBotIndex(d); addmsg(1, 3, SV_BOTFRAGS, KillerIndex, --d->frags); } @@ -188,12 +188,12 @@ void CACBot::BotPain(int damage, dynent *d) if(isteam(m_pMyEnt->team, d->team)) { - conoutf("%s fragged his teammate (%s)", (int)d->name, - (int)m_pMyEnt->name); + conoutf("%s fragged his teammate (%s)", d->name, + m_pMyEnt->name); } else { - conoutf("%s fragged %s", (int)d->name, (int)m_pMyEnt->name); + conoutf("%s fragged %s", d->name, m_pMyEnt->name); } } addmsg(1, 4, SV_BOTDIED, BotManager.GetBotIndex(m_pMyEnt), KillerIndex, diff --git a/source/src/bot/ac_bot.h b/source/src/bot/ac_bot.h index 033f491a..6abe9e77 100644 --- a/source/src/bot/ac_bot.h +++ b/source/src/bot/ac_bot.h @@ -36,7 +36,7 @@ public: virtual bool DoSPStuff(void); virtual void Spawn(void); - virtual void BotPain(int damage, dynent *d); + virtual void BotPain(int damage, dynent *d, bool gib=false); }; inline void AddScreenText(char *t, ...) {}; // UNDONE diff --git a/source/src/bot/bot.h b/source/src/bot/bot.h index ab69db0b..feb0b1f3 100644 --- a/source/src/bot/bot.h +++ b/source/src/bot/bot.h @@ -240,7 +240,7 @@ public: virtual void CheckItemPickup(void) = 0; virtual void PickUp(int n) = 0; virtual void AddItem(int i, int &v, int spawnsec, int t) = 0; - virtual void BotPain(int damage, dynent *d) = 0; + virtual void BotPain(int damage, dynent *d, bool gib=false) = 0; void SendBotInfo(void); float GetDistance(const vec &o); float GetDistance(const vec &v1, const vec &v2); diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp index d46ddf09..9169def3 100644 --- a/source/src/bot/bot_waypoint.cpp +++ b/source/src/bot/bot_waypoint.cpp @@ -237,8 +237,8 @@ bool CWaypointClass::LoadWaypoints() } else { - conoutf("Waypoints aren't for map %s but for map %s", int(m_szMapName), - int(header.szMapName)); + conoutf("Waypoints aren't for map %s but for map %s", m_szMapName, + header.szMapName); fclose(bfp); return false; } @@ -258,7 +258,7 @@ bool CWaypointClass::LoadWaypoints() } else { - conoutf("Waypoint file %s does not exist", int(filename)); + conoutf("Waypoint file %s does not exist", (filename)); return false; } @@ -267,7 +267,7 @@ bool CWaypointClass::LoadWaypoints() ReCalcCosts(); - conoutf("Waypoints for map %s loaded", int(m_szMapName)); + conoutf("Waypoints for map %s loaded", (m_szMapName)); return true; } @@ -433,8 +433,8 @@ bool CWaypointClass::LoadWPExpFile() } else { - conoutf("Waypoint experience file isn't for map %s but for map %s", int(m_szMapName), - int(header.szMapName)); + conoutf("Waypoint experience file isn't for map %s but for map %s", (m_szMapName), + (header.szMapName)); fclose(bfp); return false; } @@ -454,11 +454,11 @@ bool CWaypointClass::LoadWPExpFile() } else { - conoutf("Waypoint experience file %s does not exist", int(filename)); + conoutf("Waypoint experience file %s does not exist", (filename)); return false; } - conoutf("Waypoint experience file for map %s loaded", int(m_szMapName)); + conoutf("Waypoint experience file for map %s loaded", (m_szMapName)); return true; } diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index f2a9af39..50aa75f8 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -173,7 +173,7 @@ void CBotManager::LoadBotNamesFile() { if (strlen(szNameBuffer) >= 16) { conoutf("Warning: bot name \"%s\" has to many characters(16 is max)", - (int)szNameBuffer); + szNameBuffer); } strn0cpy(m_szBotNames[m_sBotNameCount], szNameBuffer, 16); m_sBotNameCount++; @@ -793,7 +793,7 @@ void CBotManager::ChangeBotSkill(short Skill, dynent *bot) // Only change skill of a single bot bot->pBot->m_pBotSkill = &m_BotSkills[Skill]; bot->pBot->m_sSkillNr = Skill; - conoutf("Skill of %s is now %s", (int)bot->name, (int)SkillNames[Skill]); + conoutf("Skill of %s is now %s", bot->name, SkillNames[Skill]); return; } @@ -978,16 +978,24 @@ dynent *CBotManager::CreateBot(const char *team, const char *skill, const char * return m; } +bool botmode() +{ + if(m_botmode) return true; + conoutf("the current game mode does not support bots"); + return false; +} + // Bot manager class end void addbot(char *arg1, char *arg2, char *arg3) { + if(!botmode) return; if (ishost()) { conoutf("Creating bot...\n"); dynent *b = BotManager.CreateBot(arg1, arg2, arg3); if (b) - conoutf("connected: %s", (int)b->name); + conoutf("connected: %s", b->name); else { conoutf("Error: Couldn't create bot!"); @@ -1031,6 +1039,7 @@ COMMAND(addbot, ARG_3STR); void addnbot(char *arg1, char *arg2, char *arg3) { + if(!botmode) return; if (!arg1 || !arg1[0]) return; int i = atoi(arg1); @@ -1114,6 +1123,7 @@ COMMAND(idlebots, ARG_1INT); void drawbeamtobots() { + if(!botmode) return; loopv(bots) { if (bots[i]) @@ -1125,6 +1135,7 @@ COMMAND(drawbeamtobots, ARG_NONE); void kickbot(const char *szName) { + if(!botmode) return; if (!szName || !(*szName)) return; @@ -1182,7 +1193,7 @@ void kickallbots(void) { addmsg(1, 2, SV_BOTDIS, i); - conoutf("bot %s disconnected",(int)(bots[i]->name[0] ? + conoutf("bot %s disconnected",(bots[i]->name[0] ? bots[i]->name : "[incompatible client]")); delete bots[i]->pBot; zapdynent(bots[i]); @@ -1210,6 +1221,7 @@ COMMAND(kickallbots, ARG_NONE); void togglegrap() { + if(!botmode) return; if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GrabMode(0)) SDL_WM_GrabInput(SDL_GRAB_ON); else @@ -1219,7 +1231,8 @@ void togglegrap() COMMAND(togglegrap, ARG_NONE); void togglebotview(char *bot) -{ +{ + if(!botmode) return; if (BotManager.m_pBotToView) BotManager.DisableBotView(); else if (bot && *bot) @@ -1359,6 +1372,7 @@ COMMAND(telebot, ARG_NONE); void testvisible(int iDir) { + vec angles, end, forward, right, up; traceresult_s tr; int Dir; diff --git a/source/src/client.cpp b/source/src/client.cpp index bb459804..cf722687 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -69,11 +69,11 @@ void connects(char *servername) disconnect(1); // reset state addserver(servername); - conoutf("attempting to connect to %s", (int)servername); + conoutf("attempting to connect to %s", servername); ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT }; if(enet_address_set_host(&address, servername) < 0) { - conoutf("could not resolve server %s", (int) servername); + conoutf("could not resolve server %s", servername); return; }; @@ -144,8 +144,8 @@ void trydisconnect() }; string ctext; -void toserver(char *text) { conoutf("%s:\f %s", (int)player1->name, (int)text); strn0cpy(ctext, text, 80); }; -void echo(char *text) { conoutf("%s", (int)text); }; +void toserver(char *text) { conoutf("%s:\f %s", player1->name, text); strn0cpy(ctext, text, 80); }; +void echo(char *text) { conoutf("%s", text); }; COMMAND(echo, ARG_VARI); COMMANDN(say, toserver, ARG_VARI); diff --git a/source/src/clientextras.cpp b/source/src/clientextras.cpp index 2e11b0ef..db7872a5 100644 --- a/source/src/clientextras.cpp +++ b/source/src/clientextras.cpp @@ -121,7 +121,7 @@ void renderscore(dynent *d) sprintf_sd(lag)("%d", d->plag); sprintf_sd(name) ("(%s)", d->name); if(m_ctf) sprintf_s(scorelines.add().s)("%d\t%d\t%s\t%d\t%s\t%s", d->flagscore, d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->state==CS_DEAD ? name : d->name); - else sprintf_s(scorelines.add().s)("%d\t%s\t%d\t%s\t%s", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->state==CS_DEAD ? name : d->name); + else sprintf_s(scorelines.add().s)("%d\t%s\t%d\t%s\t%s", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, m_teammode ? d->team : "", d->state==CS_DEAD ? name : d->name); menumanual(menu, scorelines.length()-1, scorelines.last().s); }; @@ -208,7 +208,7 @@ void sendmap(char *mapname) *(ushort *)start = ENET_HOST_TO_NET_16(p-start); enet_packet_resize(packet, p-start); sendpackettoserv(packet); - conoutf("sending map %s to server...", (int)mapname); + conoutf("sending map %s to server...", mapname); sprintf_sd(msg)("[map %s uploaded to server, \"getmap\" to receive it]", mapname); toserver(msg); } diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 08c190b9..9b3c8455 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -143,11 +143,13 @@ void respawnself() void respawn() { - if(player1->state==CS_DEAD && lastmillis>player1->lastaction+5000) + if(player1->state==CS_DEAD && lastmillis>player1->lastaction+(m_teammode ? 5000 : 2000)) { player1->attacking = false; if(m_arena) { conoutf("waiting for new round to start..."); return; }; respawnself(); + weaponswitch(player1->primary); + player1->lastaction -= WEAPONCHANGE_TIME/2.0f; }; }; @@ -202,9 +204,9 @@ void arenarespawn() if(alive) { if(m_teammode) - conoutf("team %s has won the round", (int)lastteam); + conoutf("team %s has won the round", lastteam); else - conoutf("%s is the survior!", (int)lastname); + conoutf("%s is the survior!", lastname); } else conoutf("everyone died!"); arenarespawnwait = lastmillis+5000; @@ -259,17 +261,28 @@ void otherplayers() // End add }; -int sleepwait = 0; -string sleepcmd; -void scriptsleep(char *msec, char *cmd) { sleepwait = atoi(msec)+lastmillis; strcpy_s(sleepcmd, cmd); }; -COMMANDN(sleep, scriptsleep, ARG_2STR); +struct scriptsleep +{ + int wait; + string cmd; + scriptsleep(int msec, char *command) { wait = msec+lastmillis; strcpy_s(cmd, command); }; +}; + +vector sleeps; + +/*int sleepwait = 0; +string sleepcmd;*/ +//void addsleep(char *msec, char *cmd) { sleepwait = atoi(msec)+lastmillis; strcpy_s(sleepcmd, cmd); }; +void addsleep(char *msec, char *cmd) { scriptsleep s(atoi(msec), cmd); sleeps.add(s); }; +COMMANDN(sleep, addsleep, ARG_2STR); void updateworld(int millis) // main game update loop { if(lastmillis) { curtime = millis - lastmillis; - if(sleepwait && lastmillis>sleepwait) { sleepwait = 0; execute(sleepcmd); }; + //if(sleepwait && lastmillis>sleepwait) { sleepwait = 0; execute(sleepcmd); }; + loopv(sleeps) if(sleeps[i].wait && lastmillis > sleeps[i].wait) { execute(sleeps[i].cmd); sleeps.remove(i); i--; }; physicsframe(); checkakimbo(); checkweaponswitch(); @@ -303,7 +316,7 @@ void updateworld(int millis) // main game update loop else if(!intermission) { moveplayer(player1, 20, true); - checkitems(); + checkitems(); }; c2sinfo(player1); // do this last, to reduce the effective frame lag }; @@ -323,7 +336,7 @@ void entinmap(dynent *d) // brute force but effective way to find a free spaw d->o.x -= dx; d->o.y -= dy; }; - conoutf("can't find entity spawn spot! (%d, %d)", (int)d->o.x, (int)d->o.y); + conoutf("can't find entity spawn spot! (%d, %d)", d->o.x, d->o.y); // leave ent at original pos, possibly stuck }; @@ -445,7 +458,7 @@ void selfdamage(int damage, int actor, dynent *act, bool gib) { if(actor==-2) { - conoutf("you got killed by %s!", (int)&act->name); + conoutf("you got killed by %s!", &act->name); } else if(actor==-1) { @@ -466,11 +479,11 @@ void selfdamage(int damage, int actor, dynent *act, bool gib) { if(isteam(a->team, player1->team)) { - conoutf("you got fragged by a teammate (%s)", (int)a->name); + conoutf("you got fragged by a teammate (%s)", a->name); } else { - conoutf("you got fragged by %s", (int)a->name); + conoutf("you got fragged by %s", a->name); }; }; }; @@ -508,6 +521,7 @@ void timeupdate(int timeremain) conoutf("intermission:"); conoutf("game has ended!"); showscores(true); + execute("start_intermission"); } else { @@ -582,14 +596,16 @@ void preparectf(bool cleanonly=false) }; }; +extern void kickallbots(void); + void startmap(char *name) // called just after a map load { //if(netmapstart()) { gamemode = 0;}; //needs fixed to switch modes? netmapstart(); //should work //monsterclear(); // Added by Rick - if(m_botmode) BotManager.BeginMap(name); - else sleepwait = 0; + if(m_botmode) { kickallbots(); BotManager.BeginMap(name); }; +// else sleepwait = 0; // End add by Rick projreset(); if(m_ctf) preparectf(); @@ -608,21 +624,16 @@ void startmap(char *name) // called just after a map load showscores(false); intermission = false; framesinmap = 0; - conoutf("game mode is %s", (int)modestr(gamemode)); + conoutf("game mode is %s", modestr(gamemode)); }; COMMANDN(map, changemap, ARG_1STR); void suicide() { - if (multiplayer()) conoutf("there are others willing to kill you..."); - else conoutf("this is not the answer"); - selfdamage(1000, -1, player1); - //if(d==player1) selfdamage(dm, -1, d); - //else { addmsg(1, 4, SV_DAMAGE, d, dm, d->lifesequence); playsound(S_FALL1+rnd(5), &d->o); }; - //particle_splash(3, 1000, 1000, player1->o); //edit out? - demodamage(1000, player1->o); - //playsound(S_SUICIDE, &player1->o); // fixme sound + if(player1->state==CS_DEAD) return; + selfdamage(1000, -1, player1); + demodamage(1000, player1->o); }; COMMAND(suicide, ARG_NONE); @@ -648,21 +659,21 @@ void flagaction(int flag, int action) conoutf("you got the enemy flag"); f.pick_ack = true; } - else conoutf("%s got %s flag", (int) f.thief->name, (int)(ownflag ? "your": "the enemy")); + else conoutf("%s got %s flag", f.thief->name, (ownflag ? "your": "the enemy")); break; }; case SV_FLAGDROP: { playsound(S_FLAGDROP); if(f.thief==player1) conoutf("you lost the flag"); - else conoutf("%s lost %s flag", (int) f.thief->name, (int)(ownflag ? "your" : "the enemy")); + else conoutf("%s lost %s flag", f.thief->name, (ownflag ? "your" : "the enemy")); break; }; case SV_FLAGRETURN: { playsound(S_FLAGRETURN); if(f.thief==player1) conoutf("you returned your flag"); - else conoutf("%s returned %s flag", (int) f.thief->name, (int)(ownflag ? "your" : "the enemy")); + else conoutf("%s returned %s flag", f.thief->name, (ownflag ? "your" : "the enemy")); break; }; case SV_FLAGSCORE: @@ -673,7 +684,7 @@ void flagaction(int flag, int action) conoutf("you scored"); addmsg(1, 2, SV_FLAGS, ++player1->flagscore); } - else conoutf("%s scored for %s team", (int) f.thief->name, (int)(ownflag ? "the enemy" : "your")); + else conoutf("%s scored for %s team", f.thief->name, (ownflag ? "the enemy" : "your")); break; }; default: break; diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index a7bce534..09f4eee2 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -9,7 +9,7 @@ extern string clientpassword; void neterr(char *s) { - conoutf("illegal network message (%s)", (int)s); + conoutf("illegal network message (%s)", s); disconnect(); }; @@ -148,7 +148,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th case SV_TEXT: sgetstr(); - conoutf("%s:\f %s", (int)d->name, (int)&text); + conoutf("%s:\f %s", d->name, &text); break; case SV_MAPCHANGE: @@ -180,12 +180,12 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if(d->name[0]) // already connected { if(strcmp(d->name, text)) - conoutf("%s is now known as %s", (int)d->name, (int)&text); + conoutf("%s is now known as %s", d->name, &text); } else // new client { c2sinit = false; // send new players my info again - conoutf("connected: %s", (int)&text); + conoutf("connected: %s", &text); gun_changed = true; // Added by Rick: If we are the host("the bot owner"), tell the bots // to update their stats @@ -199,14 +199,13 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th d->skin = getint(p); d->lifesequence = getint(p); c2si = true; - printf("SV_INITC2S\n"); break; }; case SV_CDIS: cn = getint(p); if(!(d = getclient(cn))) break; - conoutf("player %s disconnected", (int)(d->name[0] ? d->name : "[incompatible client]")); + conoutf("player %s disconnected", (d->name[0] ? d->name : "[incompatible client]")); zapdynent(players[cn]); break; @@ -221,7 +220,6 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th e.y = getint(p)/DMF; e.z = getint(p)/DMF; if(gun==GUN_SHOTGUN) createrays(s, e); - printf("shot\n"); shootv(gun, s, e, d, false, getint(p)); break; }; @@ -232,7 +230,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th int target = getint(p); int damage = getint(p); int ls = getint(p); - if(target==clientnum) { if(ls==player1->lifesequence) selfdamage(damage, cn, d, gib); else printf("wrong lifesequence\n"); } + if(target==clientnum) { if(ls==player1->lifesequence) selfdamage(damage, cn, d, gib); } else playsound(S_PAIN1+rnd(5), &getclient(target)->o); gib = false; break; @@ -267,7 +265,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if(actor==cn && !killedbybot) { - conoutf("%s suicided", (int)d->name); + conoutf("%s suicided", d->name); } else if(actor==clientnum && !killedbybot) { @@ -275,12 +273,12 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if(isteam(player1->team, d->team)) { frags = -1; - conoutf("you fragged a teammate (%s)", (int)d->name); + conoutf("you fragged a teammate (%s)", d->name); } else { frags = 1; - conoutf("you fragged %s", (int)d->name); + conoutf("you fragged %s", d->name); }; addmsg(1, 2, SV_FRAGS, player1->frags += frags); if(gib) addgib(d); @@ -292,11 +290,11 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th { if(isteam(a->team, d->name)) { - conoutf("%s fragged his teammate (%s)", (int)a->name, (int)d->name); + conoutf("%s fragged his teammate (%s)", a->name, d->name); } else { - conoutf("%s fragged %s", (int)a->name, (int)d->name); + conoutf("%s fragged %s", a->name, d->name); }; if(gib) addgib(d); }; @@ -396,7 +394,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th case SV_RECVMAP: { sgetstr(); - conoutf("received map \"%s\" from server, reloading..", (int)&text); + conoutf("received map \"%s\" from server, reloading..", &text); int mapsize = getint(p); writemap(text, mapsize, p); p += mapsize; @@ -412,7 +410,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th case SV_SERVMSG: sgetstr(); - conoutf("%s", (int)text); + conoutf("%s", text); break; // EDIT: AH @@ -428,11 +426,9 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th int thief_cn = getint(p); f.thief = thief_cn == getclientnum() ? player1 : getclient(thief_cn); f.flag->spawned = false; - printf("cl_sstolen by %i\n", thief_cn); } else if(f.state==CTFF_DROPPED) { - printf("cl_dropped\n"); f.flag->x = (ushort) (getint(p)/DMF); f.flag->y = (ushort) (getint(p)/DMF); f.flag->z = (ushort) (getint(p)/DMF); @@ -449,12 +445,10 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th } else if(f.state==CTFF_INBASE) { - printf("cl_inbase\n"); if(action==SV_FLAGRETURN) { int returnerer_cn = getint(p); f.thief = returnerer_cn == getclientnum() ? player1 : getclient(returnerer_cn); - printf("\tcl_return\n"); } f.flag->x = (ushort) f.originalpos.x; f.flag->y = (ushort) f.originalpos.y; @@ -515,12 +509,12 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if(b->name[0]) // already connected { if(strcmp(b->name, text)) - conoutf("%s is now known as %s", (int)b->name, (int)&text); + conoutf("%s is now known as %s", b->name, &text); } else // new client { //c2sinit = false; // send new players my info again - conoutf("connected: %s", (int)&text); + conoutf("connected: %s", &text); }; strcpy_s(b->name, text); sgetstr(); @@ -539,7 +533,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if (!b) break; - conoutf("bot %s disconnected", (int)(b->name[0] ? b->name : "[incompatible client]")); + conoutf("bot %s disconnected", b->name[0] ? b->name : "[incompatible client]"); delete b->pBot; zapdynent(bots[n]); bots.remove(n); @@ -586,7 +580,7 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if((b==killer) && KilledByABot) { - conoutf("%s suicided", (int)bot->name); + conoutf("%s suicided", bot->name); } else if((killer==clientnum) && !KilledByABot) { @@ -594,12 +588,12 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th if(isteam(player1->team, bot->team)) { frags = -1; - conoutf("you fragged a teammate (%s)", (int)bot->name); + conoutf("you fragged a teammate (%s)", bot->name); } else { frags = 1; - conoutf("you fragged %s", (int)bot->name); + conoutf("you fragged %s", bot->name); }; addmsg(1, 2, SV_FRAGS, player1->frags += frags); if(player1->gunselect==GUN_KNIFE) @@ -620,11 +614,11 @@ void localservertoclient(uchar *buf, int len) // processes any updates from th { if(isteam(bot->team, k->name)) { - conoutf("%s fragged his teammate (%s)", (int)bot->name, (int)k->name); + conoutf("%s fragged his teammate (%s)", bot->name, k->name); } else { - conoutf("%s fragged %s", (int)bot->name, (int)k->name); + conoutf("%s fragged %s", bot->name, k->name); } if(k->gunselect==GUN_KNIFE) addgib(bot); } diff --git a/source/src/command.cpp b/source/src/command.cpp index ea3960ef..fb1f6744 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -34,7 +34,7 @@ void alias(char *name, char *action) else { if(b->type==ID_ALIAS) b->action = exchangestr(b->action, action); - else conoutf("cannot redefine builtin %s with an alias", (int)name); + else conoutf("cannot redefine builtin %s with an alias", name); }; }; @@ -118,7 +118,7 @@ char *lookup(char *n) // find value of ident reference case ID_VAR: string t; itoa(t, *(id->storage)); return exchangestr(n, t); case ID_ALIAS: return exchangestr(n, id->action); }; - conoutf("unknown alias lookup: %s", (int)n+1); + conoutf("unknown alias lookup: %s", n+1); return n; }; @@ -150,7 +150,7 @@ int execute(char *p, bool isdown) // all evaluation happens here, if(!id) { val = ATOI(c); - if(!val && *c!='0') conoutf("unknown command: %s", (int)c); + if(!val && *c!='0') conoutf("unknown command: %s", c); } else switch(id->type) { @@ -192,7 +192,7 @@ int execute(char *p, bool isdown) // all evaluation happens here, case ID_VAR: // game defined variabled if(isdown) { - if(!w[1][0]) conoutf("%s = %d", (int)c, *id->storage); // var with no value just prints its current value + if(!w[1][0]) conoutf("%s = %d", c, *id->storage); // var with no value just prints its current value else { if(id->min>id->max) @@ -205,7 +205,7 @@ int execute(char *p, bool isdown) // all evaluation happens here, if(i1min || i1>id->max) { i1 = i1min ? id->min : id->max; // clamp to valid range - conoutf("valid range for %s is %d..%d", (int)c, id->min, id->max); + conoutf("valid range for %s is %d..%d", c, id->min, id->max); } *id->storage = i1; }; @@ -272,7 +272,7 @@ bool execfile(char *cfgfile) void exec(char *cfgfile) { - if(!execfile(cfgfile)) conoutf("could not read \"%s\"", (int)cfgfile); + if(!execfile(cfgfile)) conoutf("could not read \"%s\"", cfgfile); }; // below the commands that implement a small imperative language. thanks to the semantics of diff --git a/source/src/console.cpp b/source/src/console.cpp index 461458e5..7c78beef 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -40,9 +40,9 @@ void conline(const char *sf, bool highlight) // add a line to the console puts(cl.cref); }; -void conoutf(const char *s, int a, int b, int c) +void conoutf(const char *s, ...) { - sprintf_sd(sf)(s, a, b, c); + sprintf_sdv(sf, s); s = sf; int n = 0; while(strlen(s)>WORDWRAP) // cut strings to fit on screen @@ -92,7 +92,7 @@ void bindkey(char *key, char *action) strcpy_s(keyms[i].action, action); return; }; - conoutf("unknown key \"%s\"", (int)key); + conoutf("unknown key \"%s\"", key); }; COMMANDN(bind, bindkey, ARG_2STR); diff --git a/source/src/cube.h b/source/src/cube.h index afeec09c..d8f0f6b2 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -406,16 +406,18 @@ extern bool demoplayback; 6 - pistols 7 - bot dm 8 - bot tdm +9 - last swiss standing */ #define m_noitems (m_arena) #define m_noitemsrail (false) -#define m_arena (gamemode==3 || gamemode==4) +#define m_arena (gamemode==3 || gamemode==4 || gamemode==9) #define m_tarena (gamemode==4) #define m_teammode (gamemode==0 || gamemode==4 || gamemode==5 || gamemode==7) #define m_botmode (gamemode==7 || gamemode == 8) #define m_ctf (gamemode==5) #define m_pistol (gamemode==6) +#define m_lss (gamemode==9) //#define m_sp (gamemode<0) //#define m_dmsp (gamemode==-1) //#define m_classicsp (gamemode==-2) @@ -483,7 +485,7 @@ inline bool ishost(void) { return !clienthost; }; void splaysound(int n, vec *loc=0); void addteamscore(dynent *d); void renderscore(dynent *d); -extern void conoutf(const char *s, int a = 0, int b = 0, int c = 0); // Moved from protos.h +extern void conoutf(const char *s, ...); // Moved from protos.h extern void particle_trail(int type, int fade, vec &from, vec &to); // Moved from protos.h extern bool listenserv; extern bool intermission; diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 47d8ba01..90eb330c 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -137,7 +137,6 @@ void realpickup(int n, dynent *d) d->mag[GUN_PISTOL] = 16; radditem(n, d->ammo[1], 9); weaponswitch(GUN_PISTOL); - if(d==player1) conoutf("a lesser man would use a single pistol"); break; }; }; @@ -266,6 +265,11 @@ void radd(dynent *d) d->primary = GUN_PISTOL; d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].max; } + if(m_lss) + { + d->mag[d->primary] = d->mag[GUN_PISTOL] = 0; + d->primary = GUN_KNIFE; + } else { d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].start-magsize(GUN_PISTOL); @@ -293,13 +297,6 @@ void item(int num) COMMAND(item,ARG_1INT); -void akimbo() -{ - conoutf("akimbo=%d",player1->akimbo); -}; - -COMMAND(akimbo, ARG_NONE); - // Added by Rick bool intersect(entity *e, vec &from, vec &to, vec *end) // if lineseg hits entity bounding box(entity version) { diff --git a/source/src/main.cpp b/source/src/main.cpp index 064ee08e..0e278d67 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -165,7 +165,7 @@ int main(int argc, char **argv) !installtex(6, path(newstring("packages/textures/makke/menu.jpg")), xs, ys, false, true) || !installtex(4, path(newstring("packages/misc/explosion.jpg")), xs, ys) || !installtex(5, path(newstring("packages/misc/items.png")), xs, ys) || - !installtex(9, path(newstring("packages/misc/teammate.png")), xs, ys) || + !installtex(9, path(newstring("packages/misc/teammate.png")), xs, ys) || !installtex(10, path(newstring("packages/misc/scope.png")), xs, ys) || !installtex(11, path(newstring("packages/misc/flag_icons.png")), xs, ys) || !installtex(1, path(newstring("packages/misc/crosshairs/default.png")), xs, ys)) fatal("could not find core textures (hint: run cube from the parent of the bin directory)"); @@ -180,13 +180,11 @@ int main(int argc, char **argv) newmenu("ping\tplr\tserver"); newmenu("flags\tfrags\tpj\tping\tteam\tname"); exec("config/keymap.cfg"); - //exec("data/models.cfg"); exec("config/menus.cfg"); exec("config/prefabs.cfg"); exec("config/sounds.cfg"); exec("config/servers.cfg"); exec("config/autoexec.cfg"); - //exec("config/default_map_settings.cfg"); log("base models"); loadweapons(); @@ -249,7 +247,11 @@ int main(int argc, char **argv) break; }; }; - if(millis>lastflush+60000) { fflush(stdout); lastflush = millis; } +#ifdef _DEBUG + if(millis>lastflush+60000) { + fflush(stdout); lastflush = millis; + } +#endif }; quit(); return 1; diff --git a/source/src/protos.h b/source/src/protos.h index 1bf35e03..66920a24 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -212,6 +212,7 @@ extern void playsoundc(int n); extern void initsound(); extern void cleansound(); extern void botplaysound(int n, dynent *b); // Added by Rick +extern void music(char *name); // rendermd2 extern void rendermodel(char *mdl, int frame, int range, int tex, float rad, float x, float y, float z, float yaw, float pitch, bool teammate, float scale, float speed, int snap = 0, int basetime = 0, bool oculling=true, dynent *d=NULL); diff --git a/source/src/renderextras.cpp b/source/src/renderextras.cpp index 901521ca..8e585a47 100644 --- a/source/src/renderextras.cpp +++ b/source/src/renderextras.cpp @@ -618,18 +618,34 @@ void renderphysents() }; }; -VAR(numgibs, 0, 6, 100); +VAR(gibnum, 0, 6, 1000); +VAR(gibttl, 0, 0, 15000); +VAR(gibspeed, 1, 7, 20); + +int numlivingenemies() +{ + int num = 0; + loopv(players) if(!isteam(players[i]->team, player1->team)) num++; + loopv(bots) if(!isteam(bots[i]->team, player1->team)) num++; + return num; +} void addgib(dynent *d) { if(!d) return; playsound(S_GIB, &d->o); - loopi(numgibs) + + bool massivegib = gamemode == 9 && numlivingenemies() == 1; + + loopi((massivegib ? 1000 : gibnum)) { physent *p = new_physent(); p->owner = d; p->millis = lastmillis; - p->timetolife = 5000+rnd(10)*100; + if(massivegib) p->timetolife = 15000; + else if(gibttl>0) p->timetolife = gibttl; + else p->timetolife = 5000+rnd(10)*100; + p->state = GIB; p->isphysent = true; @@ -639,9 +655,14 @@ void addgib(dynent *d) p->o = d->o; p->o.z -= d->aboveeye; - p->vel.z = 0.3f + rnd(30)/100.0f; - p->vel.x = -0.2f + rnd(50)/100.0f; - p->vel.y = -0.2f + rnd(50)/100.0f; + + float gibvelangle = rnd(360); + float speed = massivegib ? 20 : gibspeed; + p->vel.x = sin(gibvelangle)*speed*rnd(1000)/1000.0f; + p->vel.y = cos(gibvelangle)*speed*rnd(1000)/1000.0f; + p->vel.z = speed*rnd(1000)/1000.0f; + vdiv(p->vel, 10.0f); + p->yaw = (float)rnd(360); p->pitch = (float)rnd(360); p->rotspeed = 3.0f; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index d47b8218..465bdc98 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -70,8 +70,8 @@ void cleangl() bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp, bool highqual) { SDL_Surface *s = IMG_Load(texname); - if(!s) { conoutf("couldn't load texture %s", (int)texname); return false; }; - if(s->format->BitsPerPixel!=24 && s->format->BitsPerPixel!=32) { conoutf("texture must be 24bpp or 32bpp: %s", (int)texname); return false; }; + if(!s) { conoutf("couldn't load texture %s", texname); return false; }; + if(s->format->BitsPerPixel!=24 && s->format->BitsPerPixel!=32) { conoutf("texture must be 24bpp or 32bpp: %s", texname); return false; }; // loopi(s->w*s->h*3) { uchar *p = (uchar *)s->pixels+i; *p = 255-*p; }; glBindTexture(GL_TEXTURE_2D, tnum); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -86,7 +86,7 @@ bool installtex(int tnum, char *texname, int &xs, int &ys, bool clamp, bool high void *scaledimg = s->pixels; if(xs!=s->w) { - conoutf("warning: quality loss: scaling %s", (int)texname); // for voodoo cards under linux + conoutf("warning: quality loss: scaling %s", texname); // for voodoo cards under linux scaledimg = alloc(xs*ys*3); gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, xs, ys, GL_UNSIGNED_BYTE, scaledimg); }; @@ -239,7 +239,7 @@ VARF(gamma, 30, 100, 300, if(SDL_SetGamma(f,f,f)==-1) { conoutf("Could not set gamma (card/driver doesn't support it?)"); - conoutf("sdl: %s", (int)SDL_GetError()); + conoutf("sdl: %s", SDL_GetError()); }; }); diff --git a/source/src/savegamedemo.cpp b/source/src/savegamedemo.cpp index 77204647..4e1489fc 100644 --- a/source/src/savegamedemo.cpp +++ b/source/src/savegamedemo.cpp @@ -52,7 +52,7 @@ void savestate(char *fn) { stop(); f = gzopen(fn, "wb9"); - if(!f) { conoutf("could not write %s", (int)fn); return; }; + if(!f) { conoutf("could not write %s", fn); return; }; gzwrite(f, (void *)"CUBESAVE", 8); gzputc(f, islittleendian); gzputi(SAVEGAMEVERSION); @@ -81,7 +81,7 @@ void loadstate(char *fn) stop(); if(multiplayer()) return; f = gzopen(fn, "rb9"); - if(!f) { conoutf("could not open %s", (int)fn); return; }; + if(!f) { conoutf("could not open %s", fn); return; }; string buf; gzread(f, buf, 8); @@ -151,7 +151,7 @@ void record(char *name) sprintf_sd(fn)("demos/%s.cdgz", name); savestate(fn); gzputi(cn); - conoutf("started recording demo to %s", (int)fn); + conoutf("started recording demo to %s", fn); demorecording = true; starttime = lastmillis; ddamage = bdamage = 0; diff --git a/source/src/server.cpp b/source/src/server.cpp index b3adb410..3d4f8789 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -122,9 +122,9 @@ void sendflaginfo(int flag, int action, int cn = -1) uchar *start = packet->data; uchar *p = start+2; putint(p, SV_FLAGINFO); - putint(p, flag); printf("senflaginfo flag: %i\n", flag); - putint(p, f.state); printf("senflaginfo state: %i\n", f.state); - putint(p, action); printf("senflaginfo action: %i\n", action); + putint(p, flag); + putint(p, f.state); + putint(p, action); if(f.state==CTFF_STOLEN || action==SV_FLAGRETURN) putint(p, f.thief_cn); else if(f.state==CTFF_DROPPED) loopi(3) putint(p, f.pos[i]); *(ushort *)start = ENET_HOST_TO_NET_16(p-start); @@ -250,8 +250,6 @@ void nextcfgset() // load next maprotation set curcfgset++; if(curcfgset>=configsets.length() || curcfgset<0) curcfgset=0; - printf("nextcfgset: %i\n", curcfgset); - configset &c = configsets[curcfgset]; mode = c.mode; minremain = c.time; @@ -555,9 +553,7 @@ void process(ENetPacket * packet, int sender) // sender may be -1 sgetstr(); int reqmode = getint(p); if(reqmode<0) reqmode = 0; - printf("SV_MAPCHANGE %i %s", reqmode, text); if(smapname[0] && !mapreload && !vote(text, reqmode, sender)) return; - printf(" - accepted\n"); mapreload = false; mode = reqmode; minremain = m_ctf_s ? 10 : (mode&1 ? 15 : 10); @@ -654,7 +650,6 @@ void process(ENetPacket * packet, int sender) // sender may be -1 f.state = CTFF_STOLEN; f.thief_cn = sender; sendflaginfo(flag, SV_FLAGPICKUP); - printf("srv_flagpickup\n"); }; break; }; @@ -670,7 +665,6 @@ void process(ENetPacket * packet, int sender) // sender may be -1 f.lastupdate = lastsec; loopi(3) f.pos[i] = tmp_pos[i]; sendflaginfo(flag, SV_FLAGDROP); - printf("srv_flagdrop\n"); }; break; }; @@ -685,7 +679,6 @@ void process(ENetPacket * packet, int sender) // sender may be -1 f.state = CTFF_INBASE; f.thief_cn = sender; sendflaginfo(flag, SV_FLAGRETURN); - printf("srv_flagsreturn\n"); }; break; }; @@ -700,7 +693,6 @@ void process(ENetPacket * packet, int sender) // sender may be -1 f.state = CTFF_INBASE; f.thief_cn = sender; sendflaginfo(flag, SV_FLAGSCORE); - printf("srv_flagscore\n"); }; break; }; @@ -850,7 +842,6 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal else loopv(clients) if(clients[i].type!=ST_EMPTY) { send2(true, i, SV_MAPRELOAD, 0); // ask a client to trigger map reload - printf("SV_MAPRELOAD\n"); //fixme mapreload = true; break; }; @@ -874,7 +865,13 @@ void serverslice(int seconds, unsigned int timeout) // main server update, cal nonlocalclients = 0; loopv(clients) if(clients[i].type==ST_TCPIP) nonlocalclients++; laststatus = seconds; - if(nonlocalclients || bsend || brec) { printf("status: %d remote clients, %.1f send, %.1f rec (K/sec)\n", nonlocalclients, bsend/60.0f/1024, brec/60.0f/1024); fflush(stdout); } + if(nonlocalclients || bsend || brec) + { + printf("status: %d remote clients, %.1f send, %.1f rec (K/sec)\n", nonlocalclients, bsend/60.0f/1024, brec/60.0f/1024); +#ifdef _DEBUG + fflush(stdout); +#endif + } bsend = brec = 0; }; @@ -948,7 +945,8 @@ void initserver(bool dedicated, int uprate, char *sdesc, char *ip, char *master, serverhost = enet_host_create(&address, MAXCLIENTS, 0, uprate); if(!serverhost) fatal("could not create server host\n"); loopi(MAXCLIENTS) serverhost->peers[i].data = (void *)-1; - if(maprot) readscfg(maprot); // EDIT: AH + if(!maprot) maprot = newstring("config/maprot.cfg"); + readscfg(maprot); // EDIT: AH }; resetserverifempty(); diff --git a/source/src/serverutil.cpp b/source/src/serverutil.cpp index a4a90298..fbbc04e7 100644 --- a/source/src/serverutil.cpp +++ b/source/src/serverutil.cpp @@ -29,11 +29,11 @@ void sendstring(char *t, uchar *&p) const char *modenames[] = { "team deathmatch", "coopedit", "deathmatch", "survior", - "team survior", "ctf", "pistols only!", "bot team deathmatch", "bot deathmatch" + "team survior", "ctf", "pistols only!", "bot team deathmatch", "bot deathmatch", "last swiss standing", }; //const char *modestr(int n) { return (n>=-2 && n<12) ? modenames[n+2] : "unknown"; }; -const char *modestr(int n) { return (n>=0 && n<=8) ? modenames[n] : "unknown"; }; +const char *modestr(int n) { return (n>=0 && n<=9) ? modenames[n] : "unknown"; }; /* Modified by Rick: New messages and different sizes for existing ones char msgsizesl[] = // size inclusive message token, 0 for variable or not-checked sizes diff --git a/source/src/sound.cpp b/source/src/sound.cpp index 2cd513d9..a28cea78 100644 --- a/source/src/sound.cpp +++ b/source/src/sound.cpp @@ -7,7 +7,6 @@ //#endif VARP(soundvol, 0, 255, 255); -VARP(musicvol, 0, 128, 255); bool nosound = false; #define MAXCHAN 32 @@ -27,6 +26,23 @@ struct soundloc { vec loc; bool inuse; } soundlocs[MAXCHAN]; FSOUND_STREAM *stream = NULL; #endif +int musicvol = 125; + +void setmusicvol(int vol) +{ + if(musicvol > 255 || musicvol < 0) return; + musicvol = vol; + if(nosound) return; + #ifdef USE_MIXER + if(mod) Mix_VolumeMusic((musicvol*MAXVOL)/255); + #else + if(mod) FMUSIC_SetMasterVolume(mod, musicvol); + else if(stream && musicchan>=0) FSOUND_SetVolume(musicchan, (musicvol*MAXVOL)/255); + #endif +} + +COMMANDN(musicvol, setmusicvol, ARG_1INT); + void stopsound() { if(nosound) return; @@ -78,14 +94,14 @@ void music(char *name) if(soundvol && musicvol) { string sn; - strcpy_s(sn, "packages/"); + strcpy_s(sn, "packages/audio/songs/"); strcat_s(sn, name); #ifdef USE_MIXER if(mod = Mix_LoadMUS(path(sn))) { Mix_PlayMusic(mod, -1); Mix_VolumeMusic((musicvol*MAXVOL)/255); - }; + } #else if(mod = FMUSIC_LoadSong(path(sn))) { @@ -97,16 +113,18 @@ void music(char *name) int chan = FSOUND_Stream_Play(FSOUND_FREE, stream); if(chan>=0) { FSOUND_SetVolume(chan, (musicvol*MAXVOL)/255); FSOUND_SetPaused(chan, false); }; } + #endif else { conoutf("could not play music: %s", sn); }; - #endif + }; }; COMMAND(music, ARG_1STR); + #ifdef USE_MIXER vector samples; #else @@ -215,7 +233,7 @@ void playsound(int n, vec *loc) samples[n] = FSOUND_Sample_Load(n, path(buf), FSOUND_LOOP_OFF, 0, 0); #endif - if(!samples[n]) { conoutf("failed to load sample: %s", (int)buf); return; }; + if(!samples[n]) { conoutf("failed to load sample: %s", buf); return; }; }; #ifdef USE_MIXER diff --git a/source/src/tools.h b/source/src/tools.h index 5ca68bdf..f9a57b54 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -182,11 +182,7 @@ template struct vector bool empty() { return ulen==0; }; int length() { return ulen; }; - T &operator[](int i) - { - if(i<0||i>ulen){ fatal("fuck"); }; - /*assert(i>=0 && i=0 && ii; ulen--) buf[ulen-1].~T(); }; T *getbuf() { return buf; }; diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 4db0fffb..704d7eed 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -83,7 +83,7 @@ COMMAND(shiftweapon, ARG_1INT); void altattack() { - if(player1->gunselect == GUN_SNIPER) togglescope(); + if(player1->gunselect == GUN_SNIPER && player1->state!=CS_DEAD) togglescope(); } COMMAND(altattack, ARG_NONE); @@ -231,7 +231,7 @@ void hit(int target, int damage, dynent *d, dynent *at, bool gib=false) if(d==player1) selfdamage(damage, at==player1 ? -1 : -2, at, gib); //else if(d->monsterstate) monsterpain(d, damage, at); // Added by Rick: Let bots take damage - else if(d->pBot) d->pBot->BotPain(damage, at); + else if(d->pBot) d->pBot->BotPain(damage, at, gib); else if(d->bIsBot) { int PlayerIndex = -1; diff --git a/source/src/world.cpp b/source/src/world.cpp index 376320ff..8c9de858 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -204,7 +204,7 @@ void delent() int e = closestent(); if(e<0) { conoutf("no more entities"); return; }; int t = ents[e].type; - conoutf("%s entity deleted", (int)entnames[t]); + conoutf("%s entity deleted", entnames[t]); ents[e].type = NOTUSED; addmsg(1, 10, SV_EDITENT, e, NOTUSED, 0, 0, 0, 0, 0, 0, 0); if(t==LIGHT) calclight(); @@ -213,7 +213,7 @@ void delent() int findtype(char *what) { loopi(MAXENTTYPES) if(strcmp(what, entnames[i])==0) return i; - conoutf("unknown entity type \"%s\"", (int)what); + conoutf("unknown entity type \"%s\"", what); return NOTUSED; } @@ -245,15 +245,6 @@ entity *newentity(int x, int y, int z, char *what, int v1, int v2, int v3, int v return &ents.last(); }; -void mdlcheck() -{ - loopv(ents) - { - entity &e = ents[i]; - printf("%i %i %i %i %i\n", e.type, e.attr1, e.attr2, e.attr3, e.attr4); - } -}; COMMAND(mdlcheck, ARG_NONE); - void clearents(char *name) { int type = findtype(name); diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 05450e08..e1e33140 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -107,17 +107,17 @@ void writemap(char *mname, int msize, uchar *mdata) setnames(mname); backup(cgzname, bakname); FILE *f = fopen(cgzname, "wb"); - if(!f) { conoutf("could not write map to %s", (int)cgzname); return; }; + if(!f) { conoutf("could not write map to %s", cgzname); return; }; fwrite(mdata, 1, msize, f); fclose(f); - conoutf("wrote map %s as file %s", (int)mname, (int)cgzname); + conoutf("wrote map %s as file %s", mname, cgzname); } uchar *readmap(char *mname, int *msize) { setnames(mname); uchar *mdata = (uchar *)loadfile(cgzname, msize); - if(!mdata) { conoutf("could not read map %s", (int)cgzname); return NULL; }; + if(!mdata) { conoutf("could not read map %s", cgzname); return NULL; }; return mdata; } @@ -134,7 +134,7 @@ void save_world(char *mname) setnames(mname); backup(cgzname, bakname); gzFile f = gzopen(cgzname, "wb9"); - if(!f) { conoutf("could not write map to %s", (int)cgzname); return; }; + if(!f) { conoutf("could not write map to %s", cgzname); return; }; hdr.version = MAPVERSION; hdr.numents = 0; loopv(ents) if(ents[i].type!=NOTUSED) hdr.numents++; @@ -202,7 +202,7 @@ void save_world(char *mname) }; spurge; gzclose(f); - conoutf("wrote map file %s", (int)cgzname); + conoutf("wrote map file %s", cgzname); settagareas(); }; @@ -217,7 +217,7 @@ void load_world(char *mname) // still supports all map formats that have pruneundos(); setnames(mname); gzFile f = gzopen(cgzname, "rb9"); - if(!f) { conoutf("could not read map %s", (int)cgzname); return; }; + if(!f) { conoutf("could not read map %s", cgzname); return; }; loadingscreen(); gzread(f, &hdr, sizeof(header)-sizeof(int)*16); endianswap(&hdr.version, sizeof(int), 4); @@ -351,8 +351,8 @@ void load_world(char *mname) // still supports all map formats that have gzclose(f); calclight(); settagareas(); - conoutf("read map %s (%d milliseconds)", (int)cgzname, SDL_GetTicks()-lastmillis); - conoutf("%s", (int)hdr.maptitle); + conoutf("read map %s (%d milliseconds)", cgzname, SDL_GetTicks()-lastmillis); + conoutf("%s", hdr.maptitle); startmap(mname); loopl(256) { diff --git a/source/vcpp/cube.suo b/source/vcpp/cube.suo index d2ace8e9b84792e8a9807197f0b6acda099723ed..c4ecda7c226a0cd2b13c8c0a8e7641dce31c5a94 100644 GIT binary patch delta 2969 zcmeHJTTGlq6h8Cw!?K0tvRrmSF3VCVcb4U{EX8suCe_%aTkMlW3cHkxTw0)j6k8gv zjr4&%HEPl{7!yrwRNCJ}Ya6^I)|k|o)(7i@#+sNuG^r0hp%MJ%hrP(I#KhOmpKs@! znKN_doH^&r&M%1hkHzwwlCieFzFt5?=u8I$})$IKW zpUZ0Eh1|T{Msnb@Q6&vfLy(@-M||2>xmN_w<|Oib{!soD_0T8{(lEXr^3rkYr9OHd zn%)2^^aEKzRRYO62ZGXpOr3ia)Kh?6=W0Ri16(@yEGPzwC0BMvA$lKZ!-#C(T&y$y zw({OjAa?)()kJUcE!%yQ^vg7`0CecvU4hj1K$+xX_6g!U`T3k@KaiS4<2dvv`S2@m zg7}oZjeoJ{6-WktrD+<&%rGQ2+79Z6xg*raH&d&%szSer?S&$I{QWh5Ir=X~1c64^Ik(jo-_*#i9$YN9Th zf>AESO)tVhhK3J(7u90Kg-_0V@#}?0Cm|!}1KgtLb+LBI(=W2Rux30=u8(HmtSa&% z_|v$xCDAwly*}t8zPYE9m)j~la+i$&?8fRb&~k@9>L#Zi#r2>Z)Tr}r=nQC>z+Fy3 zPKJ|=n|Fa5(j@&lpN75jfF6d{s~DEIBP)e$fiUFTr4uaV|K^5P~(_4^z~zQGT* zHO|_)dW4{bg5Jp4ZX<=Vu@RTp5@Y&lIN-|Ak#i##^VRYde$_n`63UAr3)YRWZTY2Vg9{t1#g*5A{0jHGy4_|MNt;H8m=4VGtiB^9^(t{o{$@g zBgMnrQ0A}y)YOea+k_~&Au4u_ibH<^KfYybcN delta 2459 zcmbuATToL+7{_;yhlBv(78JY$PGVJ3!u`@HBGC~`AM8Lc)M*)mKr|>2C9zVVB-&Pc zp;h^)_F^y6yO)Zd7oB#HI-O3ZQ)gPHFMVj=oW68g`$(rl`rmUBAjZ*l+{|xw_uFsx ze7D_%FZ1vSpBR#8$dF7w8J!o~n)s;Po$hYPJ=t*m8@`A!=60$B@-;5cMj{b%8*=zM zdfaftW}| zUS3MC%i3Y`F7jJTt>vtOxmX!fSTXala*Qfil{O19Mg78hg;Tg-H!0~$tnJJXZ(Ff> zVedf{`d9~TsLM_D!uud*J6M2@Zd^*!1$o$+X}S!9zX#Qt3nD6S3Twq|St;aO09p#@ zfMxBlkTDBQD}Qj^>l>ISLCGw(Wc-Dh0kdrMXk;s@r0)t-XuZ86YX!XU!T{lAA53ed zkbR@g%X%>nVoh)9SQ9c`OPq1lUO>}XC2GmaQNH;4*{bY6C(r*X!p~)$RPpJ&Do8d1 zL-e4SCT+-flY3Q|hV$Lyt0j}z`8ISekj-YHwk+ASTw=@xvc)-d^(aT-=B?3;&7)Dp zx)xpZ2cW$J)#qouh^>`;PKCZM%FIn+yCCnus@{_I{D|+?!gSHn`5^LI!>W_Cf`Zqg z<+4KAzX&mpMDisju7_w7PjTtnRxYVUTNJ)xPNN`EgK8g`q=)L#XzP>R`3nwHZlhYi zZ8CMC15-5~$K2Vr#0`iZGe)hq(IesLTppF;_Ww8UN%53XdN_8|K4cKKO16IWM%TZHi)Y!BWUKdx^#q@B2|UhT5> z;x!5|g%z>}_Aq2Y)(EWtdWGE&e9@T`Q=;Ny(TO+&?kNV*1jU?dj3($_ zy-U-Q`;RlM_B&;6J{*0kwVn|c&4_Nf2> diff --git a/source/vcpp/cube.vcproj b/source/vcpp/cube.vcproj index 842450f9..6440339d 100644 --- a/source/vcpp/cube.vcproj +++ b/source/vcpp/cube.vcproj @@ -130,7 +130,7 @@ Name="VCLinkerTool" AdditionalOptions="/MACHINE:I386" AdditionalDependencies="odbc32.lib odbccp32.lib zlib.lib opengl32.lib glu32.lib msvcrt.lib SDLmain.lib SDL.lib SDL_image.lib SDL_mixer.lib ws2_32.lib winmm.lib" - OutputFile="../../bin_win32/ac_client_debug.exe" + OutputFile="../../bin_win32/ac_client.exe" LinkIncremental="2" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="..\lib"