diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 4cc8ba292..27021c1fe 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -5,8 +5,8 @@ #include extern "C" { - #include - #include + #include // TODO: this shouldn't be here + #include // TODO: this shouldn't be here #include }; @@ -24,8 +24,6 @@ extern "C" { #include "gc_anim.h" #include "gc_console.h" -#include - struct data_container *data = 0; static int64 debug_firedelay = 0; diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp index c16923b8e..a31b7201a 100644 --- a/src/game/client/gc_hooks.cpp +++ b/src/game/client/gc_hooks.cpp @@ -298,28 +298,16 @@ extern "C" void modc_render() render_game(); if (console_active()) console_render(); - - // handle team switching - // TODO: FUGLY!!! - /* - if(config.cl_team != -10) - { - - }*/ } - else // if (client_state() != CLIENTSTATE_CONNECTING && client_state() != CLIENTSTATE_LOADING) + else { menu_render(); if (console_active()) console_render(); return; } - - // - //config.cl_team = -10; } - extern "C" int modc_snap_input(int *data) { picked_up_weapon = -1; @@ -335,12 +323,12 @@ extern "C" int modc_snap_input(int *data) input_target_lock = 0; if(chat_mode != CHATMODE_NONE) - input_data.state = STATE_CHATTING; + input_data.player_state = PLAYERSTATE_CHATTING; else if(menu_active) - input_data.state = STATE_IN_MENU; + input_data.player_state = PLAYERSTATE_IN_MENU; else { - input_data.state = STATE_PLAYING; + input_data.player_state = PLAYERSTATE_PLAYING; // TODO: this doesn't feel too pretty... look into it? if (console_active()) diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp index 3ee1704d6..00f54c89f 100644 --- a/src/game/client/gc_render_obj.cpp +++ b/src/game/client/gc_render_obj.cpp @@ -434,7 +434,7 @@ void render_player( // render the tee render_tee(&state, &render_info, player.emote, direction, position); - if(player.state == STATE_CHATTING) + if(player.player_state == PLAYERSTATE_CHATTING) { gfx_texture_set(data->images[IMAGE_EMOTICONS].id); gfx_quads_begin(); diff --git a/src/game/g_protocol.h b/src/game/g_protocol.h index 32ddb971a..e63da1437 100644 --- a/src/game/g_protocol.h +++ b/src/game/g_protocol.h @@ -81,10 +81,10 @@ enum enum { - STATE_UNKNOWN=0, - STATE_PLAYING, - STATE_IN_MENU, - STATE_CHATTING, + PLAYERSTATE_UNKNOWN=0, + PLAYERSTATE_PLAYING, + PLAYERSTATE_IN_MENU, + PLAYERSTATE_CHATTING, GAMETYPE_DM=0, GAMETYPE_TDM, @@ -103,7 +103,8 @@ struct player_input int fire; int hook; int blink; - int state; + + int player_state; int wanted_weapon; int next_weapon; @@ -193,7 +194,7 @@ struct obj_player_core // info about the player that is only needed when it's on screen struct obj_player_character : public obj_player_core { - int state; + int player_state; int health; int armor; diff --git a/src/game/server/gs_common.h b/src/game/server/gs_common.h index 2c7b79202..8c4509a23 100644 --- a/src/game/server/gs_common.h +++ b/src/game/server/gs_common.h @@ -216,19 +216,6 @@ class player : public entity { public: static const int phys_size = 28; - - enum // what are these? - { - MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY = 1 << 0, - MODIFIER_RETURNFLAGS_OVERRIDEPOSITION = 1 << 1, - MODIFIER_RETURNFLAGS_OVERRIDEGRAVITY = 1 << 2, - - MODIFIER_RETURNFLAGS_NOHOOK = 1 << 3, - - - WEAPONSTAGE_SNIPER_NEUTRAL = 0, - WEAPONSTAGE_SNIPER_CHARGING = 1, - }; // weapon info entity* hitobjects[10]; @@ -238,23 +225,21 @@ public: int ammoregenstart; int ammo; int ammocost; - int weaponstage; bool got; } weapons[NUM_WEAPONS]; + int active_weapon; int last_weapon; int wanted_weapon; int reload_timer; int attack_tick; - int sniper_chargetick; - int damage_taken; int emote_type; int emote_stop; - int last_action; + int last_action; // last tick that the player took any action ie some input // int client_id; @@ -263,7 +248,6 @@ public: int color_body; int color_feet; - // these are non-heldback inputs player_input latest_previnput; player_input latest_input; @@ -280,17 +264,18 @@ public: int armor; // ninja - vec2 activationdir; - int ninja_activationtick; - int extrapowerflags; - int currentcooldown; - int currentactivation; - int currentmovetime; + struct + { + vec2 activationdir; + int activationtick; + int currentcooldown; + int currentmovetime; + } ninja; // int score; int team; - int state; + int player_state; // if the client is chatting, accessing a menu or so bool spawning; bool dead; @@ -325,8 +310,6 @@ public: int handle_weapons(); int handle_ninja(); - int handle_sniper(); - int handle_bomb(); virtual void tick(); virtual void tick_defered(); diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index 8e1230436..67a8ad976 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -457,7 +457,6 @@ void player::init() proximity_radius = phys_size; client_id = -1; team = -1; // -1 == spectator - extrapowerflags = 0; latency_accum = 0; latency_accum_min = 0; @@ -481,7 +480,7 @@ void player::reset() die_tick = 0; die_pos = vec2(0,0); damage_taken = 0; - state = STATE_UNKNOWN; + player_state = PLAYERSTATE_UNKNOWN; mem_zero(&input, sizeof(input)); mem_zero(&previnput, sizeof(previnput)); @@ -493,9 +492,8 @@ void player::reset() damage_taken_tick = 0; attack_tick = 0; numobjectshit = 0; - ninja_activationtick = 0; - sniper_chargetick = -1; - currentmovetime = 0; + + mem_zero(&ninja, sizeof(ninja)); active_weapon = WEAPON_GUN; last_weapon = WEAPON_HAMMER; @@ -687,13 +685,11 @@ void player::try_respawn() armor = 0; jumped = 0; - ninja_activationtick = 0; - sniper_chargetick = -1; - currentcooldown = 0; + mem_zero(&ninja, sizeof(ninja)); dead = false; set_flag(entity::FLAG_PHYSICS); - state = STATE_PLAYING; + player_state = PLAYERSTATE_PLAYING; core.hook_state = HOOK_IDLE; @@ -735,7 +731,7 @@ int player::handle_ninja() { vec2 direction = normalize(vec2(latest_input.target_x, latest_input.target_y)); - if ((server_tick() - ninja_activationtick) > (data->weapons[WEAPON_NINJA].duration * server_tickspeed() / 1000)) + if ((server_tick() - ninja.activationtick) > (data->weapons[WEAPON_NINJA].duration * server_tickspeed() / 1000)) { // time's up, return weapons[WEAPON_NINJA].got = false; @@ -745,13 +741,13 @@ int player::handle_ninja() } // Check if it should activate - if (count_input(latest_previnput.fire, latest_input.fire).presses && (server_tick() > currentcooldown)) + if (count_input(latest_previnput.fire, latest_input.fire).presses && (server_tick() > ninja.currentcooldown)) { // ok then, activate ninja attack_tick = server_tick(); - activationdir = direction; - currentmovetime = data->weapons[WEAPON_NINJA].movetime * server_tickspeed() / 1000; - currentcooldown = data->weapons[WEAPON_NINJA].firedelay * server_tickspeed() / 1000 + server_tick(); + ninja.activationdir = direction; + ninja.currentmovetime = data->weapons[WEAPON_NINJA].movetime * server_tickspeed() / 1000; + ninja.currentcooldown = data->weapons[WEAPON_NINJA].firedelay * server_tickspeed() / 1000 + server_tick(); // reset hit objects numobjectshit = 0; @@ -763,24 +759,24 @@ int player::handle_ninja() //release_hooks(); } - currentmovetime--; + ninja.currentmovetime--; - if (currentmovetime == 0) + if (ninja.currentmovetime == 0) { // reset player velocity core.vel *= 0.2f; //return MODIFIER_RETURNFLAGS_OVERRIDEWEAPON; } - if (currentmovetime > 0) + if (ninja.currentmovetime > 0) { // Set player velocity - core.vel = activationdir * data->weapons[WEAPON_NINJA].velocity; + core.vel = ninja.activationdir * data->weapons[WEAPON_NINJA].velocity; vec2 oldpos = pos; move_box(&core.pos, &core.vel, vec2(phys_size, phys_size), 0.0f); // reset velocity so the client doesn't predict stuff core.vel = vec2(0.0f,0.0f); - if ((currentmovetime % 2) == 0) + if ((ninja.currentmovetime % 2) == 0) { create_smoke(pos); } @@ -821,114 +817,12 @@ int player::handle_ninja() ents[i]->take_damage(vec2(0,10.0f), data->weapons[WEAPON_NINJA].meleedamage, client_id,WEAPON_NINJA); } } - return MODIFIER_RETURNFLAGS_OVERRIDEVELOCITY | MODIFIER_RETURNFLAGS_OVERRIDEPOSITION | MODIFIER_RETURNFLAGS_OVERRIDEGRAVITY; + return 0; } return 0; } -int player::handle_sniper() -{ - /* - struct input_count button = count_input(previnput.fire, input.fire); - - bool must_release = false; - int current_load = (server_tick()-sniper_chargetick) / server_tickspeed() + 1; - - if(input.fire&1) - { - if(sniper_chargetick == -1) - { - // start charge - sniper_chargetick = server_tick(); - } - else - { - if(current_load > weapons[WEAPON_SNIPER].ammo+3) - must_release = true; - } - } - - if(button.releases || must_release) - { - vec2 direction = normalize(vec2(input.target_x, input.target_y)); - - // released - sniper_chargetick = -1; - - if(current_load > weapons[WEAPON_SNIPER].ammo) - current_load = weapons[WEAPON_SNIPER].ammo; - - weapons[WEAPON_SNIPER].ammo -= current_load; - - new projectile(projectile::WEAPON_PROJECTILETYPE_SNIPER, - client_id, pos+vec2(0,0), direction*50.0f, - 100, this, current_load, 0, 0, -1, WEAPON_SNIPER); - create_sound(pos, SOUND_SNIPER_FIRE); - - } - */ - - /* - if(button.releases) - { - vec2 direction = normalize(vec2(input.target_x, input.target_y)); - // Check if we were charging, if so fire - if (weapons[WEAPON_SNIPER].weaponstage >= WEAPONSTAGE_SNIPER_CHARGING) - { - new projectile(projectile::WEAPON_PROJECTILETYPE_SNIPER, - client_id, pos+vec2(0,0), direction*50.0f, - 100 + weapons[WEAPON_SNIPER].weaponstage * 20,this, weapons[WEAPON_SNIPER].weaponstage, 0, 0, -1, WEAPON_SNIPER); - create_sound(pos, SOUND_SNIPER_FIRE); - } - // Add blowback - core.vel = -direction * 10.0f * weapons[WEAPON_SNIPER].weaponstage; - - // update ammo and stuff - weapons[WEAPON_SNIPER].ammo = max(0,weapons[WEAPON_SNIPER].ammo - weapons[WEAPON_SNIPER].weaponstage); - weapons[WEAPON_SNIPER].weaponstage = WEAPONSTAGE_SNIPER_NEUTRAL; - weapons[WEAPON_SNIPER].chargetick = 0; - } - else if (input.fire & 1) - { - // Charge!! (if we are on the ground) - if (is_grounded() && weapons[WEAPON_SNIPER].ammo > 0) - { - if (!weapons[WEAPON_SNIPER].chargetick) - { - weapons[WEAPON_SNIPER].chargetick = server_tick(); - dbg_msg("game", "Chargetick='%d:'", server_tick()); - } - if ((server_tick() - weapons[WEAPON_SNIPER].chargetick) > server_tickspeed() * data->weapons[active_weapon].chargetime) - { - if (weapons[WEAPON_SNIPER].ammo > weapons[WEAPON_SNIPER].weaponstage) - { - weapons[WEAPON_SNIPER].weaponstage++; - weapons[WEAPON_SNIPER].chargetick = server_tick(); - } - else if ((server_tick() - weapons[WEAPON_SNIPER].chargetick) > server_tickspeed() * data->weapons[active_weapon].overchargetime) - { - // Ooopsie, weapon exploded - create_explosion(pos, client_id, WEAPON_SNIPER, false); - create_sound(pos, SOUND_ROCKET_EXPLODE); - // remove this weapon and change weapon to gun - weapons[WEAPON_SNIPER].got = false; - weapons[WEAPON_SNIPER].ammo = 0; - last_weapon = active_weapon; - active_weapon = WEAPON_GUN; - return 0; - } - } - - // While charging, don't move - return 0; - } - else if (weapons[WEAPON_SNIPER].weaponstage) - weapons[WEAPON_SNIPER].weaponstage = WEAPONSTAGE_SNIPER_NEUTRAL; - }*/ - return 0; -} - int player::handle_weapons() { vec2 direction = normalize(vec2(latest_input.target_x, latest_input.target_y)); @@ -1000,12 +894,6 @@ int player::handle_weapons() } } - // don't update other weapons while sniper is active - /* - if (active_weapon == WEAPON_SNIPER) - return handle_sniper(); - */ - if(reload_timer == 0) { bool fullauto = false; @@ -1257,7 +1145,7 @@ void player::tick() // handle weapons handle_weapons(); - state = input.state; + player_state = input.player_state; // Previnput previnput = input; @@ -1468,7 +1356,6 @@ void player::snap(int snaping_client) character->health = 0; character->armor = 0; character->weapon = active_weapon; - character->weaponstage = weapons[active_weapon].weaponstage; character->attacktick = attack_tick; if(client_id == snaping_client) @@ -1492,7 +1379,7 @@ void player::snap(int snaping_client) character->emote = EMOTE_BLINK; } - character->state = state; + character->player_state = player_state; } } @@ -1589,7 +1476,7 @@ void powerup::tick() case POWERUP_NINJA: { // activate ninja on target player - pplayer->ninja_activationtick = server_tick(); + pplayer->ninja.activationtick = server_tick(); pplayer->weapons[WEAPON_NINJA].got = true; pplayer->last_weapon = pplayer->active_weapon; pplayer->active_weapon = WEAPON_NINJA;