about summary refs log tree commit diff
path: root/src/game/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/server')
-rw-r--r--src/game/server/entities/character.cpp3
-rw-r--r--src/game/server/gamecontroller.cpp81
-rw-r--r--src/game/server/gamecontroller.hpp2
3 files changed, 51 insertions, 35 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index f9e53e61..cc3bf445 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -62,6 +62,9 @@ bool CHARACTER::spawn(PLAYER *player, vec2 pos, int team)
 	
 	game.world.insert_entity(this);
 	alive = true;
+
+	game.controller->on_character_spawn(this);
+
 	return true;
 }
 
diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp
index 4e25ff4e..8dec6795 100644
--- a/src/game/server/gamecontroller.cpp
+++ b/src/game/server/gamecontroller.cpp
@@ -10,6 +10,42 @@
 #include "gamecontroller.hpp"
 #include "gamecontext.hpp"
 
+
+
+GAMECONTROLLER::GAMECONTROLLER()
+{
+	// select gametype
+	if(strcmp(config.sv_gametype, "ctf") == 0)
+	{
+		gametype = GAMETYPE_CTF;
+		dbg_msg("game", "-- Capture The Flag --");
+	}
+	else if(strcmp(config.sv_gametype, "tdm") == 0)
+	{
+		gametype = GAMETYPE_TDM;
+		dbg_msg("game", "-- Team Death Match --");
+	}
+	else
+	{
+		gametype = GAMETYPE_DM;
+		dbg_msg("game", "-- Death Match --");
+	}
+		
+	//
+	do_warmup(config.sv_warmup);
+	game_over_tick = -1;
+	sudden_death = 0;
+	round_start_tick = server_tick();
+	round_count = 0;
+	is_teamplay = false;
+	teamscore[0] = 0;
+	teamscore[1] = 0;
+	
+	num_spawn_points[0] = 0;
+	num_spawn_points[1] = 0;
+	num_spawn_points[2] = 0;
+}
+
 float GAMECONTROLLER::evaluate_spawn_pos(SPAWNEVAL *eval, vec2 pos)
 {
 	float score = 0.0f;
@@ -72,42 +108,10 @@ bool GAMECONTROLLER::can_spawn(PLAYER *player, vec2 *out_pos)
 	}
 	
 	*out_pos = eval.pos;
-	return eval.got;}
-
-GAMECONTROLLER::GAMECONTROLLER()
-{
-	// select gametype
-	if(strcmp(config.sv_gametype, "ctf") == 0)
-	{
-		gametype = GAMETYPE_CTF;
-		dbg_msg("game", "-- Capture The Flag --");
-	}
-	else if(strcmp(config.sv_gametype, "tdm") == 0)
-	{
-		gametype = GAMETYPE_TDM;
-		dbg_msg("game", "-- Team Death Match --");
-	}
-	else
-	{
-		gametype = GAMETYPE_DM;
-		dbg_msg("game", "-- Death Match --");
-	}
-		
-	//
-	do_warmup(config.sv_warmup);
-	game_over_tick = -1;
-	sudden_death = 0;
-	round_start_tick = server_tick();
-	round_count = 0;
-	is_teamplay = false;
-	teamscore[0] = 0;
-	teamscore[1] = 0;
-	
-	num_spawn_points[0] = 0;
-	num_spawn_points[1] = 0;
-	num_spawn_points[2] = 0;
+	return eval.got;
 }
 
+
 bool GAMECONTROLLER::on_entity(int index, vec2 pos)
 {
 	int type = -1;
@@ -301,6 +305,15 @@ int GAMECONTROLLER::on_character_death(class CHARACTER *victim, class PLAYER *ki
 	return 0;
 }
 
+void GAMECONTROLLER::on_character_spawn(class CHARACTER *chr)
+{
+	// give default weapons
+	chr->weapons[WEAPON_HAMMER].got = 1;
+	chr->weapons[WEAPON_HAMMER].ammo = -1;
+	chr->weapons[WEAPON_GUN].got = 1;
+	chr->weapons[WEAPON_GUN].ammo = 10;
+}
+
 void GAMECONTROLLER::do_warmup(int seconds)
 {
 	warmup = seconds*server_tickspeed();
diff --git a/src/game/server/gamecontroller.hpp b/src/game/server/gamecontroller.hpp
index d756768f..9006f985 100644
--- a/src/game/server/gamecontroller.hpp
+++ b/src/game/server/gamecontroller.hpp
@@ -89,7 +89,7 @@ public:
 		Arguments:
 			chr - The character that was spawned.
 	*/
-	virtual void on_character_spawn(class CHARACTER *chr) {}
+	virtual void on_character_spawn(class CHARACTER *chr);
 	
 	/*
 		Function: on_character_death