about summary refs log tree commit diff
path: root/src/game/server/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/server/entities')
-rw-r--r--src/game/server/entities/character.cpp964
-rw-r--r--src/game/server/entities/character.h133
-rw-r--r--src/game/server/entities/character.hpp134
-rw-r--r--src/game/server/entities/laser.cpp130
-rw-r--r--src/game/server/entities/laser.h28
-rw-r--r--src/game/server/entities/laser.hpp31
-rw-r--r--src/game/server/entities/pickup.cpp180
-rw-r--r--src/game/server/entities/pickup.h23
-rw-r--r--src/game/server/entities/pickup.hpp24
-rw-r--r--src/game/server/entities/projectile.cpp145
-rw-r--r--src/game/server/entities/projectile.h30
-rw-r--r--src/game/server/entities/projectile.hpp37
12 files changed, 901 insertions, 958 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index 8ba91a80..839088dd 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -1,838 +1,820 @@
 #include <new>
-#include <engine/e_server_interface.h>
-#include <engine/e_config.h>
-#include <game/server/gamecontext.hpp>
-#include <game/mapitems.hpp>
+#include <engine/shared/config.h>
+#include <game/server/gamecontext.h>
+#include <game/mapitems.h>
 
-#include "character.hpp"
-#include "laser.hpp"
-#include "projectile.hpp"
+#include "character.h"
+#include "laser.h"
+#include "projectile.h"
 
-struct INPUT_COUNT
+//input count
+struct CInputCount
 {
-	int presses;
-	int releases;
+	int m_Presses;
+	int m_Releases;
 };
 
-static INPUT_COUNT count_input(int prev, int cur)
+CInputCount CountInput(int Prev, int Cur)
 {
-	INPUT_COUNT c = {0,0};
-	prev &= INPUT_STATE_MASK;
-	cur &= INPUT_STATE_MASK;
-	int i = prev;
-	while(i != cur)
+	CInputCount c = {0, 0};
+	Prev &= INPUT_STATE_MASK;
+	Cur &= INPUT_STATE_MASK;
+	int i = Prev;
+	
+	while(i != Cur)
 	{
 		i = (i+1)&INPUT_STATE_MASK;
 		if(i&1)
-			c.presses++;
+			c.m_Presses++;
 		else
-			c.releases++;
+			c.m_Releases++;
 	}
 
 	return c;
 }
 
 
-MACRO_ALLOC_POOL_ID_IMPL(CHARACTER, MAX_CLIENTS)
+MACRO_ALLOC_POOL_ID_IMPL(CCharacter, MAX_CLIENTS)
 
-// player
-CHARACTER::CHARACTER()
-: ENTITY(NETOBJTYPE_CHARACTER)
+// Character, "physical" player's part
+CCharacter::CCharacter(CGameWorld *pWorld)
+: CEntity(pWorld, NETOBJTYPE_CHARACTER)
 {
-	proximity_radius = phys_size;
+	m_ProximityRadius = g_CharPhysSize;
+	m_Health = 0;
+	m_Armor = 0;
 }
 
-void CHARACTER::reset()
+void CCharacter::Reset()
 {
-	destroy();
+	Destroy();
 }
 
-bool CHARACTER::spawn(PLAYER *player, vec2 pos, int team)
+bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos)
 {
-	player_state = PLAYERSTATE_UNKNOWN;
-	emote_stop = -1;
-	last_action = -1;
-	active_weapon = WEAPON_GUN;
-	last_weapon = WEAPON_HAMMER;
-	queued_weapon = -1;
+	m_PlayerState = PLAYERSTATE_UNKNOWN;
+	m_EmoteStop = -1;
+	m_LastAction = -1;
+	m_ActiveWeapon = WEAPON_GUN;
+	m_LastWeapon = WEAPON_HAMMER;
+	m_QueuedWeapon = -1;
 	
-	//clear();
-	this->player = player;
-	this->pos = pos;
-	this->team = team;
+	m_pPlayer = pPlayer;
+	m_Pos = Pos;
 	
-	core.reset();
-	core.world = &game.world.core;
-	core.pos = pos;
-	game.world.core.characters[player->client_id] = &core;
-
-	reckoning_tick = 0;
-	mem_zero(&sendcore, sizeof(sendcore));
-	mem_zero(&reckoningcore, sizeof(reckoningcore));
+	m_Core.Reset();
+	m_Core.Init(&GameServer()->m_World.m_Core, GameServer()->Collision());
+	m_Core.m_Pos = m_Pos;
+	GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = &m_Core;
+
+	m_ReckoningTick = 0;
+	mem_zero(&m_SendCore, sizeof(m_SendCore));
+	mem_zero(&m_ReckoningCore, sizeof(m_ReckoningCore));
 	
-	game.world.insert_entity(this);
-	alive = true;
-	player->force_balanced = false;
+	GameServer()->m_World.InsertEntity(this);
+	m_Alive = true;
 
-	game.controller->on_character_spawn(this);
+	GameServer()->m_pController->OnCharacterSpawn(this);
 
 	return true;
 }
 
-void CHARACTER::destroy()
+void CCharacter::Destroy()
 {
-	game.world.core.characters[player->client_id] = 0;
-	alive = false;
+	GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
+	m_Alive = false;
 }
 
-void CHARACTER::set_weapon(int w)
+void CCharacter::SetWeapon(int W)
 {
-	if(w == active_weapon)
+	if(W == m_ActiveWeapon)
 		return;
 		
-	last_weapon = active_weapon;
-	queued_weapon = -1;
-	active_weapon = w;
-	if(active_weapon < 0 || active_weapon >= NUM_WEAPONS)
-		active_weapon = 0;
+	m_LastWeapon = m_ActiveWeapon;
+	m_QueuedWeapon = -1;
+	m_ActiveWeapon = W;
+	GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SWITCH);
 	
-	game.create_sound(pos, SOUND_WEAPON_SWITCH);
+	if(m_ActiveWeapon < 0 || m_ActiveWeapon >= NUM_WEAPONS)
+		m_ActiveWeapon = 0;
 }
 
-bool CHARACTER::is_grounded()
+bool CCharacter::IsGrounded()
 {
-	if(col_check_point((int)(pos.x+phys_size/2), (int)(pos.y+phys_size/2+5)))
+	if(GameServer()->Collision()->CheckPoint(m_Pos.x+g_CharPhysSize/2, m_Pos.y+g_CharPhysSize/2+5))
 		return true;
-	if(col_check_point((int)(pos.x-phys_size/2), (int)(pos.y+phys_size/2+5)))
+	if(GameServer()->Collision()->CheckPoint(m_Pos.x-g_CharPhysSize/2, m_Pos.y+g_CharPhysSize/2+5))
 		return true;
 	return false;
 }
 
 
-int CHARACTER::handle_ninja()
+void CCharacter::HandleNinja()
 {
-	if(active_weapon != WEAPON_NINJA)
-		return 0;
+	if(m_ActiveWeapon != WEAPON_NINJA)
+		return;
 	
-	vec2 direction = normalize(vec2(latest_input.target_x, latest_input.target_y));
+	vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
 
-	if ((server_tick() - ninja.activationtick) > (data->weapons.ninja.duration * server_tickspeed() / 1000))
+	if ((Server()->Tick() - m_Ninja.m_ActivationTick) > (g_pData->m_Weapons.m_Ninja.m_Duration * Server()->TickSpeed() / 1000))
 	{
 		// time's up, return
-		weapons[WEAPON_NINJA].got = false;
-		active_weapon = last_weapon;
-		if(active_weapon == WEAPON_NINJA)
-			active_weapon = WEAPON_GUN;
-		set_weapon(active_weapon);
-		return 0;
+		m_aWeapons[WEAPON_NINJA].m_Got = false;
+		m_ActiveWeapon = m_LastWeapon;
+		if(m_ActiveWeapon == WEAPON_NINJA)
+			m_ActiveWeapon = WEAPON_GUN;
+			
+		SetWeapon(m_ActiveWeapon);
+		return;
 	}
 	
-	// force ninja weapon
-	set_weapon(WEAPON_NINJA);
+	// force ninja Weapon
+	SetWeapon(WEAPON_NINJA);
 
-	ninja.currentmovetime--;
+	m_Ninja.m_CurrentMoveTime--;
 
-	if (ninja.currentmovetime == 0)
+	if (m_Ninja.m_CurrentMoveTime == 0)
 	{
-		// reset player velocity
-		core.vel *= 0.2f;
-		//return MODIFIER_RETURNFLAGS_OVERRIDEWEAPON;
+		// reset velocity
+		m_Core.m_Vel *= 0.2f;
 	}
 
-	if (ninja.currentmovetime > 0)
+	if (m_Ninja.m_CurrentMoveTime > 0)
 	{
-		// Set player velocity
-		core.vel = ninja.activationdir * data->weapons.ninja.velocity;
-		vec2 oldpos = pos;
-		move_box(&core.pos, &core.vel, vec2(phys_size, phys_size), 0.0f);
+		// Set velocity
+		m_Core.m_Vel = m_Ninja.m_ActivationDir * g_pData->m_Weapons.m_Ninja.m_Velocity;
+		vec2 OldPos = m_Pos;
+		GameServer()->Collision()->MoveBox(&m_Core.m_Pos, &m_Core.m_Vel, vec2(g_CharPhysSize, g_CharPhysSize), 0.f);
+		
 		// reset velocity so the client doesn't predict stuff
-		core.vel = vec2(0.0f,0.0f);
-		if ((ninja.currentmovetime % 2) == 0)
-		{
-			//create_smoke(pos);
-		}
+		m_Core.m_Vel = vec2(0.f, 0.f);
 
-		// check if we hit anything along the way
+		// check if we Hit anything along the way
 		{
-			CHARACTER *ents[64];
-			vec2 dir = pos - oldpos;
-			float radius = phys_size * 2.0f; //length(dir * 0.5f);
-			vec2 center = oldpos + dir * 0.5f;
-			int num = game.world.find_entities(center, radius, (ENTITY**)ents, 64, NETOBJTYPE_CHARACTER);
+			CCharacter *aEnts[64];
+			vec2 Dir = m_Pos - OldPos;
+			float Radius = g_CharPhysSize * 2.0f;
+			vec2 Center = OldPos + Dir * 0.5f;
+			int Num = GameServer()->m_World.FindEntities(Center, Radius, (CEntity**)aEnts, 64, NETOBJTYPE_CHARACTER);
 
-			for (int i = 0; i < num; i++)
+			for (int i = 0; i < Num; ++i)
 			{
-				// Check if entity is a player
-				if (ents[i] == this)
+				if (aEnts[i] == this)
 					continue;
-				// make sure we haven't hit this object before
-				bool balreadyhit = false;
-				for (int j = 0; j < numobjectshit; j++)
+					
+				// make sure we haven't Hit this object before
+				bool bAlreadyHit = false;
+				for (int j = 0; j < m_NumObjectsHit; j++)
 				{
-					if (hitobjects[j] == ents[i])
-						balreadyhit = true;
+					if (m_apHitObjects[j] == aEnts[i])
+						bAlreadyHit = true;
 				}
-				if (balreadyhit)
+				if (bAlreadyHit)
 					continue;
 
 				// check so we are sufficiently close
-				if (distance(ents[i]->pos, pos) > (phys_size * 2.0f))
+				if (distance(aEnts[i]->m_Pos, m_Pos) > (g_CharPhysSize * 2.0f))
 					continue;
 
-				// hit a player, give him damage and stuffs...
-				game.create_sound(ents[i]->pos, SOUND_NINJA_HIT);
+				// Hit a player, give him damage and stuffs...
+				GameServer()->CreateSound(aEnts[i]->m_Pos, SOUND_NINJA_HIT);
 				// set his velocity to fast upward (for now)
-				if(numobjectshit < 10)
-					hitobjects[numobjectshit++] = ents[i];
+				if(m_NumObjectsHit < 10)
+					m_apHitObjects[m_NumObjectsHit++] = aEnts[i];
 					
-				ents[i]->take_damage(vec2(0,10.0f), data->weapons.ninja.base->damage, player->client_id,WEAPON_NINJA);
+				aEnts[i]->TakeDamage(vec2(0, 10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA);
 			}
 		}
-		return 0;
+		
+		return;
 	}
 
-	return 0;
+	return;
 }
 
 
-void CHARACTER::do_weaponswitch()
+void CCharacter::DoWeaponSwitch()
 {
-	if(reload_timer != 0) // make sure we have reloaded
-		return;
-		
-	if(queued_weapon == -1) // check for a queued weapon
+	// make sure we can switch
+	if(m_ReloadTimer != 0 || m_QueuedWeapon == -1 || m_aWeapons[WEAPON_NINJA].m_Got)
 		return;
 
-	if(weapons[WEAPON_NINJA].got) // if we have ninja, no weapon selection is possible
-		return;
-
-	// switch weapon
-	set_weapon(queued_weapon);
+	// switch Weapon
+	SetWeapon(m_QueuedWeapon);
 }
 
-void CHARACTER::handle_weaponswitch()
+void CCharacter::HandleWeaponSwitch()
 {
-	int wanted_weapon = active_weapon;
-	if(queued_weapon != -1)
-		wanted_weapon = queued_weapon;
+	int WantedWeapon = m_ActiveWeapon;
+	if(m_QueuedWeapon != -1)
+		WantedWeapon = m_QueuedWeapon;
 	
-	// select weapon
-	int next = count_input(latest_previnput.next_weapon, latest_input.next_weapon).presses;
-	int prev = count_input(latest_previnput.prev_weapon, latest_input.prev_weapon).presses;
+	// select Weapon
+	int Next = CountInput(m_LatestPrevInput.m_NextWeapon, m_LatestInput.m_NextWeapon).m_Presses;
+	int Prev = CountInput(m_LatestPrevInput.m_PrevWeapon, m_LatestInput.m_PrevWeapon).m_Presses;
 
-	if(next < 128) // make sure we only try sane stuff
+	if(Next < 128) // make sure we only try sane stuff
 	{
-		while(next) // next weapon selection
+		while(Next) // Next Weapon selection
 		{
-			wanted_weapon = (wanted_weapon+1)%NUM_WEAPONS;
-			if(weapons[wanted_weapon].got)
-				next--;
+			WantedWeapon = (WantedWeapon+1)%NUM_WEAPONS;
+			if(m_aWeapons[WantedWeapon].m_Got)
+				Next--;
 		}
 	}
 
-	if(prev < 128) // make sure we only try sane stuff
+	if(Prev < 128) // make sure we only try sane stuff
 	{
-		while(prev) // prev weapon selection
+		while(Prev) // Prev Weapon selection
 		{
-			wanted_weapon = (wanted_weapon-1)<0?NUM_WEAPONS-1:wanted_weapon-1;
-			if(weapons[wanted_weapon].got)
-				prev--;
+			WantedWeapon = (WantedWeapon-1)<0?NUM_WEAPONS-1:WantedWeapon-1;
+			if(m_aWeapons[WantedWeapon].m_Got)
+				Prev--;
 		}
 	}
 
-	// direct weapon selection
-	if(latest_input.wanted_weapon)
-		wanted_weapon = input.wanted_weapon-1;
+	// Direct Weapon selection
+	if(m_LatestInput.m_WantedWeapon)
+		WantedWeapon = m_Input.m_WantedWeapon-1;
 
 	// check for insane values
-	if(wanted_weapon >= 0 && wanted_weapon < NUM_WEAPONS && wanted_weapon != active_weapon && weapons[wanted_weapon].got)
-		queued_weapon = wanted_weapon;
+	if(WantedWeapon >= 0 && WantedWeapon < NUM_WEAPONS && WantedWeapon != m_ActiveWeapon && m_aWeapons[WantedWeapon].m_Got)
+		m_QueuedWeapon = WantedWeapon;
 	
-	do_weaponswitch();
+	DoWeaponSwitch();
 }
 
-void CHARACTER::fire_weapon()
+void CCharacter::FireWeapon()
 {
-	if(reload_timer != 0)
+	if(m_ReloadTimer != 0)
 		return;
 		
-	do_weaponswitch();
+	DoWeaponSwitch();
+	vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
 	
-	vec2 direction = normalize(vec2(latest_input.target_x, latest_input.target_y));
-	
-	bool fullauto = false;
-	if(active_weapon == WEAPON_GRENADE || active_weapon == WEAPON_SHOTGUN || active_weapon == WEAPON_RIFLE)
-		fullauto = true;
+	bool FullAuto = false;
+	if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE)
+		FullAuto = true;
 
 
 	// check if we gonna fire
-	bool will_fire = false;
-	if(count_input(latest_previnput.fire, latest_input.fire).presses) will_fire = true;
-	if(fullauto && (latest_input.fire&1) && weapons[active_weapon].ammo) will_fire = true;
-	if(!will_fire)
+	bool WillFire = false;
+	if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses)
+		WillFire = true;
+		
+	if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo)
+		WillFire = true;
+		
+	if(!WillFire)
 		return;
 		
 	// check for ammo
-	if(!weapons[active_weapon].ammo)
+	if(!m_aWeapons[m_ActiveWeapon].m_Ammo)
 	{
 		// 125ms is a magical limit of how fast a human can click
-		reload_timer = 125 * server_tickspeed() / 1000;;
-		game.create_sound(pos, SOUND_WEAPON_NOAMMO);
+		m_ReloadTimer = 125 * Server()->TickSpeed() / 1000;
+		GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO);
 		return;
 	}
 	
-	vec2 projectile_startpos = pos+direction*phys_size*0.75f;
+	vec2 ProjStartPos = m_Pos+Direction*g_CharPhysSize*0.75f;
 	
-	switch(active_weapon)
+	switch(m_ActiveWeapon)
 	{
 		case WEAPON_HAMMER:
 		{
-			// reset objects hit
-			numobjectshit = 0;
-			game.create_sound(pos, SOUND_HAMMER_FIRE);
+			// reset objects Hit
+			m_NumObjectsHit = 0;
+			GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);
 			
-			CHARACTER *ents[64];
-			int hits = 0;
-			int num = game.world.find_entities(pos+direction*phys_size*0.75f, phys_size*0.5f, (ENTITY**)ents, 64, NETOBJTYPE_CHARACTER);
+			CCharacter *aEnts[64];
+			int Hits = 0;
+			int Num = GameServer()->m_World.FindEntities(ProjStartPos, g_CharPhysSize*0.5f, (CEntity**)aEnts, 
+			64, NETOBJTYPE_CHARACTER);
 
-			for (int i = 0; i < num; i++)
+			for (int i = 0; i < Num; ++i)
 			{
-				CHARACTER *target = ents[i];
-				if (target == this)
+				CCharacter *Target = aEnts[i];
+				
+				//for race mod or any other mod, which needs hammer hits through the wall remove second condition
+				if ((Target == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, Target->m_Pos, NULL, NULL))
 					continue;
-					
-				// hit a player, give him damage and stuffs...
-				vec2 fdir = normalize(ents[i]->pos - pos);
 
 				// set his velocity to fast upward (for now)
-				game.create_hammerhit(pos);
-				ents[i]->take_damage(vec2(0,-1.0f), data->weapons.hammer.base->damage, player->client_id, active_weapon);
-				vec2 dir;
-				if (length(target->pos - pos) > 0.0f)
-					dir = normalize(target->pos - pos);
+				GameServer()->CreateHammerHit(m_Pos);
+				aEnts[i]->TakeDamage(vec2(0.f, -1.f), g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon);
+				
+				vec2 Dir;
+				if (length(Target->m_Pos - m_Pos) > 0.0f)
+					Dir = normalize(Target->m_Pos - m_Pos);
 				else
-					dir = vec2(0,-1);
+					Dir = vec2(0.f, -1.f);
 					
-				target->core.vel += normalize(dir + vec2(0,-1.1f)) * 10.0f;
-				hits++;
+				Target->m_Core.m_Vel += normalize(Dir + vec2(0.f, -1.1f)) * 10.0f;
+				Hits++;
 			}
 			
-			// if we hit anything, we have to wait for the reload
-			if(hits)
-				reload_timer = server_tickspeed()/3;
+			// if we Hit anything, we have to wait for the reload
+			if(Hits)
+				m_ReloadTimer = Server()->TickSpeed()/3;
 			
 		} break;
 
 		case WEAPON_GUN:
 		{
-			PROJECTILE *proj = new PROJECTILE(WEAPON_GUN,
-				player->client_id,
-				projectile_startpos,
-				direction,
-				(int)(server_tickspeed()*tuning.gun_lifetime),
+			CProjectile *Proj = new CProjectile(GameWorld(), WEAPON_GUN,
+				m_pPlayer->GetCID(),
+				ProjStartPos,
+				Direction,
+				(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
 				1, 0, 0, -1, WEAPON_GUN);
 				
-			// pack the projectile and send it to the client directly
-			NETOBJ_PROJECTILE p;
-			proj->fill_info(&p);
+			// pack the Projectile and send it to the client Directly
+			CNetObj_Projectile p;
+			Proj->FillInfo(&p);
 			
-			msg_pack_start(NETMSGTYPE_SV_EXTRAPROJECTILE, 0);
-			msg_pack_int(1);
-			for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
-				msg_pack_int(((int *)&p)[i]);
-			msg_pack_end();
-			server_send_msg(player->client_id);
-							
-			game.create_sound(pos, SOUND_GUN_FIRE);
+			CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
+			Msg.AddInt(1);
+			for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
+				Msg.AddInt(((int *)&p)[i]);
+				
+			Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
+	
+			GameServer()->CreateSound(m_Pos, SOUND_GUN_FIRE);
 		} break;
 		
 		case WEAPON_SHOTGUN:
 		{
-			int shotspread = 2;
+			int ShotSpread = 2;
 
-			msg_pack_start(NETMSGTYPE_SV_EXTRAPROJECTILE, 0);
-			msg_pack_int(shotspread*2+1);
+			CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
+			Msg.AddInt(ShotSpread*2+1);
 			
-			for(int i = -shotspread; i <= shotspread; i++)
+			for(int i = -ShotSpread; i <= ShotSpread; ++i)
 			{
-				float spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
-				float a = get_angle(direction);
-				a += spreading[i+2];
-				float v = 1-(abs(i)/(float)shotspread);
-				float speed = mix((float)tuning.shotgun_speeddiff, 1.0f, v);
-				PROJECTILE *proj = new PROJECTILE(WEAPON_SHOTGUN,
-					player->client_id,
-					projectile_startpos,
-					vec2(cosf(a), sinf(a))*speed,
-					(int)(server_tickspeed()*tuning.shotgun_lifetime),
+				float Spreading[] = {-0.185f, -0.070f, 0, 0.070f, 0.185f};
+				float a = GetAngle(Direction);
+				a += Spreading[i+2];
+				float v = 1-(absolute(i)/(float)ShotSpread);
+				float Speed = mix((float)GameServer()->Tuning()->m_ShotgunSpeeddiff, 1.0f, v);
+				CProjectile *Proj = new CProjectile(GameWorld(), WEAPON_SHOTGUN,
+					m_pPlayer->GetCID(),
+					ProjStartPos,
+					vec2(cosf(a), sinf(a))*Speed,
+					(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_ShotgunLifetime),
 					1, 0, 0, -1, WEAPON_SHOTGUN);
 					
-				// pack the projectile and send it to the client directly
-				NETOBJ_PROJECTILE p;
-				proj->fill_info(&p);
+				// pack the Projectile and send it to the client Directly
+				CNetObj_Projectile p;
+				Proj->FillInfo(&p);
 				
-				for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
-					msg_pack_int(((int *)&p)[i]);
+				for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
+					Msg.AddInt(((int *)&p)[i]);
 			}
 
-			msg_pack_end();
-			server_send_msg(player->client_id);					
+			Server()->SendMsg(&Msg, 0,m_pPlayer->GetCID());					
 			
-			game.create_sound(pos, SOUND_SHOTGUN_FIRE);
+			GameServer()->CreateSound(m_Pos, SOUND_SHOTGUN_FIRE);
 		} break;
 
 		case WEAPON_GRENADE:
 		{
-			PROJECTILE *proj = new PROJECTILE(WEAPON_GRENADE,
-				player->client_id,
-				projectile_startpos,
-				direction,
-				(int)(server_tickspeed()*tuning.grenade_lifetime),
-				1, PROJECTILE::PROJECTILE_FLAGS_EXPLODE, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);
-
-			// pack the projectile and send it to the client directly
-			NETOBJ_PROJECTILE p;
-			proj->fill_info(&p);
+			CProjectile *Proj = new CProjectile(GameWorld(), WEAPON_GRENADE,
+				m_pPlayer->GetCID(),
+				ProjStartPos,
+				Direction,
+				(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GrenadeLifetime),
+				1, true, 0, SOUND_GRENADE_EXPLODE, WEAPON_GRENADE);
+
+			// pack the Projectile and send it to the client Directly
+			CNetObj_Projectile p;
+			Proj->FillInfo(&p);
+			
+			CMsgPacker Msg(NETMSGTYPE_SV_EXTRAPROJECTILE);
+			Msg.AddInt(1);
+			for(unsigned i = 0; i < sizeof(CNetObj_Projectile)/sizeof(int); i++)
+				Msg.AddInt(((int *)&p)[i]);
+			Server()->SendMsg(&Msg, 0, m_pPlayer->GetCID());
 			
-			msg_pack_start(NETMSGTYPE_SV_EXTRAPROJECTILE, 0);
-			msg_pack_int(1);
-			for(unsigned i = 0; i < sizeof(NETOBJ_PROJECTILE)/sizeof(int); i++)
-				msg_pack_int(((int *)&p)[i]);
-			msg_pack_end();
-			server_send_msg(player->client_id);
-
-			game.create_sound(pos, SOUND_GRENADE_FIRE);
+			GameServer()->CreateSound(m_Pos, SOUND_GRENADE_FIRE);
 		} break;
 		
 		case WEAPON_RIFLE:
 		{
-			new LASER(pos, direction, tuning.laser_reach, player->client_id);
-			game.create_sound(pos, SOUND_RIFLE_FIRE);
+			new CLaser(GameWorld(), m_Pos, Direction, GameServer()->Tuning()->m_LaserReach, m_pPlayer->GetCID());
+			GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
 		} break;
 		
 		case WEAPON_NINJA:
 		{
-			attack_tick = server_tick();
-			ninja.activationdir = direction;
-			ninja.currentmovetime = data->weapons.ninja.movetime * server_tickspeed() / 1000;
-
-			//reload_timer = data->weapons.ninja.base->firedelay * server_tickspeed() / 1000 + server_tick();
+			// reset Hit objects
+			m_NumObjectsHit = 0;
 			
-			// reset hit objects
-			numobjectshit = 0;
+			m_AttackTick = Server()->Tick();
+			m_Ninja.m_ActivationDir = Direction;
+			m_Ninja.m_CurrentMoveTime = g_pData->m_Weapons.m_Ninja.m_Movetime * Server()->TickSpeed() / 1000;
 
-			game.create_sound(pos, SOUND_NINJA_FIRE);
-			
+			GameServer()->CreateSound(m_Pos, SOUND_NINJA_FIRE);
 		} break;
 		
 	}
-
-	if(weapons[active_weapon].ammo > 0) // -1 == unlimited
-		weapons[active_weapon].ammo--;
-	attack_tick = server_tick();
-	if(!reload_timer)
-		reload_timer = data->weapons.id[active_weapon].firedelay * server_tickspeed() / 1000;
+	
+	m_AttackTick = Server()->Tick();
+	
+	if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0) // -1 == unlimited
+		m_aWeapons[m_ActiveWeapon].m_Ammo--;
+	
+	if(!m_ReloadTimer)
+		m_ReloadTimer = g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Firedelay * Server()->TickSpeed() / 1000;
 }
 
-int CHARACTER::handle_weapons()
+void CCharacter::HandleWeapons()
 {
-	vec2 direction = normalize(vec2(latest_input.target_x, latest_input.target_y));
-
-	/*
-	if(config.dbg_stress)
-	{
-		for(int i = 0; i < NUM_WEAPONS; i++)
-		{
-			weapons[i].got = true;
-			weapons[i].ammo = 10;
-		}
-
-		if(reload_timer) // twice as fast reload
-			reload_timer--;
-	} */
-
-	//if(active_weapon == WEAPON_NINJA)
-	handle_ninja();
-
+	//ninja
+	HandleNinja();
+	
+	vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));
 
 	// check reload timer
-	if(reload_timer)
+	if(m_ReloadTimer)
 	{
-		reload_timer--;
-		return 0;
+		m_ReloadTimer--;
+		return;
 	}
-	
-	/*
-	if (active_weapon == WEAPON_NINJA)
-	{
-		// don't update other weapons while ninja is active
-		return handle_ninja();
-	}*/
 
-	// fire weapon, if wanted
-	fire_weapon();
+	// fire Weapon, if wanted
+	FireWeapon();
 
 	// ammo regen
-	int ammoregentime = data->weapons.id[active_weapon].ammoregentime;
-	if(ammoregentime)
+	int AmmoRegenTime = g_pData->m_Weapons.m_aId[m_ActiveWeapon].m_Ammoregentime;
+	if(AmmoRegenTime)
 	{
 		// If equipped and not active, regen ammo?
-		if (reload_timer <= 0)
+		if (m_ReloadTimer <= 0)
 		{
-			if (weapons[active_weapon].ammoregenstart < 0)
-				weapons[active_weapon].ammoregenstart = server_tick();
+			if (m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart < 0)
+				m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = Server()->Tick();
 
-			if ((server_tick() - weapons[active_weapon].ammoregenstart) >= ammoregentime * server_tickspeed() / 1000)
+			if ((Server()->Tick() - m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart) >= AmmoRegenTime * Server()->TickSpeed() / 1000)
 			{
 				// Add some ammo
-				weapons[active_weapon].ammo = min(weapons[active_weapon].ammo + 1, 10);
-				weapons[active_weapon].ammoregenstart = -1;
+				m_aWeapons[m_ActiveWeapon].m_Ammo = min(m_aWeapons[m_ActiveWeapon].m_Ammo + 1, 10);
+				m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1;
 			}
 		}
 		else
 		{
-			weapons[active_weapon].ammoregenstart = -1;
+			m_aWeapons[m_ActiveWeapon].m_AmmoRegenStart = -1;
 		}
 	}
 	
-	return 0;
+	return;
+}
+
+bool CCharacter::GiveWeapon(int Weapon, int Ammo)
+{
+	if(m_aWeapons[Weapon].m_Ammo < g_pData->m_Weapons.m_aId[Weapon].m_Maxammo || !m_aWeapons[Weapon].m_Got)
+	{	
+		m_aWeapons[Weapon].m_Got = true;
+		m_aWeapons[Weapon].m_Ammo = min(g_pData->m_Weapons.m_aId[Weapon].m_Maxammo, Ammo);
+		return true;
+	}
+	return false;
+}
+
+void CCharacter::GiveNinja()
+{
+	m_Ninja.m_ActivationTick = Server()->Tick();
+	m_aWeapons[WEAPON_NINJA].m_Got = true;
+	m_aWeapons[WEAPON_NINJA].m_Ammo = -1;
+	m_LastWeapon = m_ActiveWeapon;
+	m_ActiveWeapon = WEAPON_NINJA;
+	
+	GameServer()->CreateSound(m_Pos, SOUND_PICKUP_NINJA);
 }
 
-void CHARACTER::on_predicted_input(NETOBJ_PLAYER_INPUT *new_input)
+void CCharacter::SetEmote(int Emote, int Tick)
+{
+	m_EmoteType = Emote;
+	m_EmoteStop = Tick;
+}
+
+void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
 {
 	// check for changes
-	if(mem_comp(&input, new_input, sizeof(NETOBJ_PLAYER_INPUT)) != 0)
-		last_action = server_tick();
+	if(mem_comp(&m_Input, pNewInput, sizeof(CNetObj_PlayerInput)) != 0)
+		m_LastAction = Server()->Tick();
 		
 	// copy new input
-	mem_copy(&input, new_input, sizeof(input));
-	num_inputs++;
+	mem_copy(&m_Input, pNewInput, sizeof(m_Input));
+	m_NumInputs++;
 	
 	// or are not allowed to aim in the center
-	if(input.target_x == 0 && input.target_y == 0)
-		input.target_y = -1;	
+	if(m_Input.m_TargetX == 0 && m_Input.m_TargetY == 0)
+		m_Input.m_TargetY = -1;	
 }
 
-void CHARACTER::on_direct_input(NETOBJ_PLAYER_INPUT *new_input)
+void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
 {
-	mem_copy(&latest_previnput, &latest_input, sizeof(latest_input));
-	mem_copy(&latest_input, new_input, sizeof(latest_input));
+	mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
+	mem_copy(&m_LatestInput, pNewInput, sizeof(m_LatestInput));
 	
-	if(num_inputs > 2 && team != -1)
+	if(m_NumInputs > 2 && m_pPlayer->GetTeam() != -1)
 	{
-		handle_weaponswitch();
-		fire_weapon();
+		HandleWeaponSwitch();
+		FireWeapon();
 	}
 	
-	mem_copy(&latest_previnput, &latest_input, sizeof(latest_input));
+	mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput));
 }
 
-void CHARACTER::tick()
+void CCharacter::Tick()
 {
-	if(player->force_balanced)
+	if(m_pPlayer->m_ForceBalanced)
 	{
-		char buf[128];
-		str_format(buf, sizeof(buf), "You were moved to %s due to team balancing", game.controller->get_team_name(team));
-		game.send_broadcast(buf, player->client_id);
+		char Buf[128];
+		str_format(Buf, sizeof(Buf), "You were moved to %s due to team balancing", GameServer()->m_pController->GetTeamName(m_pPlayer->GetTeam()));
+		GameServer()->SendBroadcast(Buf, m_pPlayer->GetCID());
 		
-		player->force_balanced = false;
+		m_pPlayer->m_ForceBalanced = false;
 	}
 
-	//player_core core;
-	//core.pos = pos;
-	//core.jumped = jumped;
-	core.input = input;
-	core.tick(true);
+	m_Core.m_Input = m_Input;
+	m_Core.Tick(true);
 	
-	float phys_size = 28.0f;
 	// handle death-tiles
-	if(col_get((int)(pos.x+phys_size/3), (int)(pos.y-phys_size/3))&COLFLAG_DEATH ||
-			col_get((int)(pos.x+phys_size/3), (int)(pos.y+phys_size/3))&COLFLAG_DEATH ||
-			col_get((int)(pos.x-phys_size/3), (int)(pos.y-phys_size/3))&COLFLAG_DEATH ||
-			col_get((int)(pos.x-phys_size/3), (int)(pos.y+phys_size/3))&COLFLAG_DEATH)
+	if(GameServer()->Collision()->GetCollisionAt(m_Pos.x+g_CharPhysSize/3.f, m_Pos.y-g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH ||
+		GameServer()->Collision()->GetCollisionAt(m_Pos.x+g_CharPhysSize/3.f, m_Pos.y+g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH ||
+		GameServer()->Collision()->GetCollisionAt(m_Pos.x-g_CharPhysSize/3.f, m_Pos.y-g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH ||
+		GameServer()->Collision()->GetCollisionAt(m_Pos.x-g_CharPhysSize/3.f, m_Pos.y+g_CharPhysSize/3.f)&CCollision::COLFLAG_DEATH)
 	{
-		die(player->client_id, WEAPON_WORLD);
+		Die(m_pPlayer->GetCID(), WEAPON_WORLD);
 	}
 
-	// handle weapons
-	handle_weapons();
+	// handle Weapons
+	HandleWeapons();
 
-	player_state = input.player_state;
+	m_PlayerState = m_Input.m_PlayerState;
 
 	// Previnput
-	previnput = input;
+	m_PrevInput = m_Input;
 	return;
 }
 
-void CHARACTER::tick_defered()
+void CCharacter::TickDefered()
 {
 	// advance the dummy
 	{
-		WORLD_CORE tempworld;
-		reckoningcore.world = &tempworld;
-		reckoningcore.tick(false);
-		reckoningcore.move();
-		reckoningcore.quantize();
+		CWorldCore TempWorld;
+		m_ReckoningCore.Init(&TempWorld, GameServer()->Collision());
+		m_ReckoningCore.Tick(false);
+		m_ReckoningCore.Move();
+		m_ReckoningCore.Quantize();
 	}
 	
-	//lastsentcore;
-	/*if(!dead)
-	{*/
-		vec2 start_pos = core.pos;
-		vec2 start_vel = core.vel;
-		bool stuck_before = test_box(core.pos, vec2(28.0f, 28.0f));
-		
-		core.move();
-		bool stuck_after_move = test_box(core.pos, vec2(28.0f, 28.0f));
-		core.quantize();
-		bool stuck_after_quant = test_box(core.pos, vec2(28.0f, 28.0f));
-		pos = core.pos;
-		
-		if(!stuck_before && (stuck_after_move || stuck_after_quant))
-		{
-			dbg_msg("player", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", 
-				stuck_before,
-				stuck_after_move,
-				stuck_after_quant,
-				start_pos.x, start_pos.y,
-				start_vel.x, start_vel.y,
-				*((unsigned *)&start_pos.x), *((unsigned *)&start_pos.y),
-				*((unsigned *)&start_vel.x), *((unsigned *)&start_vel.y));
-		}
+	//lastsentcore
+	vec2 StartPos = m_Core.m_Pos;
+	vec2 StartVel = m_Core.m_Vel;
+	bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
+	
+	m_Core.Move();
+	bool StuckAfterMove = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
+	m_Core.Quantize();
+	bool StuckAfterQuant = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));
+	m_Pos = m_Core.m_Pos;
+	
+	if(!StuckBefore && (StuckAfterMove || StuckAfterQuant))
+	{
+		dbg_msg("char_core", "STUCK!!! %d %d %d %f %f %f %f %x %x %x %x", 
+			StuckBefore,
+			StuckAfterMove,
+			StuckAfterQuant,
+			StartPos.x, StartPos.y,
+			StartVel.x, StartVel.y,
+			*((unsigned *)&StartPos.x), *((unsigned *)&StartPos.y),
+			*((unsigned *)&StartVel.x), *((unsigned *)&StartVel.y));
+	}
 
-		int events = core.triggered_events;
-		int mask = cmask_all_except_one(player->client_id);
-		
-		if(events&COREEVENT_GROUND_JUMP) game.create_sound(pos, SOUND_PLAYER_JUMP, mask);
-		
-		//if(events&COREEVENT_HOOK_LAUNCH) snd_play_random(CHN_WORLD, SOUND_HOOK_LOOP, 1.0f, pos);
-		if(events&COREEVENT_HOOK_ATTACH_PLAYER) game.create_sound(pos, SOUND_HOOK_ATTACH_PLAYER, cmask_all());
-		if(events&COREEVENT_HOOK_ATTACH_GROUND) game.create_sound(pos, SOUND_HOOK_ATTACH_GROUND, mask);
-		if(events&COREEVENT_HOOK_HIT_NOHOOK) game.create_sound(pos, SOUND_HOOK_NOATTACH, mask);
-		//if(events&COREEVENT_HOOK_RETRACT) snd_play_random(CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, pos);
-	//}
-	
-	if(team == -1)
+	int Events = m_Core.m_TriggeredEvents;
+	int Mask = CmaskAllExceptOne(m_pPlayer->GetCID());
+	
+	if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Mask);
+	
+	if(Events&COREEVENT_HOOK_ATTACH_PLAYER) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, CmaskAll());
+	if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Mask);
+	if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Mask);
+
+	
+	if(m_pPlayer->GetTeam() == -1)
 	{
-		pos.x = input.target_x;
-		pos.y = input.target_y;
+		m_Pos.x = m_Input.m_TargetX;
+		m_Pos.y = m_Input.m_TargetY;
 	}
 	
-	// update the sendcore if needed
+	// update the m_SendCore if needed
 	{
-		NETOBJ_CHARACTER predicted;
-		NETOBJ_CHARACTER current;
-		mem_zero(&predicted, sizeof(predicted));
-		mem_zero(&current, sizeof(current));
-		reckoningcore.write(&predicted);
-		core.write(&current);
+		CNetObj_Character Predicted;
+		CNetObj_Character Current;
+		mem_zero(&Predicted, sizeof(Predicted));
+		mem_zero(&Current, sizeof(Current));
+		m_ReckoningCore.Write(&Predicted);
+		m_Core.Write(&Current);
 
 		// only allow dead reackoning for a top of 3 seconds
-		if(reckoning_tick+server_tickspeed()*3 < server_tick() || mem_comp(&predicted, &current, sizeof(NETOBJ_CHARACTER)) != 0)
+		if(m_ReckoningTick+Server()->TickSpeed()*3 < Server()->Tick() || mem_comp(&Predicted, &Current, sizeof(CNetObj_Character)) != 0)
 		{
-			reckoning_tick = server_tick();
-			sendcore = core;
-			reckoningcore = core;
+			m_ReckoningTick = Server()->Tick();
+			m_SendCore = m_Core;
+			m_ReckoningCore = m_Core;
 		}
 	}
 }
 
-bool CHARACTER::increase_health(int amount)
+bool CCharacter::IncreaseHealth(int Amount)
 {
-	if(health >= 10)
+	if(m_Health >= 10)
 		return false;
-	health = clamp(health+amount, 0, 10);
+	m_Health = clamp(m_Health+Amount, 0, 10);
 	return true;
 }
 
-bool CHARACTER::increase_armor(int amount)
+bool CCharacter::IncreaseArmor(int Amount)
 {
-	if(armor >= 10)
+	if(m_Armor >= 10)
 		return false;
-	armor = clamp(armor+amount, 0, 10);
+	m_Armor = clamp(m_Armor+Amount, 0, 10);
 	return true;
 }
 
-void CHARACTER::die(int killer, int weapon)
+void CCharacter::Die(int Killer, int Weapon)
 {
-	/*if (dead || team == -1)
-		return;*/
-	int mode_special = game.controller->on_character_death(this, game.players[killer], weapon);
+	int ModeSpecial = GameServer()->m_pController->OnCharacterDeath(this, GameServer()->m_apPlayers[Killer], Weapon);
 
 	dbg_msg("game", "kill killer='%d:%s' victim='%d:%s' weapon=%d special=%d",
-		killer, server_clientname(killer),
-		player->client_id, server_clientname(player->client_id), weapon, mode_special);
+		Killer, Server()->ClientName(Killer),
+		m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial);
 
 	// send the kill message
-	NETMSG_SV_KILLMSG msg;
-	msg.killer = killer;
-	msg.victim = player->client_id;
-	msg.weapon = weapon;
-	msg.mode_special = mode_special;
-	msg.pack(MSGFLAG_VITAL);
-	server_send_msg(-1);
+	CNetMsg_Sv_KillMsg Msg;
+	Msg.m_Killer = Killer;
+	Msg.m_Victim = m_pPlayer->GetCID();
+	Msg.m_Weapon = Weapon;
+	Msg.m_ModeSpecial = ModeSpecial;
+	Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
 
 	// a nice sound
-	game.create_sound(pos, SOUND_PLAYER_DIE);
-
-	// set dead state
-	// TODO: do stuff here
-	/*
-	die_pos = pos;
-	dead = true;
-	*/
+	GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE);
 	
 	// this is for auto respawn after 3 secs
-	player->die_tick = server_tick();
+	m_pPlayer->m_DieTick = Server()->Tick();
 	
-	alive = false;
-	game.world.remove_entity(this);
-	game.world.core.characters[player->client_id] = 0;
-	game.create_death(pos, player->client_id);
+	m_Alive = false;
+	GameServer()->m_World.RemoveEntity(this);
+	GameServer()->m_World.m_Core.m_apCharacters[m_pPlayer->GetCID()] = 0;
+	GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID());
 	
 	// we got to wait 0.5 secs before respawning
-	player->respawn_tick = server_tick()+server_tickspeed()/2;
+	m_pPlayer->m_RespawnTick = Server()->Tick()+Server()->TickSpeed()/2;
 }
 
-bool CHARACTER::take_damage(vec2 force, int dmg, int from, int weapon)
+bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon)
 {
-	core.vel += force;
+	m_Core.m_Vel += Force;
 	
-	if(game.controller->is_friendly_fire(player->client_id, from) && !config.sv_teamdamage)
+	if(GameServer()->m_pController->IsFriendlyFire(m_pPlayer->GetCID(), From) && !g_Config.m_SvTeamdamage)
 		return false;
 
-	// player only inflicts half damage on self
-	if(from == player->client_id)
-		dmg = max(1, dmg/2);
+	// m_pPlayer only inflicts half damage on self
+	if(From == m_pPlayer->GetCID())
+		Dmg = max(1, Dmg/2);
 
-	damage_taken++;
+	m_DamageTaken++;
 
 	// create healthmod indicator
-	if(server_tick() < damage_taken_tick+25)
+	if(Server()->Tick() < m_DamageTakenTick+25)
 	{
 		// make sure that the damage indicators doesn't group together
-		game.create_damageind(pos, damage_taken*0.25f, dmg);
+		GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg);
 	}
 	else
 	{
-		damage_taken = 0;
-		game.create_damageind(pos, 0, dmg);
+		m_DamageTaken = 0;
+		GameServer()->CreateDamageInd(m_Pos, 0, Dmg);
 	}
 
-	if(dmg)
+	if(Dmg)
 	{
-		if(armor)
+		if(m_Armor)
 		{
-			if(dmg > 1)
+			if(Dmg > 1)
 			{
-				health--;
-				dmg--;
+				m_Health--;
+				Dmg--;
 			}
 			
-			if(dmg > armor)
+			if(Dmg > m_Armor)
 			{
-				dmg -= armor;
-				armor = 0;
+				Dmg -= m_Armor;
+				m_Armor = 0;
 			}
 			else
 			{
-				armor -= dmg;
-				dmg = 0;
+				m_Armor -= Dmg;
+				Dmg = 0;
 			}
 		}
 		
-		health -= dmg;
+		m_Health -= Dmg;
 	}
 
-	damage_taken_tick = server_tick();
+	m_DamageTakenTick = Server()->Tick();
 
-	// do damage hit sound
-	if(from >= 0 && from != player->client_id && game.players[from])
-		game.create_sound(game.players[from]->view_pos, SOUND_HIT, cmask_one(from));
+	// do damage Hit sound
+	if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From])
+		GameServer()->CreateSound(GameServer()->m_apPlayers[From]->m_ViewPos, SOUND_HIT, CmaskOne(From));
 
 	// check for death
-	if(health <= 0)
+	if(m_Health <= 0)
 	{
-		die(from, weapon);
+		Die(From, Weapon);
 		
 		// set attacker's face to happy (taunt!)
-		if (from >= 0 && from != player->client_id && game.players[from])
+		if (From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From])
 		{
-			CHARACTER *chr = game.players[from]->get_character();
-			if (chr)
+			CCharacter *pChr = GameServer()->m_apPlayers[From]->GetCharacter();
+			if (pChr)
 			{
-				chr->emote_type = EMOTE_HAPPY;
-				chr->emote_stop = server_tick() + server_tickspeed();
+				pChr->m_EmoteType = EMOTE_HAPPY;
+				pChr->m_EmoteStop = Server()->Tick() + Server()->TickSpeed();
 			}
 		}
 	
 		return false;
 	}
 
-	if (dmg > 2)
-		game.create_sound(pos, SOUND_PLAYER_PAIN_LONG);
+	if (Dmg > 2)
+		GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG);
 	else
-		game.create_sound(pos, SOUND_PLAYER_PAIN_SHORT);
+		GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_SHORT);
 
-	emote_type = EMOTE_PAIN;
-	emote_stop = server_tick() + 500 * server_tickspeed() / 1000;
+	m_EmoteType = EMOTE_PAIN;
+	m_EmoteStop = Server()->Tick() + 500 * Server()->TickSpeed() / 1000;
 
-	// spawn blood?
 	return true;
 }
 
-void CHARACTER::snap(int snapping_client)
+void CCharacter::Snap(int SnappingClient)
 {
-	if(networkclipped(snapping_client))
+	if(NetworkClipped(SnappingClient))
 		return;
 	
-	NETOBJ_CHARACTER *character = (NETOBJ_CHARACTER *)snap_new_item(NETOBJTYPE_CHARACTER, player->client_id, sizeof(NETOBJ_CHARACTER));
+	CNetObj_Character *Character = static_cast<CNetObj_Character *>(Server()->SnapNewItem(NETOBJTYPE_CHARACTER, m_pPlayer->GetCID(), sizeof(CNetObj_Character)));
 	
-	// write down the core
-	if(game.world.paused)
+	// write down the m_Core
+	if(GameServer()->m_World.m_Paused)
 	{
 		// no dead reckoning when paused because the client doesn't know
 		// how far to perform the reckoning
-		character->tick = 0;
-		core.write(character);
+		Character->m_Tick = 0;
+		m_Core.Write(Character);
 	}
 	else
 	{
-		character->tick = reckoning_tick;
-		sendcore.write(character);
+		Character->m_Tick = m_ReckoningTick;
+		m_SendCore.Write(Character);
 	}
 	
 	// set emote
-	if (emote_stop < server_tick())
+	if (m_EmoteStop < Server()->Tick())
 	{
-		emote_type = EMOTE_NORMAL;
-		emote_stop = -1;
+		m_EmoteType = EMOTE_NORMAL;
+		m_EmoteStop = -1;
 	}
 
-	character->emote = emote_type;
+	Character->m_Emote = m_EmoteType;
 
-	character->ammocount = 0;
-	character->health = 0;
-	character->armor = 0;
+	Character->m_AmmoCount = 0;
+	Character->m_Health = 0;
+	Character->m_Armor = 0;
 	
-	character->weapon = active_weapon;
-	character->attacktick = attack_tick;
+	Character->m_Weapon = m_ActiveWeapon;
+	Character->m_AttackTick = m_AttackTick;
 
-	character->direction = input.direction;
+	Character->m_Direction = m_Input.m_Direction;
 
-	if(player->client_id == snapping_client)
+	if(m_pPlayer->GetCID() == SnappingClient)
 	{
-		character->health = health;
-		character->armor = armor;
-		if(weapons[active_weapon].ammo > 0)
-			character->ammocount = weapons[active_weapon].ammo;
+		Character->m_Health = m_Health;
+		Character->m_Armor = m_Armor;
+		if(m_aWeapons[m_ActiveWeapon].m_Ammo > 0)
+			Character->m_AmmoCount = m_aWeapons[m_ActiveWeapon].m_Ammo;
 	}
 
-	if (character->emote == EMOTE_NORMAL)
+	if (Character->m_Emote == EMOTE_NORMAL)
 	{
-		if(250 - ((server_tick() - last_action)%(250)) < 5)
-			character->emote = EMOTE_BLINK;
+		if(250 - ((Server()->Tick() - m_LastAction)%(250)) < 5)
+			Character->m_Emote = EMOTE_BLINK;
 	}
 
-	character->player_state = player_state;
+	Character->m_PlayerState = m_PlayerState;
 }
diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h
new file mode 100644
index 00000000..30c6586f
--- /dev/null
+++ b/src/game/server/entities/character.h
@@ -0,0 +1,133 @@
+#ifndef GAME_SERVER_ENTITIES_CHARACTER_H
+#define GAME_SERVER_ENTITIES_CHARACTER_H
+
+#include <game/server/entity.h>
+#include <game/generated/server_data.h>
+#include <game/generated/protocol.h>
+
+#include <game/gamecore.h>
+
+//character's size
+const int g_CharPhysSize = 28;
+
+enum
+{
+	WEAPON_GAME = -3, // team switching etc
+	WEAPON_SELF = -2, // console kill command
+	WEAPON_WORLD = -1, // death tiles etc
+};
+
+class CCharacter : public CEntity
+{
+	MACRO_ALLOC_POOL_ID()
+	
+public:
+	CCharacter(CGameWorld *pWorld);
+	
+	virtual void Reset();
+	virtual void Destroy();
+	virtual void Tick();
+	virtual void TickDefered();
+	virtual void Snap(int SnappingClient);
+		
+	bool IsGrounded();
+	
+	void SetWeapon(int W);
+	void HandleWeaponSwitch();
+	void DoWeaponSwitch();
+	
+	void HandleWeapons();
+	void HandleNinja();
+
+	void OnPredictedInput(CNetObj_PlayerInput *pNewInput);
+	void OnDirectInput(CNetObj_PlayerInput *pNewInput);
+	void FireWeapon();
+
+	void Die(int Killer, int Weapon);
+	bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon);	
+
+	bool Spawn(class CPlayer *pPlayer, vec2 Pos);
+	bool Remove();
+	
+	bool IncreaseHealth(int Amount);
+	bool IncreaseArmor(int Amount);
+	
+	bool GiveWeapon(int Weapon, int Ammo);
+	void GiveNinja();
+	
+	void SetEmote(int Emote, int Tick);
+	
+	const bool IsAlive() { return m_Alive; }
+	class CPlayer *GetPlayer() { return m_pPlayer; }
+	
+private:
+	// player controlling this character
+	class CPlayer *m_pPlayer;
+	
+	bool m_Alive;
+
+	// weapon info
+	CEntity *m_apHitObjects[10];
+	int m_NumObjectsHit;
+	
+	struct WeaponStat
+	{
+		int m_AmmoRegenStart;
+		int m_Ammo;
+		int m_Ammocost;
+		bool m_Got;
+		
+	} m_aWeapons[NUM_WEAPONS];
+	
+	int m_ActiveWeapon;
+	int m_LastWeapon;
+	int m_QueuedWeapon;
+	
+	int m_ReloadTimer;
+	int m_AttackTick;
+	
+	int m_DamageTaken;
+
+	int m_EmoteType;
+	int m_EmoteStop;
+	
+	// last tick that the player took any action ie some input
+	int m_LastAction;
+
+	// these are non-heldback inputs
+	CNetObj_PlayerInput m_LatestPrevInput;
+	CNetObj_PlayerInput m_LatestInput;
+
+	// input	
+	CNetObj_PlayerInput m_PrevInput;
+	CNetObj_PlayerInput m_Input;
+	int m_NumInputs;
+	int m_Jumped;
+	
+	int m_DamageTakenTick;
+
+	int m_Health;
+	int m_Armor;
+
+	// ninja
+	struct
+	{
+		vec2 m_ActivationDir;
+		int m_ActivationTick;
+		int m_CurrentMoveTime;
+		
+	} m_Ninja;
+
+	int m_PlayerState;// if the client is chatting, accessing a menu or so
+
+	// the player core for the physics	
+	CCharacterCore m_Core;
+	
+	// info for dead reckoning
+	int m_ReckoningTick; // tick that we are performing dead reckoning From
+	CCharacterCore m_SendCore; // core that we should send
+	CCharacterCore m_ReckoningCore; // the dead reckoning core
+
+};
+
+#endif
diff --git a/src/game/server/entities/character.hpp b/src/game/server/entities/character.hpp
deleted file mode 100644
index bd2f7afe..00000000
--- a/src/game/server/entities/character.hpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-
-#ifndef GAME_SERVER_ENTITY_CHARACTER_H
-#define GAME_SERVER_ENTITY_CHARACTER_H
-
-#include <game/server/entity.hpp>
-#include <game/generated/gs_data.hpp>
-#include <game/generated/g_protocol.hpp>
-
-#include <game/gamecore.hpp>
-
-enum
-{
-	WEAPON_GAME = -3, // team switching etc
-	WEAPON_SELF = -2, // console kill command
-	WEAPON_WORLD = -1, // death tiles etc
-};
-
-class CHARACTER : public ENTITY
-{
-	MACRO_ALLOC_POOL_ID()
-public:
-	// player controlling this character
-	class PLAYER *player;
-	
-	bool alive;
-
-	// weapon info
-	ENTITY *hitobjects[10];
-	int numobjectshit;
-	struct WEAPONSTAT
-	{
-		int ammoregenstart;
-		int ammo;
-		int ammocost;
-		bool got;
-	} weapons[NUM_WEAPONS];
-	
-	int active_weapon;
-	int last_weapon;
-	int queued_weapon;
-	
-	int reload_timer;
-	int attack_tick;
-	
-	int damage_taken;
-
-	int emote_type;
-	int emote_stop;
-
-	// TODO: clean this up
-	char skin_name[64];
-	int use_custom_color;
-	int color_body;
-	int color_feet;
-	
-	int last_action; // last tick that the player took any action ie some input
-
-	// these are non-heldback inputs
-	NETOBJ_PLAYER_INPUT latest_previnput;
-	NETOBJ_PLAYER_INPUT latest_input;
-
-	// input	
-	NETOBJ_PLAYER_INPUT previnput;
-	NETOBJ_PLAYER_INPUT input;
-	int num_inputs;
-	int jumped;
-	
-	int damage_taken_tick;
-
-	int health;
-	int armor;
-
-	// ninja
-	struct
-	{
-		vec2 activationdir;
-		int activationtick;
-		int currentmovetime;
-	} ninja;
-
-	//
-	//int score;
-	int team;
-	int player_state; // if the client is chatting, accessing a menu or so
-
-	// the player core for the physics	
-	CHARACTER_CORE core;
-	
-	// info for dead reckoning
-	int reckoning_tick; // tick that we are performing dead reckoning from
-	CHARACTER_CORE sendcore; // core that we should send
-	CHARACTER_CORE reckoningcore; // the dead reckoning core
-
-	//
-	CHARACTER();
-	
-	virtual void reset();
-	virtual void destroy();
-		
-	bool is_grounded();
-	
-	void set_weapon(int w);
-	
-	void handle_weaponswitch();
-	void do_weaponswitch();
-	
-	int handle_weapons();
-	int handle_ninja();
-
-	void on_predicted_input(NETOBJ_PLAYER_INPUT *new_input);
-	void on_direct_input(NETOBJ_PLAYER_INPUT *new_input);
-	void fire_weapon();
-
-	void die(int killer, int weapon);
-
-	bool take_damage(vec2 force, int dmg, int from, int weapon);	
-
-	
-	bool spawn(PLAYER *player, vec2 pos, int team);
-	//bool init_tryspawn(int team);
-	bool remove();
-
-	static const int phys_size = 28;
-
-	virtual void tick();
-	virtual void tick_defered();
-	virtual void snap(int snapping_client);
-	
-	bool increase_health(int amount);
-	bool increase_armor(int amount);
-};
-
-#endif
diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp
index 2c6fa0ff..6bc26074 100644
--- a/src/game/server/entities/laser.cpp
+++ b/src/game/server/entities/laser.cpp
@@ -1,115 +1,105 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-#include <engine/e_server_interface.h>
-#include <game/generated/g_protocol.hpp>
-#include <game/server/gamecontext.hpp>
-#include "laser.hpp"
+// copyright (c) 2007 magnus auvinen, see licence.txt for more info
+#include <game/generated/protocol.h>
+#include <game/server/gamecontext.h>
+#include "laser.h"
 
-//////////////////////////////////////////////////
-// laser
-//////////////////////////////////////////////////
-LASER::LASER(vec2 pos, vec2 direction, float start_energy, int owner)
-: ENTITY(NETOBJTYPE_LASER)
+CLaser::CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner)
+: CEntity(pGameWorld, NETOBJTYPE_LASER)
 {
-	this->pos = pos;
-	this->owner = owner;
-	energy = start_energy;
-	dir = direction;
-	bounces = 0;
-	do_bounce();
-	
-	game.world.insert_entity(this);
+	m_Pos = Pos;
+	m_Owner = Owner;
+	m_Energy = StartEnergy;
+	m_Dir = Direction;
+	m_Bounces = 0;
+	m_EvalTick = 0;
+	GameWorld()->InsertEntity(this);
+	DoBounce();
 }
 
 
-bool LASER::hit_character(vec2 from, vec2 to)
+bool CLaser::HitCharacter(vec2 From, vec2 To)
 {
-	vec2 at;
-	CHARACTER *owner_char = game.get_player_char(owner);
-	CHARACTER *hit = game.world.intersect_character(pos, to, 0.0f, at, owner_char);
-	if(!hit)
+	vec2 At;
+	CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
+	CCharacter *Hit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, OwnerChar);
+	if(!Hit)
 		return false;
 
-	this->from = from;
-	pos = at;
-	energy = -1;		
-	hit->take_damage(vec2(0,0), tuning.laser_damage, owner, WEAPON_RIFLE);
+	m_From = From;
+	m_Pos = At;
+	m_Energy = -1;		
+	Hit->TakeDamage(vec2(0.f, 0.f), GameServer()->Tuning()->m_LaserDamage, m_Owner, WEAPON_RIFLE);
 	return true;
 }
 
-void LASER::do_bounce()
+void CLaser::DoBounce()
 {
-	eval_tick = server_tick();
+	m_EvalTick = Server()->Tick();
 	
-	if(energy < 0)
+	if(m_Energy < 0)
 	{
-		//dbg_msg("laser", "%d removed", server_tick());
-		game.world.destroy_entity(this);
+		GameServer()->m_World.DestroyEntity(this);
 		return;
 	}
 	
-	vec2 to = pos + dir*energy;
-	vec2 org_to = to;
+	vec2 To = m_Pos + m_Dir * m_Energy;
+	vec2 OrgTo = To;
 	
-	if(col_intersect_line(pos, to, 0x0, &to))
+	if(GameServer()->Collision()->IntersectLine(m_Pos, To, 0x0, &To))
 	{
-		if(!hit_character(pos, to))
+		if(!HitCharacter(m_Pos, To))
 		{
 			// intersected
-			from = pos;
-			pos = to;
+			m_From = m_Pos;
+			m_Pos = To;
 
-			vec2 temp_pos = pos;
-			vec2 temp_dir = dir*4.0f;
+			vec2 TempPos = m_Pos;
+			vec2 TempDir = m_Dir * 4.0f;
 			
-			move_point(&temp_pos, &temp_dir, 1.0f, 0);
-			pos = temp_pos;
-			dir = normalize(temp_dir);
+			GameServer()->Collision()->MovePoint(&TempPos, &TempDir, 1.0f, 0);
+			m_Pos = TempPos;
+			m_Dir = normalize(TempDir);
 			
-			energy -= distance(from, pos) + tuning.laser_bounce_cost;
-			bounces++;
+			m_Energy -= distance(m_From, m_Pos) + GameServer()->Tuning()->m_LaserBounceCost;
+			m_Bounces++;
 			
-			if(bounces > tuning.laser_bounce_num)
-				energy = -1;
+			if(m_Bounces > GameServer()->Tuning()->m_LaserBounceNum)
+				m_Energy = -1;
 				
-			game.create_sound(pos, SOUND_RIFLE_BOUNCE);
+			GameServer()->CreateSound(m_Pos, SOUND_RIFLE_BOUNCE);
 		}
 	}
 	else
 	{
-		if(!hit_character(pos, to))
+		if(!HitCharacter(m_Pos, To))
 		{
-			from = pos;
-			pos = to;
-			energy = -1;
+			m_From = m_Pos;
+			m_Pos = To;
+			m_Energy = -1;
 		}
 	}
-		
-	//dbg_msg("laser", "%d done %f %f %f %f", server_tick(), from.x, from.y, pos.x, pos.y);
 }
 	
-void LASER::reset()
+void CLaser::Reset()
 {
-	game.world.destroy_entity(this);
+	GameServer()->m_World.DestroyEntity(this);
 }
 
-void LASER::tick()
+void CLaser::Tick()
 {
-	if(server_tick() > eval_tick+(server_tickspeed()*tuning.laser_bounce_delay)/1000.0f)
-	{
-		do_bounce();
-	}
-
+	if(Server()->Tick() > m_EvalTick+(Server()->TickSpeed()*GameServer()->Tuning()->m_LaserBounceDelay)/1000.0f)
+		DoBounce();
 }
 
-void LASER::snap(int snapping_client)
+void CLaser::Snap(int SnappingClient)
 {
-	if(networkclipped(snapping_client))
+	if(NetworkClipped(SnappingClient))
 		return;
 
-	NETOBJ_LASER *obj = (NETOBJ_LASER *)snap_new_item(NETOBJTYPE_LASER, id, sizeof(NETOBJ_LASER));
-	obj->x = (int)pos.x;
-	obj->y = (int)pos.y;
-	obj->from_x = (int)from.x;
-	obj->from_y = (int)from.y;
-	obj->start_tick = eval_tick;
+	CNetObj_Laser *pObj = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_Id, sizeof(CNetObj_Laser)));
+	pObj->m_X = (int)m_Pos.x;
+	pObj->m_Y = (int)m_Pos.y;
+	pObj->m_FromX = (int)m_From.x;
+	pObj->m_FromY = (int)m_From.y;
+	pObj->m_StartTick = m_EvalTick;
 }
diff --git a/src/game/server/entities/laser.h b/src/game/server/entities/laser.h
new file mode 100644
index 00000000..040cfb4c
--- /dev/null
+++ b/src/game/server/entities/laser.h
@@ -0,0 +1,28 @@
+#ifndef GAME_SERVER_ENTITIES_LASER_H
+#define GAME_SERVER_ENTITIES_LASER_H
+
+#include <game/server/entity.h>
+
+class CLaser : public CEntity
+{
+public:
+	CLaser(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner);
+	
+	virtual void Reset();
+	virtual void Tick();
+	virtual void Snap(int SnappingClient);
+	
+protected:
+	bool HitCharacter(vec2 From, vec2 To);
+	void DoBounce();
+	
+private:
+	vec2 m_From;
+	vec2 m_Dir;
+	float m_Energy;
+	int m_Bounces;
+	int m_EvalTick;
+	int m_Owner;
+};
+
+#endif
diff --git a/src/game/server/entities/laser.hpp b/src/game/server/entities/laser.hpp
deleted file mode 100644
index aa4c2284..00000000
--- a/src/game/server/entities/laser.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-
-#ifndef GAME_SERVER_ENTITY_LASER_H
-#define GAME_SERVER_ENTITY_LASER_H
-
-#include <game/server/entity.hpp>
-
-class CHARACTER;
-
-class LASER : public ENTITY
-{
-	vec2 from;
-	vec2 dir;
-	float energy;
-	int bounces;
-	int eval_tick;
-	int owner;
-	
-	bool hit_character(vec2 from, vec2 to);
-	void do_bounce();
-	
-public:
-	
-	LASER(vec2 pos, vec2 direction, float start_energy, int owner);
-	
-	virtual void reset();
-	virtual void tick();
-	virtual void snap(int snapping_client);
-};
-
-#endif
diff --git a/src/game/server/entities/pickup.cpp b/src/game/server/entities/pickup.cpp
index 436282cc..9798e2c3 100644
--- a/src/game/server/entities/pickup.cpp
+++ b/src/game/server/entities/pickup.cpp
@@ -1,143 +1,129 @@
-#include <engine/e_server_interface.h>
-#include <game/generated/g_protocol.hpp>
-#include <game/server/gamecontext.hpp>
-#include "pickup.hpp"
+#include <game/generated/protocol.h>
+#include <game/server/gamecontext.h>
+#include "pickup.h"
 
-//////////////////////////////////////////////////
-// pickup
-//////////////////////////////////////////////////
-PICKUP::PICKUP(int _type, int _subtype)
-: ENTITY(NETOBJTYPE_PICKUP)
+CPickup::CPickup(CGameWorld *pGameWorld, int Type, int SubType)
+: CEntity(pGameWorld, NETOBJTYPE_PICKUP)
 {
-	type = _type;
-	subtype = _subtype;
-	proximity_radius = phys_size;
+	m_Type = Type;
+	m_Subtype = SubType;
+	m_ProximityRadius = PickupPhysSize;
 
-	reset();
-
-	// TODO: should this be done here?
-	game.world.insert_entity(this);
+	Reset();
+	
+	GameWorld()->InsertEntity(this);
 }
 
-void PICKUP::reset()
+void CPickup::Reset()
 {
-	if (data->pickups[type].spawndelay > 0)
-		spawntick = server_tick() + server_tickspeed() * data->pickups[type].spawndelay;
+	if (g_pData->m_aPickups[m_Type].m_Spawndelay > 0)
+		m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * g_pData->m_aPickups[m_Type].m_Spawndelay;
 	else
-		spawntick = -1;
+		m_SpawnTick = -1;
 }
 
-void PICKUP::tick()
+void CPickup::Tick()
 {
 	// wait for respawn
-	if(spawntick > 0)
+	if(m_SpawnTick > 0)
 	{
-		if(server_tick() > spawntick)
+		if(Server()->Tick() > m_SpawnTick)
 		{
 			// respawn
-			spawntick = -1;
+			m_SpawnTick = -1;
 
-			if(type == POWERUP_WEAPON)
-				game.create_sound(pos, SOUND_WEAPON_SPAWN);
+			if(m_Type == POWERUP_WEAPON)
+				GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
 		}
 		else
 			return;
 	}
 	// Check if a player intersected us
-	CHARACTER *chr = game.world.closest_character(pos, 20.0f, 0);
-	if(chr)
+	CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
+	if(pChr && pChr->IsAlive())
 	{
 		// player picked us up, is someone was hooking us, let them go
-		int respawntime = -1;
-		switch (type)
+		int RespawnTime = -1;
+		switch (m_Type)
 		{
-		case POWERUP_HEALTH:
-			if(chr->increase_health(1))
-			{
-				game.create_sound(pos, SOUND_PICKUP_HEALTH);
-				respawntime = data->pickups[type].respawntime;
-			}
-			break;
-		case POWERUP_ARMOR:
-			if(chr->increase_armor(1))
-			{
-				game.create_sound(pos, SOUND_PICKUP_ARMOR);
-				respawntime = data->pickups[type].respawntime;
-			}
-			break;
+			case POWERUP_HEALTH:
+				if(pChr->IncreaseHealth(1))
+				{
+					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
+					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
+				}
+				break;
+				
+			case POWERUP_ARMOR:
+				if(pChr->IncreaseArmor(1))
+				{
+					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
+					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
+				}
+				break;
 
-		case POWERUP_WEAPON:
-			if(subtype >= 0 && subtype < NUM_WEAPONS)
-			{
-				if(chr->weapons[subtype].ammo < data->weapons.id[subtype].maxammo || !chr->weapons[subtype].got)
+			case POWERUP_WEAPON:
+				if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS)
 				{
-					chr->weapons[subtype].got = true;
-					chr->weapons[subtype].ammo = min(data->weapons.id[subtype].maxammo, chr->weapons[subtype].ammo + 10);
-					respawntime = data->pickups[type].respawntime;
+					if(pChr->GiveWeapon(m_Subtype, 10))
+					{
+						RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
 
-					// TODO: data compiler should take care of stuff like this
-					if(subtype == WEAPON_GRENADE)
-						game.create_sound(pos, SOUND_PICKUP_GRENADE);
-					else if(subtype == WEAPON_SHOTGUN)
-						game.create_sound(pos, SOUND_PICKUP_SHOTGUN);
-					else if(subtype == WEAPON_RIFLE)
-						game.create_sound(pos, SOUND_PICKUP_SHOTGUN);
+						if(m_Subtype == WEAPON_GRENADE)
+							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
+						else if(m_Subtype == WEAPON_SHOTGUN)
+							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
+						else if(m_Subtype == WEAPON_RIFLE)
+							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
 
-					if(chr->player)
-                    	game.send_weapon_pickup(chr->player->client_id, subtype);
+						if(pChr->GetPlayer())
+							GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
+					}
 				}
-			}
-			break;
-		case POWERUP_NINJA:
-			{
-				// activate ninja on target player
-				chr->ninja.activationtick = server_tick();
-				chr->weapons[WEAPON_NINJA].got = true;
-				chr->weapons[WEAPON_NINJA].ammo = -1;
-				chr->last_weapon = chr->active_weapon;
-				chr->active_weapon = WEAPON_NINJA;
-				respawntime = data->pickups[type].respawntime;
-				game.create_sound(pos, SOUND_PICKUP_NINJA);
-
-				// loop through all players, setting their emotes
-				ENTITY *ents[64];
-				int num = game.world.find_entities(vec2(0, 0), 1000000, ents, 64, NETOBJTYPE_CHARACTER);
-				for (int i = 0; i < num; i++)
+				break;
+				
+			case POWERUP_NINJA:
 				{
-					CHARACTER *c = (CHARACTER *)ents[i];
-					if (c != chr)
+					// activate ninja on target player
+					pChr->GiveNinja();
+					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
+
+					// loop through all players, setting their emotes
+					CEntity *apEnts[64];
+					int Num = GameServer()->m_World.FindEntities(vec2(0, 0), 1000000, apEnts, 64, NETOBJTYPE_CHARACTER);
+					
+					for (int i = 0; i < Num; ++i)
 					{
-						c->emote_type = EMOTE_SURPRISE;
-						c->emote_stop = server_tick() + server_tickspeed();
+						CCharacter *pC = static_cast<CCharacter *>(apEnts[i]);
+						if (pC != pChr)
+							pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
 					}
-				}
 
-				chr->emote_type = EMOTE_ANGRY;
-				chr->emote_stop = server_tick() + 1200 * server_tickspeed() / 1000;
+					pChr->SetEmote(EMOTE_ANGRY, Server()->Tick() + 1200 * Server()->TickSpeed() / 1000);
+					break;
+				}
 				
+			default:
 				break;
-			}
-		default:
-			break;
 		};
 
-		if(respawntime >= 0)
+		if(RespawnTime >= 0)
 		{
 			dbg_msg("game", "pickup player='%d:%s' item=%d/%d",
-				chr->player->client_id, server_clientname(chr->player->client_id), type, subtype);
-			spawntick = server_tick() + server_tickspeed() * respawntime;
+				pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
+			m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
 		}
 	}
 }
 
-void PICKUP::snap(int snapping_client)
+void CPickup::Snap(int SnappingClient)
 {
-	if(spawntick != -1)
+	if(m_SpawnTick != -1 || NetworkClipped(SnappingClient))
 		return;
 
-	NETOBJ_PICKUP *up = (NETOBJ_PICKUP *)snap_new_item(NETOBJTYPE_PICKUP, id, sizeof(NETOBJ_PICKUP));
-	up->x = (int)pos.x;
-	up->y = (int)pos.y;
-	up->type = type; // TODO: two diffrent types? what gives?
-	up->subtype = subtype;
+	CNetObj_Pickup *pP = static_cast<CNetObj_Pickup *>(Server()->SnapNewItem(NETOBJTYPE_PICKUP, m_Id, sizeof(CNetObj_Pickup)));
+	pP->m_X = (int)m_Pos.x;
+	pP->m_Y = (int)m_Pos.y;
+	pP->m_Type = m_Type;
+	pP->m_Subtype = m_Subtype;
 }
diff --git a/src/game/server/entities/pickup.h b/src/game/server/entities/pickup.h
new file mode 100644
index 00000000..c076464c
--- /dev/null
+++ b/src/game/server/entities/pickup.h
@@ -0,0 +1,23 @@
+#ifndef GAME_SERVER_ENTITIES_PICKUP_H
+#define GAME_SERVER_ENTITIES_PICKUP_H
+
+#include <game/server/entity.h>
+
+const int PickupPhysSize = 14;
+
+class CPickup : public CEntity
+{
+public:
+	CPickup(CGameWorld *pGameWorld, int Type, int SubType = 0);
+	
+	virtual void Reset();
+	virtual void Tick();
+	virtual void Snap(int SnappingClient);
+	
+private:
+	int m_Type;
+	int m_Subtype;
+	int m_SpawnTick;
+};
+
+#endif
diff --git a/src/game/server/entities/pickup.hpp b/src/game/server/entities/pickup.hpp
deleted file mode 100644
index cd480d92..00000000
--- a/src/game/server/entities/pickup.hpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-
-#ifndef GAME_SERVER_ENTITY_PICKUP_H
-#define GAME_SERVER_ENTITY_PICKUP_H
-
-#include <game/server/entity.hpp>
-
-// TODO: move to seperate file
-class PICKUP : public ENTITY
-{
-public:
-	static const int phys_size = 14;
-	
-	int type;
-	int subtype; // weapon type for instance?
-	int spawntick;
-	PICKUP(int _type, int _subtype = 0);
-	
-	virtual void reset();
-	virtual void tick();
-	virtual void snap(int snapping_client);
-};
-
-#endif
diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp
index 2a8de766..18652ba1 100644
--- a/src/game/server/entities/projectile.cpp
+++ b/src/game/server/entities/projectile.cpp
@@ -1,105 +1,102 @@
-#include <engine/e_server_interface.h>
-#include <game/generated/g_protocol.hpp>
-#include <game/server/gamecontext.hpp>
-#include "projectile.hpp"
+#include <game/generated/protocol.h>
+#include <game/server/gamecontext.h>
+#include "projectile.h"
 
-
-//////////////////////////////////////////////////
-// projectile
-//////////////////////////////////////////////////
-PROJECTILE::PROJECTILE(int type, int owner, vec2 pos, vec2 dir, int span,
-	int damage, int flags, float force, int sound_impact, int weapon)
-: ENTITY(NETOBJTYPE_PROJECTILE)
+CProjectile::CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos, vec2 Dir, int Span,
+		int Damage, bool Explosive, float Force, int SoundImpact, int Weapon)
+: CEntity(pGameWorld, NETOBJTYPE_PROJECTILE)
 {
-	this->type = type;
-	this->pos = pos;
-	this->direction = dir;
-	this->lifespan = span;
-	this->owner = owner;
-	this->flags = flags;
-	this->force = force;
-	this->damage = damage;
-	this->sound_impact = sound_impact;
-	this->weapon = weapon;
-	this->bounce = 0;
-	this->start_tick = server_tick();
-	game.world.insert_entity(this);
+	m_Type = Type;
+	m_Pos = Pos;
+	m_Direction = Dir;
+	m_LifeSpan = Span;
+	m_Owner = Owner;
+	m_Force = Force;
+	m_Damage = Damage;
+	m_SoundImpact = SoundImpact;
+	m_Weapon = Weapon;
+	m_StartTick = Server()->Tick();
+	m_Explosive = Explosive;
+
+	GameWorld()->InsertEntity(this);
 }
 
-void PROJECTILE::reset()
+void CProjectile::Reset()
 {
-	game.world.destroy_entity(this);
+	GameServer()->m_World.DestroyEntity(this);
 }
 
-vec2 PROJECTILE::get_pos(float time)
+vec2 CProjectile::GetPos(float Time)
 {
-	float curvature = 0;
-	float speed = 0;
-	if(type == WEAPON_GRENADE)
-	{
-		curvature = tuning.grenade_curvature;
-		speed = tuning.grenade_speed;
-	}
-	else if(type == WEAPON_SHOTGUN)
-	{
-		curvature = tuning.shotgun_curvature;
-		speed = tuning.shotgun_speed;
-	}
-	else if(type == WEAPON_GUN)
+	float Curvature = 0;
+	float Speed = 0;
+	
+	switch(m_Type)
 	{
-		curvature = tuning.gun_curvature;
-		speed = tuning.gun_speed;
+		case WEAPON_GRENADE:
+			Curvature = GameServer()->Tuning()->m_GrenadeCurvature;
+			Speed = GameServer()->Tuning()->m_GrenadeSpeed;
+			break;
+			
+		case WEAPON_SHOTGUN:
+			Curvature = GameServer()->Tuning()->m_ShotgunCurvature;
+			Speed = GameServer()->Tuning()->m_ShotgunSpeed;
+			break;
+			
+		case WEAPON_GUN:
+			Curvature = GameServer()->Tuning()->m_GunCurvature;
+			Speed = GameServer()->Tuning()->m_GunSpeed;
+			break;
 	}
 	
-	return calc_pos(pos, direction, curvature, speed, time);
+	return CalcPos(m_Pos, m_Direction, Curvature, Speed, Time);
 }
 
 
-void PROJECTILE::tick()
+void CProjectile::Tick()
 {
-	
-	float pt = (server_tick()-start_tick-1)/(float)server_tickspeed();
-	float ct = (server_tick()-start_tick)/(float)server_tickspeed();
-	vec2 prevpos = get_pos(pt);
-	vec2 curpos = get_pos(ct);
+	float Pt = (Server()->Tick()-m_StartTick-1)/(float)Server()->TickSpeed();
+	float Ct = (Server()->Tick()-m_StartTick)/(float)Server()->TickSpeed();
+	vec2 PrevPos = GetPos(Pt);
+	vec2 CurPos = GetPos(Ct);
+	int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &CurPos, 0);
+	CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
+	CCharacter *TargetChr = GameServer()->m_World.IntersectCharacter(PrevPos, CurPos, 6.0f, CurPos, OwnerChar);
 
-	lifespan--;
+	m_LifeSpan--;
 	
-	int collide = col_intersect_line(prevpos, curpos, &curpos, 0);
-	//int collide = col_check_point((int)curpos.x, (int)curpos.y);
-	CHARACTER *ownerchar = game.get_player_char(owner);
-	CHARACTER *targetchr = game.world.intersect_character(prevpos, curpos, 6.0f, curpos, ownerchar);
-	if(targetchr || collide || lifespan < 0)
+	if(TargetChr || Collide || m_LifeSpan < 0)
 	{
-		if(lifespan >= 0 || weapon == WEAPON_GRENADE)
-			game.create_sound(curpos, sound_impact);
+		if(m_LifeSpan >= 0 || m_Weapon == WEAPON_GRENADE)
+			GameServer()->CreateSound(CurPos, m_SoundImpact);
 
-		if(flags & PROJECTILE_FLAGS_EXPLODE)
-			game.create_explosion(curpos, owner, weapon, false);
-		else if(targetchr)
-			targetchr->take_damage(direction * max(0.001f, force), damage, owner, weapon);
+		if(m_Explosive)
+			GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, false);
+			
+		else if(TargetChr)
+			TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon);
 
-		game.world.destroy_entity(this);
+		GameServer()->m_World.DestroyEntity(this);
 	}
 }
 
-void PROJECTILE::fill_info(NETOBJ_PROJECTILE *proj)
+void CProjectile::FillInfo(CNetObj_Projectile *pProj)
 {
-	proj->x = (int)pos.x;
-	proj->y = (int)pos.y;
-	proj->vx = (int)(direction.x*100.0f);
-	proj->vy = (int)(direction.y*100.0f);
-	proj->start_tick = start_tick;
-	proj->type = type;
+	pProj->m_X = (int)m_Pos.x;
+	pProj->m_Y = (int)m_Pos.y;
+	pProj->m_VelX = (int)(m_Direction.x*100.0f);
+	pProj->m_VelY = (int)(m_Direction.y*100.0f);
+	pProj->m_StartTick = m_StartTick;
+	pProj->m_Type = m_Type;
 }
 
-void PROJECTILE::snap(int snapping_client)
+void CProjectile::Snap(int SnappingClient)
 {
-	float ct = (server_tick()-start_tick)/(float)server_tickspeed();
+	float Ct = (Server()->Tick()-m_StartTick)/(float)Server()->TickSpeed();
 	
-	if(networkclipped(snapping_client, get_pos(ct)))
+	if(NetworkClipped(SnappingClient, GetPos(Ct)))
 		return;
 
-	NETOBJ_PROJECTILE *proj = (NETOBJ_PROJECTILE *)snap_new_item(NETOBJTYPE_PROJECTILE, id, sizeof(NETOBJ_PROJECTILE));
-	fill_info(proj);
+	CNetObj_Projectile *pProj = static_cast<CNetObj_Projectile *>(Server()->SnapNewItem(NETOBJTYPE_PROJECTILE, m_Id, sizeof(CNetObj_Projectile)));
+	FillInfo(pProj);
 }
diff --git a/src/game/server/entities/projectile.h b/src/game/server/entities/projectile.h
new file mode 100644
index 00000000..87f4f6c3
--- /dev/null
+++ b/src/game/server/entities/projectile.h
@@ -0,0 +1,30 @@
+#ifndef GAME_SERVER_ENTITIES_PROJECTILE_H
+#define GAME_SERVER_ENTITIES_PROJECTILE_H
+
+class CProjectile : public CEntity
+{
+public:
+	CProjectile(CGameWorld *pGameWorld, int Type, int Owner, vec2 Pos, vec2 Dir, int Span,
+		int Damage, bool Explosive, float Force, int SoundImpact, int Weapon);
+
+	vec2 GetPos(float Time);
+	void FillInfo(CNetObj_Projectile *pProj);
+
+	virtual void Reset();
+	virtual void Tick();
+	virtual void Snap(int SnappingClient);
+	
+private:
+	vec2 m_Direction;
+	int m_LifeSpan;
+	int m_Owner;
+	int m_Type;
+	int m_Damage;
+	int m_SoundImpact;
+	int m_Weapon;
+	float m_Force;
+	int m_StartTick;
+	bool m_Explosive;
+};
+
+#endif
diff --git a/src/game/server/entities/projectile.hpp b/src/game/server/entities/projectile.hpp
deleted file mode 100644
index a5c3b88f..00000000
--- a/src/game/server/entities/projectile.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
-
-#ifndef GAME_SERVER_ENTITY_PROJECTILE_H
-#define GAME_SERVER_ENTITY_PROJECTILE_H
-
-class PROJECTILE : public ENTITY
-{
-public:
-	enum
-	{
-		PROJECTILE_FLAGS_EXPLODE = 1 << 0,
-	};
-	
-	vec2 direction;
-	int lifespan;
-	int owner;
-	int type;
-	int flags;
-	int damage;
-	int sound_impact;
-	int weapon;
-	int bounce;
-	float force;
-	int start_tick;
-	
-	PROJECTILE(int type, int owner, vec2 pos, vec2 vel, int span,
-		int damage, int flags, float force, int sound_impact, int weapon);
-
-	vec2 get_pos(float time);
-	void fill_info(NETOBJ_PROJECTILE *proj);
-
-	virtual void reset();
-	virtual void tick();
-	virtual void snap(int snapping_client);
-};
-
-#endif