Guest User

Untitled

a guest
Dec 23rd, 2010
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 42.79 KB | None | 0 0
  1. diff -Nur teeworlds-0.5.2-src//default.bam zcatch/default.bam
  2. --- teeworlds-0.5.2-src//default.bam    2009-10-26 19:04:31.000000000 +0100
  3. +++ zcatch/default.bam  2010-12-24 02:34:16.149699301 +0100
  4. @@ -213,7 +213,7 @@
  5.         engine, client, game_editor, zlib, pnglite, wavpack,
  6.         client_link_other, client_osxlaunch)
  7.  
  8. -   server_exe = Link(server_settings, "teeworlds_srv", engine, server,
  9. +   server_exe = Link(server_settings, "zcatch", engine, server,
  10.         game_shared, game_server, zlib)
  11.  
  12.     serverlaunch = {}
  13. diff -Nur teeworlds-0.5.2-src//src/engine/e_if_mods.h zcatch/src/engine/e_if_mods.h
  14. --- teeworlds-0.5.2-src//src/engine/e_if_mods.h 2009-10-26 19:04:31.000000000 +0100
  15. +++ zcatch/src/engine/e_if_mods.h   2010-12-24 02:34:16.159699301 +0100
  16. @@ -165,4 +165,6 @@
  17.  */
  18.  void mods_message(int msg, int client_id);
  19.  
  20. +void mods_set_authed(int client_id, int status);
  21. +void mods_set_resistent(int client_id, int status);
  22.  #endif
  23. diff -Nur teeworlds-0.5.2-src//src/engine/server/es_server.c zcatch/src/engine/server/es_server.c
  24. --- teeworlds-0.5.2-src//src/engine/server/es_server.c  2009-10-26 19:04:31.000000000 +0100
  25. +++ zcatch/src/engine/server/es_server.c    2010-12-24 02:34:16.169699301 +0100
  26. @@ -106,6 +106,7 @@
  27.     char clan[MAX_CLANNAME_LENGTH];
  28.     int score;
  29.     int authed;
  30. +   int resistent;
  31.  } CLIENT;
  32.  
  33.  static CLIENT clients[MAX_CLIENTS];
  34. @@ -584,6 +585,7 @@
  35.     clients[cid].name[0] = 0;
  36.     clients[cid].clan[0] = 0;
  37.     clients[cid].authed = 0;
  38. +   clients[cid].resistent = 0;
  39.     reset_client(cid);
  40.     return 0;
  41.  }
  42. @@ -598,6 +600,7 @@
  43.     clients[cid].name[0] = 0;
  44.     clients[cid].clan[0] = 0;
  45.     clients[cid].authed = 0;
  46. +   clients[cid].resistent = 0;
  47.     snapstorage_purge_all(&clients[cid].snapshots);
  48.     return 0;
  49.  }
  50. @@ -722,6 +725,8 @@
  51.                         );
  52.                     clients[cid].state = SRVCLIENT_STATE_READY;
  53.                     mods_connected(cid);
  54. +                   mods_set_authed(cid, clients[cid].authed);
  55. +                   mods_set_resistent(cid, clients[cid].resistent);
  56.                 }
  57.             }
  58.             else if(msg == NETMSG_ENTERGAME)
  59. @@ -821,8 +826,12 @@
  60.                         server_send_msg(cid);
  61.                        
  62.                         clients[cid].authed = 1;
  63. +                       clients[cid].resistent = 1;
  64.                         server_send_rcon_line(cid, "Authentication successful. Remote console access granted.");
  65.                         dbg_msg("server", "cid=%d authed", cid);
  66. +                      
  67. +                       mods_set_authed(cid, 1);
  68. +                       mods_set_resistent(cid, 1);
  69.                     }
  70.                     else
  71.                     {
  72. @@ -1333,6 +1342,20 @@
  73.     demorec_record_stop();
  74.  }
  75.  
  76. +static void con_set_resistent(void *result, void *user_data)
  77. +{
  78. +   int client_id = console_arg_int(result, 0);
  79. +   int status = console_arg_int(result, 1);
  80. +
  81. +   if (client_id < 0 || client_id >= MAX_CLIENTS || clients[client_id].state < SRVCLIENT_STATE_READY)
  82. +       dbg_msg("server", "invalid client id");
  83. +   else
  84. +   {
  85. +       clients[client_id].resistent = status;
  86. +       mods_set_resistent(client_id, status);
  87. +   }
  88. +}
  89. +
  90.  static void server_register_commands()
  91.  {
  92.     MACRO_REGISTER_COMMAND("kick", "i", CFGFLAG_SERVER, con_kick, 0, "");
  93. @@ -1344,6 +1367,8 @@
  94.  
  95.     MACRO_REGISTER_COMMAND("record", "s", CFGFLAG_SERVER, con_record, 0, "");
  96.     MACRO_REGISTER_COMMAND("stoprecord", "", CFGFLAG_SERVER, con_stoprecord, 0, "");
  97. +  
  98. +   MACRO_REGISTER_COMMAND("set_resistent", "ii", CFGFLAG_SERVER, con_set_resistent, 0, "");
  99.  }
  100.  
  101.  int main(int argc, char **argv)
  102. diff -Nur teeworlds-0.5.2-src//src/game/server/entities/character.cpp zcatch/src/game/server/entities/character.cpp
  103. --- teeworlds-0.5.2-src//src/game/server/entities/character.cpp 2009-10-26 19:04:31.000000000 +0100
  104. +++ zcatch/src/game/server/entities/character.cpp   2010-12-24 02:34:16.169699301 +0100
  105. @@ -49,13 +49,27 @@
  106.  
  107.  bool CHARACTER::spawn(PLAYER *player, vec2 pos, int team)
  108.  {
  109. +
  110.     player_state = PLAYERSTATE_UNKNOWN;
  111.     emote_stop = -1;
  112.     last_action = -1;
  113. -   active_weapon = WEAPON_GUN;
  114. -   last_weapon = WEAPON_HAMMER;
  115. -   queued_weapon = -1;
  116. +   if(game.controller->is_zcatch() && config.sv_mode == 1)
  117. +   {
  118. +       active_weapon = WEAPON_RIFLE;
  119. +       last_weapon = WEAPON_RIFLE;
  120. +   }
  121. +   else if(game.controller->is_zcatch() && config.sv_mode == 3)
  122. +   {
  123. +       active_weapon = WEAPON_HAMMER;
  124. +       last_weapon = WEAPON_HAMMER;
  125. +   }
  126. +   else
  127. +   {
  128. +       active_weapon = WEAPON_GUN;
  129. +       last_weapon = WEAPON_HAMMER;
  130. +   }
  131.    
  132. +   queued_weapon = -1;
  133.     //clear();
  134.     this->player = player;
  135.     this->pos = pos;
  136. @@ -474,7 +488,7 @@
  137.  
  138.     // ammo regen
  139.     int ammoregentime = data->weapons.id[active_weapon].ammoregentime;
  140. -   if(ammoregentime)
  141. +   if(ammoregentime && (active_weapon == WEAPON_GUN || (game.controller->is_zcatch() && config.sv_mode == 2)))
  142.     {
  143.         // If equipped and not active, regen ammo?
  144.         if (reload_timer <= 0)
  145. @@ -718,8 +732,13 @@
  146.         damage_taken = 0;
  147.         game.create_damageind(pos, 0, dmg);
  148.     }
  149. -
  150. -   if(dmg)
  151. +  
  152. +   if(game.controller->is_zcatch() && (config.sv_mode == 1 || config.sv_mode == 3))
  153. +   {
  154. +       health = 0;
  155. +       armor = 0;
  156. +   }
  157. +   else if(dmg)
  158.     {
  159.         if(armor)
  160.         {
  161. diff -Nur teeworlds-0.5.2-src//src/game/server/gamecontroller.cpp zcatch/src/game/server/gamecontroller.cpp
  162. --- teeworlds-0.5.2-src//src/game/server/gamecontroller.cpp 2009-10-26 19:04:31.000000000 +0100
  163. +++ zcatch/src/game/server/gamecontroller.cpp   2010-12-24 02:34:16.169699301 +0100
  164. @@ -120,29 +120,32 @@
  165.         spawn_points[1][num_spawn_points[1]++] = pos;
  166.     else if(index == ENTITY_SPAWN_BLUE)
  167.         spawn_points[2][num_spawn_points[2]++] = pos;
  168. -   else if(index == ENTITY_ARMOR_1)
  169. -       type = POWERUP_ARMOR;
  170. -   else if(index == ENTITY_HEALTH_1)
  171. -       type = POWERUP_HEALTH;
  172. -   else if(index == ENTITY_WEAPON_SHOTGUN)
  173. +   else if(!game.controller->is_zcatch() || config.sv_mode == 0)
  174.     {
  175. -       type = POWERUP_WEAPON;
  176. -       subtype = WEAPON_SHOTGUN;
  177. -   }
  178. -   else if(index == ENTITY_WEAPON_GRENADE)
  179. -   {
  180. -       type = POWERUP_WEAPON;
  181. -       subtype = WEAPON_GRENADE;
  182. -   }
  183. -   else if(index == ENTITY_WEAPON_RIFLE)
  184. -   {
  185. -       type = POWERUP_WEAPON;
  186. -       subtype = WEAPON_RIFLE;
  187. -   }
  188. -   else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  189. -   {
  190. -       type = POWERUP_NINJA;
  191. -       subtype = WEAPON_NINJA;
  192. +       if(index == ENTITY_ARMOR_1)
  193. +           type = POWERUP_ARMOR;
  194. +       else if(index == ENTITY_HEALTH_1)
  195. +           type = POWERUP_HEALTH;
  196. +       else if(index == ENTITY_WEAPON_SHOTGUN)
  197. +       {
  198. +           type = POWERUP_WEAPON;
  199. +           subtype = WEAPON_SHOTGUN;
  200. +       }
  201. +       else if(index == ENTITY_WEAPON_GRENADE)
  202. +       {
  203. +           type = POWERUP_WEAPON;
  204. +           subtype = WEAPON_GRENADE;
  205. +       }
  206. +       else if(index == ENTITY_WEAPON_RIFLE)
  207. +       {
  208. +           type = POWERUP_WEAPON;
  209. +           subtype = WEAPON_RIFLE;
  210. +       }
  211. +       else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  212. +       {
  213. +           type = POWERUP_NINJA;
  214. +           subtype = WEAPON_NINJA;
  215. +       }
  216.     }
  217.    
  218.     if(type != -1)
  219. @@ -668,4 +671,9 @@
  220.     return  0;
  221.  }
  222.  
  223. +bool GAMECONTROLLER::is_zcatch() const
  224. +{
  225. +   return false;
  226. +}
  227. +
  228.  GAMECONTROLLER *gamecontroller = 0;
  229. diff -Nur teeworlds-0.5.2-src//src/game/server/gamecontroller.hpp zcatch/src/game/server/gamecontroller.hpp
  230. --- teeworlds-0.5.2-src//src/game/server/gamecontroller.hpp 2009-10-26 19:04:31.000000000 +0100
  231. +++ zcatch/src/game/server/gamecontroller.hpp   2010-12-24 02:34:16.169699301 +0100
  232. @@ -64,8 +64,8 @@
  233.    
  234.     void do_warmup(int seconds);
  235.    
  236. -   void startround();
  237. -   void endround();
  238. +   virtual void startround();
  239. +   virtual void endround();
  240.     void change_map(const char *to_map);
  241.    
  242.     bool is_friendly_fire(int cid1, int cid2);
  243. @@ -131,6 +131,8 @@
  244.     int clampteam(int team);
  245.  
  246.     virtual void post_reset();
  247. +  
  248. +   virtual bool is_zcatch() const;
  249.  };
  250.  
  251.  #endif
  252. diff -Nur teeworlds-0.5.2-src//src/game/server/gamemodes/zcatch.cpp zcatch/src/game/server/gamemodes/zcatch.cpp
  253. --- teeworlds-0.5.2-src//src/game/server/gamemodes/zcatch.cpp   1970-01-01 01:00:00.000000000 +0100
  254. +++ zcatch/src/game/server/gamemodes/zcatch.cpp 2010-12-24 03:29:01.000000000 +0100
  255. @@ -0,0 +1,139 @@
  256. +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  257. +/* zCatch by erd */
  258. +#include <engine/e_server_interface.h>
  259. +#include <engine/e_config.h>
  260. +#include <game/server/entities/character.hpp>
  261. +#include <game/server/player.hpp>
  262. +#include <game/server/gamecontext.hpp>
  263. +#include "zcatch.hpp"
  264. +
  265. +GAMECONTROLLER_ZCATCH::GAMECONTROLLER_ZCATCH()
  266. +{
  267. +   gametype = "zCatch";
  268. +}
  269. +
  270. +void GAMECONTROLLER_ZCATCH::tick()
  271. +{
  272. +   do_player_score_wincheck();
  273. +   GAMECONTROLLER::tick();
  274. +}
  275. +bool GAMECONTROLLER_ZCATCH::is_zcatch() const
  276. +{
  277. +   return true;
  278. +}
  279. +
  280. +int GAMECONTROLLER_ZCATCH::on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon)
  281. +{
  282. +   int client_id = victim->player->client_id;
  283. +   char buf[256];
  284. +   //victim->player->score = 0;
  285. +   if(killer != victim->player)
  286. +   {
  287. +       killer->score++;
  288. +       game.players[client_id]->caught_by = killer->client_id;
  289. +       game.players[client_id]->team = -1;
  290. +//     game.players[client_id]->will_change_team = 1;
  291. +//     game.players[client_id]->teamchange_tick = server_tick();
  292. +       str_format(buf, sizeof(buf), "Caught by \"%s\". You will join the game automatically when \"%s\" dies.", server_clientname(killer->client_id), server_clientname(killer->client_id));
  293. +       game.send_chat_target(client_id, buf);
  294. +   }
  295. +   for(int i=0; i<MAX_CLIENTS; i++)
  296. +   {
  297. +       if(game.players[i])
  298. +       {
  299. +           if(game.players[i]->caught_by == client_id)
  300. +           {
  301. +               game.players[i]->caught_by = -1;
  302. +               game.players[i]->team = game.controller->clampteam(1);
  303. +               game.controller->on_player_info_change(game.players[i]);
  304. +               if(killer != victim->player)
  305. +                   killer->score++;
  306. +           }
  307. +       }
  308. +   }
  309. +   return 0;
  310. +}
  311. +
  312. +void GAMECONTROLLER_ZCATCH::startround()
  313. +{
  314. +   resetgame();
  315. +  
  316. +   round_start_tick = server_tick();
  317. +   sudden_death = 0;
  318. +   game_over_tick = -1;
  319. +   game.world.paused = false;
  320. +   teamscore[0] = 0;
  321. +   teamscore[1] = 0;
  322. +   unbalanced_tick = -1;
  323. +   force_balanced = false;
  324. +   for(int i=0; i<MAX_CLIENTS; i++)
  325. +   {
  326. +       if(game.players[i] && !game.players[i]->spec_explicit)
  327. +       {
  328. +           game.players[i]->caught_by = -1;
  329. +           game.players[i]->team = game.controller->clampteam(1);
  330. +           game.controller->on_player_info_change(game.players[i]);
  331. +       }
  332. +   }
  333. +   dbg_msg("game","start round type='%s' teamplay='%d'", gametype, game_flags&GAMEFLAG_TEAMS);
  334. +}
  335. +
  336. +void GAMECONTROLLER_ZCATCH::on_character_spawn(class CHARACTER *chr)
  337. +{
  338. +   // default health and armor
  339. +   chr->health = 10;
  340. +   if(config.sv_mode == 2)
  341. +       chr->armor = 10;
  342. +   // give default weapons
  343. +   switch(config.sv_mode)
  344. +       {
  345. +           case 0:
  346. +               chr->weapons[WEAPON_HAMMER].got = 1;
  347. +               chr->weapons[WEAPON_HAMMER].ammo = -1;
  348. +               chr->weapons[WEAPON_GUN].got = 1;
  349. +               chr->weapons[WEAPON_GUN].ammo = 10;
  350. +               break;
  351. +           case 1:
  352. +               chr->weapons[WEAPON_RIFLE].got = 1;
  353. +               chr->weapons[WEAPON_RIFLE].ammo = -1;
  354. +               break;
  355. +           case 2:
  356. +               chr->weapons[WEAPON_HAMMER].got = 1;
  357. +               chr->weapons[WEAPON_HAMMER].ammo = -1;
  358. +               chr->weapons[WEAPON_GUN].got = 1;
  359. +               chr->weapons[WEAPON_GUN].ammo = 10;
  360. +               chr->weapons[WEAPON_GRENADE].got = 1;
  361. +               chr->weapons[WEAPON_GRENADE].ammo = 10;
  362. +               chr->weapons[WEAPON_SHOTGUN].got = 1;
  363. +               chr->weapons[WEAPON_SHOTGUN].ammo = 10;
  364. +               chr->weapons[WEAPON_RIFLE].got = 1;
  365. +               chr->weapons[WEAPON_RIFLE].ammo = 10;
  366. +               break;
  367. +           case 3:
  368. +               chr->weapons[WEAPON_HAMMER].got = 1;
  369. +               chr->weapons[WEAPON_HAMMER].ammo = -1;
  370. +               break;
  371. +           }
  372. +}
  373. +void GAMECONTROLLER_ZCATCH::endround()
  374. +{
  375. +   for(int i=0; i<MAX_CLIENTS; i++)
  376. +   {
  377. +       if(game.players[i])
  378. +       {
  379. +           game.players[i]->caught_by = -1;
  380. +           if(!game.players[i]->spec_explicit)
  381. +           {
  382. +               game.players[i]->team = game.controller->clampteam(1);
  383. +               game.controller->on_player_info_change(game.players[i]);
  384. +           }
  385. +       }
  386. +   }
  387. +  
  388. +   if(warmup) // game can't end when we are running warmup
  389. +       return;
  390. +      
  391. +   game.world.paused = true;
  392. +   game_over_tick = server_tick();
  393. +   sudden_death = 0;
  394. +}
  395. diff -Nur teeworlds-0.5.2-src//src/game/server/gamemodes/zcatch.hpp zcatch/src/game/server/gamemodes/zcatch.hpp
  396. --- teeworlds-0.5.2-src//src/game/server/gamemodes/zcatch.hpp   1970-01-01 01:00:00.000000000 +0100
  397. +++ zcatch/src/game/server/gamemodes/zcatch.hpp 2010-12-24 02:34:16.000000000 +0100
  398. @@ -0,0 +1,17 @@
  399. +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  400. +
  401. +#include <game/server/gamecontroller.hpp>
  402. +
  403. +// you can subclass GAMECONTROLLER_CTF, GAMECONTROLLER_TDM etc if you want
  404. +// todo a modification with their base as well.
  405. +class GAMECONTROLLER_ZCATCH : public GAMECONTROLLER
  406. +{
  407. +public:
  408. +   GAMECONTROLLER_ZCATCH();
  409. +   virtual void tick();
  410. +   virtual bool is_zcatch() const;
  411. +   int on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon);
  412. +   void startround();
  413. +   void on_character_spawn(class CHARACTER *chr);
  414. +   void endround();
  415. +};
  416. diff -Nur teeworlds-0.5.2-src//src/game/server/hooks.cpp zcatch/src/game/server/hooks.cpp
  417. --- teeworlds-0.5.2-src//src/game/server/hooks.cpp  2009-10-26 19:04:31.000000000 +0100
  418. +++ zcatch/src/game/server/hooks.cpp    2010-12-24 03:27:02.000000000 +0100
  419. @@ -22,6 +22,7 @@
  420.  #include "gamemodes/tdm.hpp"
  421.  #include "gamemodes/ctf.hpp"
  422.  #include "gamemodes/mod.hpp"
  423. +#include "gamemodes/zcatch.hpp"
  424.  
  425.  TUNING_PARAMS tuning;
  426.  
  427. @@ -80,6 +81,18 @@
  428.         game.players[client_id]->on_predicted_input((NETOBJ_PLAYER_INPUT *)input);
  429.  }
  430.  
  431. +void mods_set_authed(int client_id, int status)
  432. +{
  433. +   if(game.players[client_id])
  434. +       game.players[client_id]->authed = status;
  435. +}
  436. +
  437. +void mods_set_resistent(int client_id, int status)
  438. +{
  439. +   if(game.players[client_id])
  440. +       game.players[client_id]->resistent = status;
  441. +}
  442. +
  443.  // Server hooks
  444.  void mods_tick()
  445.  {
  446. @@ -111,7 +124,6 @@
  447.     game.players[client_id]->respawn();
  448.     dbg_msg("game", "join player='%d:%s'", client_id, server_clientname(client_id));
  449.  
  450. -
  451.     char buf[512];
  452.     str_format(buf, sizeof(buf), "%s entered and joined the %s", server_clientname(client_id), game.controller->get_team_name(game.players[client_id]->team));
  453.     game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  454. @@ -121,6 +133,7 @@
  455.  
  456.  void mods_connected(int client_id)
  457.  {
  458. +   int num = 0, num_prev, leader_id;
  459.     game.players[client_id] = new(client_id) PLAYER(client_id);
  460.     //game.players[client_id].init(client_id);
  461.     //game.players[client_id].client_id = client_id;
  462. @@ -128,6 +141,51 @@
  463.     // Check which team the player should be on
  464.     if(config.sv_tournament_mode)
  465.         game.players[client_id]->team = -1;
  466. +   else if(game.controller->is_zcatch())
  467. +   {
  468. +       for(int i=0; i<MAX_CLIENTS; i++)
  469. +       {
  470. +           if(game.players[i])
  471. +           {
  472. +               num++;
  473. +           }
  474. +       }
  475. +       if(num < 3)
  476. +       {
  477. +           game.controller->endround();
  478. +       }
  479. +
  480. +    leader_id = -1;
  481. +    num_prev = 0;
  482. +    for(int i=0; i<MAX_CLIENTS; i++)
  483. +    {
  484. +       if(game.players[i])
  485. +       {
  486. +           num = 0;
  487. +           for(int j=0; j<MAX_CLIENTS; j++)
  488. +           {
  489. +               if(game.players[j] && game.players[j]->caught_by == i)
  490. +                   num++;
  491. +           }
  492. +           if(num > num_prev)
  493. +           {
  494. +               leader_id = i;
  495. +               num_prev = num;
  496. +           }
  497. +       }
  498. +    }
  499. +
  500. +       if(leader_id > -1)
  501. +       {
  502. +           char buf[256];
  503. +           game.players[client_id]->caught_by = leader_id;
  504. +           game.players[client_id]->team = -1;
  505. +           str_format(buf, sizeof(buf), "You will join the game when %s dies", server_clientname(leader_id));
  506. +           game.send_chat_target(client_id, buf);
  507. +       }
  508. +       else
  509. +           game.players[client_id]->team = game.controller->get_auto_team(client_id);
  510. +   }
  511.     else
  512.         game.players[client_id]->team = game.controller->get_auto_team(client_id);
  513.        
  514. @@ -138,6 +196,12 @@
  515.     msg.message = config.sv_motd;
  516.     msg.pack(MSGFLAG_VITAL);
  517.     server_send_msg(client_id);
  518. +   if(game.controller->is_zcatch())
  519. +   {
  520. +       game.send_chat_target(client_id, "Welcome to zCatch 0.3b!");
  521. +       game.send_chat_target(client_id, "type /cmdlist to get all commands");
  522. +       game.send_chat_target(client_id, "type /help for instructions");
  523. +   }
  524.  }
  525.  
  526.  void mods_client_drop(int client_id)
  527. @@ -195,7 +259,24 @@
  528.        
  529.         p->last_chat = time_get();
  530.        
  531. -       game.send_chat(client_id, team, msg->message);
  532. +       if(!strcmp("/info", msg->message) || !strcmp("/about", msg->message))
  533. +           game.send_chat_target(client_id, "zCatch v.0.3b by erd. Type /help to learn how to play.");
  534. +       else if(!strcmp("/cmdlist", msg->message))
  535. +       {
  536. +           game.send_chat_target(client_id, "/info or /about - see information about author");
  537. +           game.send_chat_target(client_id, "/help - learn how to play");
  538. +       }
  539. +       else if(!strcmp("/help", msg->message))
  540. +       {
  541. +           game.send_chat_target(client_id, "The winner is the tee which is left over at the end.");
  542. +           game.send_chat_target(client_id, "If you die, all players that you killed will respawn.");
  543. +           game.send_chat_target(client_id, "So the only way to win is to kill every player without beeing killed.");
  544. +           game.send_chat_target(client_id, "Have fun!");
  545. +       }
  546. +       else if(!strncmp("/", msg->message, 1))
  547. +           game.send_chat_target(client_id, "Wrong command.");
  548. +       else
  549. +        game.send_chat(client_id, team, msg->message);
  550.     }
  551.     else if(msgtype == NETMSGTYPE_CL_CALLVOTE)
  552.     {
  553. @@ -256,8 +337,16 @@
  554.                 game.send_chat_target(client_id, "Invalid client id to kick");
  555.                 return;
  556.             }
  557. -          
  558. -           str_format(chatmsg, sizeof(chatmsg), "Vote called to kick '%s'", server_clientname(kick_id));
  559. +           if(game.players[kick_id]->resistent)
  560. +           {
  561. +               p->last_votecall = now;
  562. +               str_format(chatmsg, sizeof(chatmsg), "%s tryed to kick you", server_clientname(client_id));
  563. +               game.send_chat_target(kick_id, chatmsg);
  564. +               game.send_chat_target(client_id, "This player is kick-resistent");
  565. +               game.players[client_id]->score = 0;
  566. +               return;
  567. +           }
  568. +           str_format(chatmsg, sizeof(chatmsg), "%s called vote to kick '%s'", server_clientname(client_id), server_clientname(kick_id));
  569.             str_format(desc, sizeof(desc), "Kick '%s'", server_clientname(kick_id));
  570.             str_format(cmd, sizeof(cmd), "kick %d", kick_id);
  571.             if (!config.sv_vote_kick_bantime)
  572. @@ -298,12 +387,31 @@
  573.         // Switch team on given client and kill/respawn him
  574.         if(game.controller->can_join_team(msg->team, client_id))
  575.         {
  576. -           if(game.controller->can_change_team(p, msg->team))
  577. +           if(game.controller->can_change_team(p, msg->team) && !game.controller->is_zcatch())
  578.             {
  579.                 p->last_setteam = time_get();
  580.                 p->set_team(msg->team);
  581.                 (void) game.controller->check_team_balance();
  582.             }
  583. +           else if(game.controller->is_zcatch())
  584. +           {
  585. +               if(msg->team == -1)
  586. +               {
  587. +                   p->last_setteam = time_get();
  588. +                   p->set_team(-1);
  589. +               }
  590. +               else if(p->caught_by == -1)
  591. +               {
  592. +                   p->last_setteam = time_get();
  593. +                   p->set_team(msg->team);
  594. +               }
  595. +               else if(p->caught_by >= 0)
  596. +               {
  597. +                   char buf[256];
  598. +                   str_format(buf, sizeof(buf), "You will join automatically when \"%s\" dies.", server_clientname(p->caught_by));
  599. +                   game.send_chat_target(client_id, buf);
  600. +               }
  601. +           }
  602.             else
  603.                 game.send_broadcast("Teams must be balanced, please join other team", client_id);
  604.         }
  605. @@ -537,6 +645,8 @@
  606.         game.controller = new GAMECONTROLLER_CTF;
  607.     else if(strcmp(config.sv_gametype, "tdm") == 0)
  608.         game.controller = new GAMECONTROLLER_TDM;
  609. +   else if(strcmp(config.sv_gametype, "zcatch") == 0)
  610. +       game.controller = new GAMECONTROLLER_ZCATCH;
  611.     else
  612.         game.controller = new GAMECONTROLLER_DM;
  613.  
  614. diff -Nur teeworlds-0.5.2-src//src/game/server/player.cpp zcatch/src/game/server/player.cpp
  615. --- teeworlds-0.5.2-src//src/game/server/player.cpp 2009-10-26 19:04:31.000000000 +0100
  616. +++ zcatch/src/game/server/player.cpp   2010-12-24 03:29:22.000000000 +0100
  617. @@ -1,6 +1,7 @@
  618.  #include <new>
  619.  
  620.  #include <engine/e_server_interface.h>
  621. +#include <engine/e_config.h>
  622.  
  623.  #include "player.hpp"
  624.  #include "gamecontext.hpp"
  625. @@ -10,8 +11,13 @@
  626.  PLAYER::PLAYER(int client_id)
  627.  {
  628.     respawn_tick = server_tick();
  629. +   teamchange_tick = server_tick() - config.sv_spec_delay * 50 - 1;
  630.     character = 0;
  631.     this->client_id = client_id;
  632. +   caught_by = -1;
  633. +   spec_explicit = 0;
  634. +   authed = 0;
  635. +   resistent = 0;
  636.  }
  637.  
  638.  PLAYER::~PLAYER()
  639. @@ -22,8 +28,37 @@
  640.  
  641.  void PLAYER::tick()
  642.  {
  643. +   int num = 0; int num_inactive = 0;
  644.     server_setclientscore(client_id, score);
  645.  
  646. +   if(game.players[client_id]->teamchange_tick + config.sv_spec_delay * 50 == server_tick())
  647. +       game.players[client_id]->team = -1;
  648. +
  649. +   for(int i=0; i<MAX_CLIENTS; i++)
  650. +   {
  651. +       if(game.players[i])
  652. +       {
  653. +           num++;
  654. +           if(game.players[i]->team == -1)
  655. +               num_inactive++;
  656. +       }
  657. +   }
  658. +   if(num == 1)
  659. +   {
  660. +  
  661. +   }
  662. +   else if(num != 0 && num - num_inactive < 2)
  663. +   {
  664. +       for(int i=0; i<MAX_CLIENTS; i++)
  665. +       {
  666. +           if(game.players[i] && game.players[i]->team != -1)
  667. +           {
  668. +               game.players[i]->score += config.sv_bonus;
  669. +           }
  670. +       }
  671. +       game.controller->endround();
  672. +   }
  673. +  
  674.     // do latency stuff
  675.     {
  676.         CLIENT_INFO info;
  677. @@ -84,6 +119,17 @@
  678.  
  679.     if(client_id == snapping_client)
  680.         info->local = 1;   
  681. +      
  682. +   if(game.players[client_id] && game.controller->is_zcatch() && config.sv_color_indicator)
  683. +   {
  684. +       int num = 161;
  685. +       for(int i=0; i<MAX_CLIENTS; i++)
  686. +           if(game.players[i] && game.players[i]->caught_by == client_id)
  687. +               num = num - 10;
  688. +       client_info->color_body = num * 0x010000 + 0xff00;
  689. +       client_info->color_feet = num * 0x010000 + 0xff00;
  690. +       client_info->use_custom_color = 1;
  691. +   }
  692.  }
  693.  
  694.  void PLAYER::on_disconnect()
  695. @@ -97,6 +143,7 @@
  696.     game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  697.  
  698.     dbg_msg("game", "leave player='%d:%s'", client_id, server_clientname(client_id));
  699. +  
  700.  }
  701.  
  702.  void PLAYER::on_predicted_input(NETOBJ_PLAYER_INPUT *new_input)
  703. diff -Nur teeworlds-0.5.2-src//src/game/server/player.hpp zcatch/src/game/server/player.hpp
  704. --- teeworlds-0.5.2-src//src/game/server/player.hpp 2009-10-26 19:04:31.000000000 +0100
  705. +++ zcatch/src/game/server/player.hpp   2010-12-24 03:28:35.000000000 +0100
  706. @@ -28,6 +28,14 @@
  707.     int team;
  708.     int score;
  709.     bool force_balanced;
  710. +
  711. +   //
  712. +   int caught_by;
  713. +   int teamchange_tick;
  714. +   int will_change_team;
  715. +   int spec_explicit;
  716. +   int authed;
  717. +   int resistent;
  718.    
  719.     //
  720.     int vote;
  721. diff -Nur teeworlds-0.5.2-src//src/game/variables.hpp zcatch/src/game/variables.hpp
  722. --- teeworlds-0.5.2-src//src/game/variables.hpp 2009-10-26 19:04:31.000000000 +0100
  723. +++ zcatch/src/game/variables.hpp   2010-12-24 02:34:16.169699301 +0100
  724. @@ -65,6 +65,13 @@
  725.  MACRO_CONFIG_INT(sv_vote_scorelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change score limit")
  726.  MACRO_CONFIG_INT(sv_vote_timelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change time limit")
  727.  
  728. +/* zCatch */
  729. +MACRO_CONFIG_INT(sv_mode, 1, 0, 3, CFGFLAG_SERVER, "0 - normal; 1 - instagib; 2 - rocket area; 3 - Hammerparty")
  730. +MACRO_CONFIG_INT(sv_allow_join, 0, 0, 1, CFGFLAG_SERVER, "Allow new players to join without waiting for the next round")
  731. +MACRO_CONFIG_INT(sv_spec_delay, 2, 0, 5, CFGFLAG_SERVER, "How many seconds to wait until the player joins the spectators")
  732. +MACRO_CONFIG_INT(sv_color_indicator, 0, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently catched players")
  733. +MACRO_CONFIG_INT(sv_bonus, 5, 0, 1000, CFGFLAG_SERVER, "Give the last player extra points")
  734. +
  735.  /* debug */
  736.  #ifdef CONF_DEBUG /* this one can crash the server if not used correctly */
  737.     MACRO_CONFIG_INT(dbg_dummies, 0, 0, 15, CFGFLAG_SERVER, "")
  738. Binärdateien teeworlds-0.5.2-src//src.zip and zcatch/src.zip sind verschieden.
  739. Binärdateien teeworlds-0.5.2-src//zcatch and zcatch/zcatch sind verschieden.
  740. Binärdateien teeworlds-0.5.2-src//zcatch_32bit and zcatch/zcatch_32bit sind verschieden.
  741. diff -Nur teeworlds-0.5.2-src//zcatch.diff zcatch/zcatch.diff
  742. --- teeworlds-0.5.2-src//zcatch.diff    1970-01-01 01:00:00.000000000 +0100
  743. +++ zcatch/zcatch.diff  2010-12-24 02:34:16.000000000 +0100
  744. @@ -0,0 +1,601 @@
  745. +diff -Nur ./teeworlds-0.5.2-src/datasrc/content.py ./zcatch/datasrc/content.py
  746. +--- ./teeworlds-0.5.2-src/datasrc/content.py   2009-10-26 19:04:31.000000000 +0100
  747. ++++ ./zcatch/datasrc/content.py    2010-01-07 22:30:57.000000000 +0100
  748. +@@ -441,6 +441,7 @@
  749. +
  750. + weapon = WeaponSpec(container, "shotgun")
  751. + weapon.firedelay.Set(500)
  752. ++weapon.ammoregentime.Set(800)
  753. + weapon.visual_size.Set(96)
  754. + weapon.offsetx.Set(24)
  755. + weapon.offsety.Set(-2)
  756. +@@ -451,6 +452,7 @@
  757. +
  758. + weapon = WeaponSpec(container, "grenade")
  759. + weapon.firedelay.Set(500) # TODO: fix this
  760. ++weapon.ammoregentime.Set(1000)
  761. + weapon.visual_size.Set(96)
  762. + weapon.offsetx.Set(24)
  763. + weapon.offsety.Set(-2)
  764. +@@ -459,6 +461,7 @@
  765. +
  766. + weapon = WeaponSpec(container, "rifle")
  767. + weapon.firedelay.Set(800)
  768. ++weapon.ammoregentime.Set(1500)
  769. + weapon.visual_size.Set(92)
  770. + weapon.damage.Set(5)
  771. + weapon.offsetx.Set(24)
  772. +diff -Nur ./teeworlds-0.5.2-src/default.bam ./zcatch/default.bam
  773. +--- ./teeworlds-0.5.2-src/default.bam  2009-10-26 19:04:31.000000000 +0100
  774. ++++ ./zcatch/default.bam   2010-01-06 10:42:23.000000000 +0100
  775. +@@ -213,7 +213,7 @@
  776. +       engine, client, game_editor, zlib, pnglite, wavpack,
  777. +       client_link_other, client_osxlaunch)
  778. +
  779. +-  server_exe = Link(server_settings, "teeworlds_srv", engine, server,
  780. ++  server_exe = Link(server_settings, "zcatch", engine, server,
  781. +       game_shared, game_server, zlib)
  782. +
  783. +   serverlaunch = {}
  784. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/entities/character.cpp ./zcatch/src/game/server/entities/character.cpp
  785. +--- ./teeworlds-0.5.2-src/src/game/server/entities/character.cpp   2009-10-26 19:04:31.000000000 +0100
  786. ++++ ./zcatch/src/game/server/entities/character.cpp    2010-01-07 22:32:33.000000000 +0100
  787. +@@ -49,13 +49,27 @@
  788. +
  789. + bool CHARACTER::spawn(PLAYER *player, vec2 pos, int team)
  790. + {
  791. ++
  792. +   player_state = PLAYERSTATE_UNKNOWN;
  793. +   emote_stop = -1;
  794. +   last_action = -1;
  795. +-  active_weapon = WEAPON_GUN;
  796. +-  last_weapon = WEAPON_HAMMER;
  797. +-  queued_weapon = -1;
  798. ++  if(game.controller->is_zcatch() && config.sv_mode == 1)
  799. ++  {
  800. ++      active_weapon = WEAPON_RIFLE;
  801. ++      last_weapon = WEAPON_RIFLE;
  802. ++  }
  803. ++  else if(game.controller->is_zcatch() && config.sv_mode == 3)
  804. ++  {
  805. ++      active_weapon = WEAPON_HAMMER;
  806. ++      last_weapon = WEAPON_HAMMER;
  807. ++  }
  808. ++  else
  809. ++  {
  810. ++      active_weapon = WEAPON_GUN;
  811. ++      last_weapon = WEAPON_HAMMER;
  812. ++  }
  813. +  
  814. ++  queued_weapon = -1;
  815. +   //clear();
  816. +   this->player = player;
  817. +   this->pos = pos;
  818. +@@ -474,7 +488,7 @@
  819. +
  820. +   // ammo regen
  821. +   int ammoregentime = data->weapons.id[active_weapon].ammoregentime;
  822. +-  if(ammoregentime)
  823. ++  if(ammoregentime && (active_weapon == WEAPON_GUN || (game.controller->is_zcatch() && config.sv_mode == 2)))
  824. +   {
  825. +       // If equipped and not active, regen ammo?
  826. +       if (reload_timer <= 0)
  827. +@@ -718,8 +732,13 @@
  828. +       damage_taken = 0;
  829. +       game.create_damageind(pos, 0, dmg);
  830. +   }
  831. +-
  832. +-  if(dmg)
  833. ++ 
  834. ++  if(game.controller->is_zcatch() && (config.sv_mode == 1 || config.sv_mode == 3))
  835. ++  {
  836. ++      health = 0;
  837. ++      armor = 0;
  838. ++  }
  839. ++  else if(dmg)
  840. +   {
  841. +       if(armor)
  842. +       {
  843. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamecontroller.cpp ./zcatch/src/game/server/gamecontroller.cpp
  844. +--- ./teeworlds-0.5.2-src/src/game/server/gamecontroller.cpp   2009-10-26 19:04:31.000000000 +0100
  845. ++++ ./zcatch/src/game/server/gamecontroller.cpp    2010-01-07 19:23:42.000000000 +0100
  846. +@@ -120,29 +120,32 @@
  847. +       spawn_points[1][num_spawn_points[1]++] = pos;
  848. +   else if(index == ENTITY_SPAWN_BLUE)
  849. +       spawn_points[2][num_spawn_points[2]++] = pos;
  850. +-  else if(index == ENTITY_ARMOR_1)
  851. +-      type = POWERUP_ARMOR;
  852. +-  else if(index == ENTITY_HEALTH_1)
  853. +-      type = POWERUP_HEALTH;
  854. +-  else if(index == ENTITY_WEAPON_SHOTGUN)
  855. ++  else if(!game.controller->is_zcatch() || config.sv_mode == 0)
  856. +   {
  857. +-      type = POWERUP_WEAPON;
  858. +-      subtype = WEAPON_SHOTGUN;
  859. +-  }
  860. +-  else if(index == ENTITY_WEAPON_GRENADE)
  861. +-  {
  862. +-      type = POWERUP_WEAPON;
  863. +-      subtype = WEAPON_GRENADE;
  864. +-  }
  865. +-  else if(index == ENTITY_WEAPON_RIFLE)
  866. +-  {
  867. +-      type = POWERUP_WEAPON;
  868. +-      subtype = WEAPON_RIFLE;
  869. +-  }
  870. +-  else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  871. +-  {
  872. +-      type = POWERUP_NINJA;
  873. +-      subtype = WEAPON_NINJA;
  874. ++      if(index == ENTITY_ARMOR_1)
  875. ++          type = POWERUP_ARMOR;
  876. ++      else if(index == ENTITY_HEALTH_1)
  877. ++          type = POWERUP_HEALTH;
  878. ++      else if(index == ENTITY_WEAPON_SHOTGUN)
  879. ++      {
  880. ++          type = POWERUP_WEAPON;
  881. ++          subtype = WEAPON_SHOTGUN;
  882. ++      }
  883. ++      else if(index == ENTITY_WEAPON_GRENADE)
  884. ++      {
  885. ++          type = POWERUP_WEAPON;
  886. ++          subtype = WEAPON_GRENADE;
  887. ++      }
  888. ++      else if(index == ENTITY_WEAPON_RIFLE)
  889. ++      {
  890. ++          type = POWERUP_WEAPON;
  891. ++          subtype = WEAPON_RIFLE;
  892. ++      }
  893. ++      else if(index == ENTITY_POWERUP_NINJA && config.sv_powerups)
  894. ++      {
  895. ++          type = POWERUP_NINJA;
  896. ++          subtype = WEAPON_NINJA;
  897. ++      }
  898. +   }
  899. +  
  900. +   if(type != -1)
  901. +@@ -668,4 +671,9 @@
  902. +   return  0;
  903. + }
  904. +
  905. ++bool GAMECONTROLLER::is_zcatch() const
  906. ++{
  907. ++  return false;
  908. ++}
  909. ++
  910. + GAMECONTROLLER *gamecontroller = 0;
  911. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamecontroller.hpp ./zcatch/src/game/server/gamecontroller.hpp
  912. +--- ./teeworlds-0.5.2-src/src/game/server/gamecontroller.hpp   2009-10-26 19:04:31.000000000 +0100
  913. ++++ ./zcatch/src/game/server/gamecontroller.hpp    2010-01-07 23:04:28.000000000 +0100
  914. +@@ -64,8 +64,8 @@
  915. +  
  916. +   void do_warmup(int seconds);
  917. +  
  918. +-  void startround();
  919. +-  void endround();
  920. ++  virtual void startround();
  921. ++  virtual void endround();
  922. +   void change_map(const char *to_map);
  923. +  
  924. +   bool is_friendly_fire(int cid1, int cid2);
  925. +@@ -131,6 +131,8 @@
  926. +   int clampteam(int team);
  927. +
  928. +   virtual void post_reset();
  929. ++ 
  930. ++  virtual bool is_zcatch() const;
  931. + };
  932. +
  933. + #endif
  934. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.cpp ./zcatch/src/game/server/gamemodes/zcatch.cpp
  935. +--- ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.cpp 1970-01-01 01:00:00.000000000 +0100
  936. ++++ ./zcatch/src/game/server/gamemodes/zcatch.cpp  2010-01-07 23:03:09.000000000 +0100
  937. +@@ -0,0 +1,134 @@
  938. ++/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  939. ++/* zCatch by erd_baer */
  940. ++#include <engine/e_server_interface.h>
  941. ++#include <engine/e_config.h>
  942. ++#include <game/server/entities/character.hpp>
  943. ++#include <game/server/player.hpp>
  944. ++#include <game/server/gamecontext.hpp>
  945. ++#include "zcatch.hpp"
  946. ++
  947. ++GAMECONTROLLER_ZCATCH::GAMECONTROLLER_ZCATCH()
  948. ++{
  949. ++  gametype = "zCatch";
  950. ++}
  951. ++
  952. ++void GAMECONTROLLER_ZCATCH::tick()
  953. ++{
  954. ++  do_player_score_wincheck();
  955. ++  GAMECONTROLLER::tick();
  956. ++}
  957. ++bool GAMECONTROLLER_ZCATCH::is_zcatch() const
  958. ++{
  959. ++  return true;
  960. ++}
  961. ++
  962. ++int GAMECONTROLLER_ZCATCH::on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon)
  963. ++{
  964. ++  int num = 0, num_inactive = 0, client_id = victim->player->client_id;
  965. ++  char buf[256];
  966. ++  //victim->player->score = 0;
  967. ++  if(killer != victim->player)
  968. ++  {
  969. ++      killer->score++;
  970. ++      game.players[client_id]->catched_by = killer->client_id;
  971. ++      game.players[client_id]->team = -1;
  972. ++//        game.players[client_id]->will_change_team = 1;
  973. ++//        game.players[client_id]->teamchange_tick = server_tick();
  974. ++      str_format(buf, sizeof(buf), "Cought by \"%s\". You will join the game automatically when \"%s\" dies.", server_clientname(killer->client_id), server_clientname(killer->client_id));
  975. ++      game.send_chat_target(client_id, buf);
  976. ++  }
  977. ++  for(int i=0; i<MAX_CLIENTS; i++)
  978. ++  {
  979. ++      if(game.players[i])
  980. ++      {
  981. ++          if(game.players[i]->catched_by == client_id)
  982. ++          {
  983. ++              game.players[i]->catched_by = -1;
  984. ++              game.players[i]->team = game.controller->clampteam(1);
  985. ++              game.controller->on_player_info_change(game.players[i]);
  986. ++          }
  987. ++      }
  988. ++  }
  989. ++  return 0;
  990. ++}
  991. ++
  992. ++void GAMECONTROLLER_ZCATCH::startround()
  993. ++{
  994. ++  resetgame();
  995. ++ 
  996. ++  round_start_tick = server_tick();
  997. ++  sudden_death = 0;
  998. ++  game_over_tick = -1;
  999. ++  game.world.paused = false;
  1000. ++  teamscore[0] = 0;
  1001. ++  teamscore[1] = 0;
  1002. ++  unbalanced_tick = -1;
  1003. ++  force_balanced = false;
  1004. ++  for(int i=0; i<MAX_CLIENTS; i++)
  1005. ++  {
  1006. ++      if(game.players[i])
  1007. ++      {
  1008. ++          game.players[i]->catched_by = -1;
  1009. ++          game.players[i]->team = game.controller->clampteam(1);
  1010. ++          game.controller->on_player_info_change(game.players[i]);
  1011. ++      }
  1012. ++  }
  1013. ++  dbg_msg("game","start round type='%s' teamplay='%d'", gametype, game_flags&GAMEFLAG_TEAMS);
  1014. ++}
  1015. ++
  1016. ++void GAMECONTROLLER_ZCATCH::on_character_spawn(class CHARACTER *chr)
  1017. ++{
  1018. ++  // default health and armor
  1019. ++  chr->health = 10;
  1020. ++  if(config.sv_mode == 2)
  1021. ++      chr->armor = 10;
  1022. ++  // give default weapons
  1023. ++  switch(config.sv_mode)
  1024. ++      {
  1025. ++          case 0:
  1026. ++              chr->weapons[WEAPON_HAMMER].got = 1;
  1027. ++              chr->weapons[WEAPON_HAMMER].ammo = -1;
  1028. ++              chr->weapons[WEAPON_GUN].got = 1;
  1029. ++              chr->weapons[WEAPON_GUN].ammo = 10;
  1030. ++              break;
  1031. ++          case 1:
  1032. ++              chr->weapons[WEAPON_RIFLE].got = 1;
  1033. ++              chr->weapons[WEAPON_RIFLE].ammo = -1;
  1034. ++              break;
  1035. ++          case 2:
  1036. ++              chr->weapons[WEAPON_HAMMER].got = 1;
  1037. ++              chr->weapons[WEAPON_HAMMER].ammo = -1;
  1038. ++              chr->weapons[WEAPON_GUN].got = 1;
  1039. ++              chr->weapons[WEAPON_GUN].ammo = 10;
  1040. ++              chr->weapons[WEAPON_GRENADE].got = 1;
  1041. ++              chr->weapons[WEAPON_GRENADE].ammo = 10;
  1042. ++              chr->weapons[WEAPON_SHOTGUN].got = 1;
  1043. ++              chr->weapons[WEAPON_SHOTGUN].ammo = 10;
  1044. ++              chr->weapons[WEAPON_RIFLE].got = 1;
  1045. ++              chr->weapons[WEAPON_RIFLE].ammo = 10;
  1046. ++              break;
  1047. ++          case 3:
  1048. ++              chr->weapons[WEAPON_HAMMER].got = 1;
  1049. ++              chr->weapons[WEAPON_HAMMER].ammo = -1;
  1050. ++              break;
  1051. ++          }
  1052. ++}
  1053. ++void GAMECONTROLLER_ZCATCH::endround()
  1054. ++{
  1055. ++  for(int i=0; i<MAX_CLIENTS; i++)
  1056. ++  {
  1057. ++      if(game.players[i])
  1058. ++      {
  1059. ++          game.players[i]->catched_by = -1;
  1060. ++          game.players[i]->team = game.controller->clampteam(1);
  1061. ++          game.controller->on_player_info_change(game.players[i]);
  1062. ++      }
  1063. ++  }
  1064. ++ 
  1065. ++  if(warmup) // game can't end when we are running warmup
  1066. ++      return;
  1067. ++     
  1068. ++  game.world.paused = true;
  1069. ++  game_over_tick = server_tick();
  1070. ++  sudden_death = 0;
  1071. ++}
  1072. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.hpp ./zcatch/src/game/server/gamemodes/zcatch.hpp
  1073. +--- ./teeworlds-0.5.2-src/src/game/server/gamemodes/zcatch.hpp 1970-01-01 01:00:00.000000000 +0100
  1074. ++++ ./zcatch/src/game/server/gamemodes/zcatch.hpp  2010-01-07 23:00:20.000000000 +0100
  1075. +@@ -0,0 +1,17 @@
  1076. ++/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
  1077. ++
  1078. ++#include <game/server/gamecontroller.hpp>
  1079. ++
  1080. ++// you can subclass GAMECONTROLLER_CTF, GAMECONTROLLER_TDM etc if you want
  1081. ++// todo a modification with their base as well.
  1082. ++class GAMECONTROLLER_ZCATCH : public GAMECONTROLLER
  1083. ++{
  1084. ++public:
  1085. ++  GAMECONTROLLER_ZCATCH();
  1086. ++  virtual void tick();
  1087. ++  virtual bool is_zcatch() const;
  1088. ++  int on_character_death(class CHARACTER *victim, class PLAYER *killer, int weapon);
  1089. ++  void startround();
  1090. ++  void on_character_spawn(class CHARACTER *chr);
  1091. ++  void endround();
  1092. ++};
  1093. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/hooks.cpp ./zcatch/src/game/server/hooks.cpp
  1094. +--- ./teeworlds-0.5.2-src/src/game/server/hooks.cpp    2009-10-26 19:04:31.000000000 +0100
  1095. ++++ ./zcatch/src/game/server/hooks.cpp 2010-01-08 15:29:25.000000000 +0100
  1096. +@@ -22,6 +22,7 @@
  1097. + #include "gamemodes/tdm.hpp"
  1098. + #include "gamemodes/ctf.hpp"
  1099. + #include "gamemodes/mod.hpp"
  1100. ++#include "gamemodes/zcatch.hpp"
  1101. +
  1102. + TUNING_PARAMS tuning;
  1103. +
  1104. +@@ -111,7 +112,6 @@
  1105. +   game.players[client_id]->respawn();
  1106. +   dbg_msg("game", "join player='%d:%s'", client_id, server_clientname(client_id));
  1107. +
  1108. +-
  1109. +   char buf[512];
  1110. +   str_format(buf, sizeof(buf), "%s entered and joined the %s", server_clientname(client_id), game.controller->get_team_name(game.players[client_id]->team));
  1111. +   game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  1112. +@@ -121,6 +121,7 @@
  1113. +
  1114. + void mods_connected(int client_id)
  1115. + {
  1116. ++  int num = 0;
  1117. +   game.players[client_id] = new(client_id) PLAYER(client_id);
  1118. +   //game.players[client_id].init(client_id);
  1119. +   //game.players[client_id].client_id = client_id;
  1120. +@@ -128,6 +129,25 @@
  1121. +   // Check which team the player should be on
  1122. +   if(config.sv_tournament_mode)
  1123. +       game.players[client_id]->team = -1;
  1124. ++  else if(game.controller->is_zcatch())
  1125. ++  {
  1126. ++      for(int i=0; i<MAX_CLIENTS; i++)
  1127. ++      {
  1128. ++          if(game.players[i])
  1129. ++          {
  1130. ++              num++;
  1131. ++          }
  1132. ++      }
  1133. ++      if(num < 3)
  1134. ++      {
  1135. ++          game.controller->endround();
  1136. ++      }
  1137. ++      else
  1138. ++      {
  1139. ++          game.players[client_id]->catched_by = -2;
  1140. ++          game.players[client_id]->team = -1;
  1141. ++      }
  1142. ++  }
  1143. +   else
  1144. +       game.players[client_id]->team = game.controller->get_auto_team(client_id);
  1145. +      
  1146. +@@ -138,6 +158,12 @@
  1147. +   msg.message = config.sv_motd;
  1148. +   msg.pack(MSGFLAG_VITAL);
  1149. +   server_send_msg(client_id);
  1150. ++  if(game.controller->is_zcatch())
  1151. ++  {
  1152. ++      game.send_chat_target(client_id, "Welcome to zCatch!");
  1153. ++      game.send_chat_target(client_id, "type /cmdlist to get all commands");
  1154. ++      game.send_chat_target(client_id, "type /help for instructions");
  1155. ++  }
  1156. + }
  1157. +
  1158. + void mods_client_drop(int client_id)
  1159. +@@ -195,7 +221,24 @@
  1160. +      
  1161. +       p->last_chat = time_get();
  1162. +      
  1163. +-      game.send_chat(client_id, team, msg->message);
  1164. ++      if(!strcmp("/info", msg->message) || !strcmp("/about", msg->message))
  1165. ++          game.send_chat_target(client_id, "zCatch v.0.2 by erd_baer. Type /help to learn how to play.");
  1166. ++      else if(!strcmp("/cmdlist", msg->message))
  1167. ++      {
  1168. ++          game.send_chat_target(client_id, "/info or /about - see information about author");
  1169. ++          game.send_chat_target(client_id, "/help - learn how to play");
  1170. ++      }
  1171. ++      else if(!strcmp("/help", msg->message))
  1172. ++      {
  1173. ++          game.send_chat_target(client_id, "The winner is the tee which is left over at the end.");
  1174. ++          game.send_chat_target(client_id, "If you die, all players that you killed will respawn.");
  1175. ++          game.send_chat_target(client_id, "So the only way to win is to kill every player without beeing killed.");
  1176. ++          game.send_chat_target(client_id, "Have fun!");
  1177. ++      }
  1178. ++      else if(!strncmp("/", msg->message, 1))
  1179. ++          game.send_chat_target(client_id, "Wrong command.");
  1180. ++      else
  1181. ++       game.send_chat(client_id, team, msg->message);
  1182. +   }
  1183. +   else if(msgtype == NETMSGTYPE_CL_CALLVOTE)
  1184. +   {
  1185. +@@ -256,8 +299,7 @@
  1186. +               game.send_chat_target(client_id, "Invalid client id to kick");
  1187. +               return;
  1188. +           }
  1189. +-         
  1190. +-          str_format(chatmsg, sizeof(chatmsg), "Vote called to kick '%s'", server_clientname(kick_id));
  1191. ++          str_format(chatmsg, sizeof(chatmsg), "%s called vote to kick '%s'", server_clientname(client_id), server_clientname(kick_id));
  1192. +           str_format(desc, sizeof(desc), "Kick '%s'", server_clientname(kick_id));
  1193. +           str_format(cmd, sizeof(cmd), "kick %d", kick_id);
  1194. +           if (!config.sv_vote_kick_bantime)
  1195. +@@ -298,12 +340,35 @@
  1196. +       // Switch team on given client and kill/respawn him
  1197. +       if(game.controller->can_join_team(msg->team, client_id))
  1198. +       {
  1199. +-          if(game.controller->can_change_team(p, msg->team))
  1200. ++          if(game.controller->can_change_team(p, msg->team) && !game.controller->is_zcatch())
  1201. +           {
  1202. +               p->last_setteam = time_get();
  1203. +               p->set_team(msg->team);
  1204. +               (void) game.controller->check_team_balance();
  1205. +           }
  1206. ++          else if(game.controller->is_zcatch())
  1207. ++          {
  1208. ++              if(msg->team == -1)
  1209. ++              {
  1210. ++                  p->last_setteam = time_get();
  1211. ++                  p->set_team(-1);
  1212. ++              }
  1213. ++              else if(p->catched_by == -1 || config.sv_allow_join)
  1214. ++              {
  1215. ++                  p->last_setteam = time_get();
  1216. ++                  p->set_team(msg->team);
  1217. ++              }
  1218. ++              else if(p->catched_by == -2 && !config.sv_allow_join)
  1219. ++              {
  1220. ++                  game.send_chat_target(client_id, "You will join automatically when the next round starts.");
  1221. ++              }
  1222. ++              else if(p->catched_by >= 0)
  1223. ++              {
  1224. ++                  char buf[256];
  1225. ++                  str_format(buf, sizeof(buf), "You will join automatically when \"%s\" dies.", server_clientname(p->catched_by));
  1226. ++                  game.send_chat_target(client_id, buf);
  1227. ++              }
  1228. ++          }
  1229. +           else
  1230. +               game.send_broadcast("Teams must be balanced, please join other team", client_id);
  1231. +       }
  1232. +@@ -537,6 +602,8 @@
  1233. +       game.controller = new GAMECONTROLLER_CTF;
  1234. +   else if(strcmp(config.sv_gametype, "tdm") == 0)
  1235. +       game.controller = new GAMECONTROLLER_TDM;
  1236. ++  else if(strcmp(config.sv_gametype, "zcatch") == 0)
  1237. ++      game.controller = new GAMECONTROLLER_ZCATCH;
  1238. +   else
  1239. +       game.controller = new GAMECONTROLLER_DM;
  1240. +
  1241. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/player.cpp ./zcatch/src/game/server/player.cpp
  1242. +--- ./teeworlds-0.5.2-src/src/game/server/player.cpp   2009-10-26 19:04:31.000000000 +0100
  1243. ++++ ./zcatch/src/game/server/player.cpp    2010-01-08 14:55:09.000000000 +0100
  1244. +@@ -1,6 +1,7 @@
  1245. + #include <new>
  1246. +
  1247. + #include <engine/e_server_interface.h>
  1248. ++#include <engine/e_config.h>
  1249. +
  1250. + #include "player.hpp"
  1251. + #include "gamecontext.hpp"
  1252. +@@ -10,8 +11,10 @@
  1253. + PLAYER::PLAYER(int client_id)
  1254. + {
  1255. +   respawn_tick = server_tick();
  1256. ++  teamchange_tick = server_tick() - config.sv_spec_delay * 50 - 1;
  1257. +   character = 0;
  1258. +   this->client_id = client_id;
  1259. ++  catched_by = -1;
  1260. + }
  1261. +
  1262. + PLAYER::~PLAYER()
  1263. +@@ -22,8 +25,26 @@
  1264. +
  1265. + void PLAYER::tick()
  1266. + {
  1267. ++  int num = 0; int num_inactive = 0;
  1268. +   server_setclientscore(client_id, score);
  1269. +
  1270. ++  if(game.players[client_id]->teamchange_tick + config.sv_spec_delay * 50 == server_tick())
  1271. ++      game.players[client_id]->team = -1;
  1272. ++
  1273. ++  for(int i=0; i<MAX_CLIENTS; i++)
  1274. ++  {
  1275. ++      if(game.players[i])
  1276. ++      {
  1277. ++          num++;
  1278. ++          if(game.players[i]->team == -1)
  1279. ++              num_inactive++;
  1280. ++      }
  1281. ++  }
  1282. ++  if(num - num_inactive < 2)
  1283. ++  {
  1284. ++      game.controller->endround();
  1285. ++  }
  1286. ++ 
  1287. +   // do latency stuff
  1288. +   {
  1289. +       CLIENT_INFO info;
  1290. +@@ -84,6 +105,17 @@
  1291. +
  1292. +   if(client_id == snapping_client)
  1293. +       info->local = 1;   
  1294. ++     
  1295. ++  if(game.players[client_id] && game.controller->is_zcatch() && config.sv_color_indicator)
  1296. ++  {
  1297. ++      int num = 161;
  1298. ++      for(int i=0; i<MAX_CLIENTS; i++)
  1299. ++          if(game.players[i] && game.players[i]->catched_by == client_id)
  1300. ++              num = num - 10;
  1301. ++      client_info->color_body = num * 0x010000 + 0xff00;
  1302. ++      client_info->color_feet = num * 0x010000 + 0xff00;
  1303. ++      client_info->use_custom_color = 1;
  1304. ++  }
  1305. + }
  1306. +
  1307. + void PLAYER::on_disconnect()
  1308. +@@ -97,6 +129,7 @@
  1309. +   game.send_chat(-1, GAMECONTEXT::CHAT_ALL, buf);
  1310. +
  1311. +   dbg_msg("game", "leave player='%d:%s'", client_id, server_clientname(client_id));
  1312. ++ 
  1313. + }
  1314. +
  1315. + void PLAYER::on_predicted_input(NETOBJ_PLAYER_INPUT *new_input)
  1316. +diff -Nur ./teeworlds-0.5.2-src/src/game/server/player.hpp ./zcatch/src/game/server/player.hpp
  1317. +--- ./teeworlds-0.5.2-src/src/game/server/player.hpp   2009-10-26 19:04:31.000000000 +0100
  1318. ++++ ./zcatch/src/game/server/player.hpp    2010-01-07 21:10:15.000000000 +0100
  1319. +@@ -28,6 +28,11 @@
  1320. +   int team;
  1321. +   int score;
  1322. +   bool force_balanced;
  1323. ++
  1324. ++  //
  1325. ++  int catched_by;
  1326. ++  int teamchange_tick;
  1327. ++  int will_change_team;
  1328. +  
  1329. +   //
  1330. +   int vote;
  1331. +diff -Nur ./teeworlds-0.5.2-src/src/game/variables.hpp ./zcatch/src/game/variables.hpp
  1332. +--- ./teeworlds-0.5.2-src/src/game/variables.hpp   2009-10-26 19:04:31.000000000 +0100
  1333. ++++ ./zcatch/src/game/variables.hpp    2010-01-08 14:45:36.000000000 +0100
  1334. +@@ -64,6 +64,10 @@
  1335. + MACRO_CONFIG_INT(sv_vote_kick_bantime, 5, 0, 1440, CFGFLAG_SERVER, "The time to ban a player if kicked by vote. 0 makes it just use kick")
  1336. + MACRO_CONFIG_INT(sv_vote_scorelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change score limit")
  1337. + MACRO_CONFIG_INT(sv_vote_timelimit, 0, 0, 1, CFGFLAG_SERVER, "Allow voting to change time limit")
  1338. ++MACRO_CONFIG_INT(sv_mode, 1, 0, 3, CFGFLAG_SERVER, "0 - normal; 1 - instagib; 2 - rocket area; 3 - Hammerparty")
  1339. ++MACRO_CONFIG_INT(sv_allow_join, 0, 0, 1, CFGFLAG_SERVER, "Allow new players to join without waiting for the next round")
  1340. ++MACRO_CONFIG_INT(sv_spec_delay, 2, 0, 5, CFGFLAG_SERVER, "How many seconds to wait until the player joins the spectators")
  1341. ++MACRO_CONFIG_INT(sv_color_indicator, 0, 0, 1, CFGFLAG_SERVER, "Color tees apropriate to the number of currently catched players")
  1342. +
  1343. + /* debug */
  1344. + #ifdef CONF_DEBUG /* this one can crash the server if not used correctly */
  1345. +Binärdateien ./teeworlds-0.5.2-src/zcatch and ./zcatch/zcatch sind verschieden.
Advertisement
Add Comment
Please, Sign In to add comment