From d711dd190cac809a9bd278fba03ed974812bb863 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 17 Aug 2008 08:52:24 +0000 Subject: continued with clean up --- default.bam | 4 +- src/engine/e_config_variables.h | 2 +- src/game/client/gc_client.cpp | 6 +- src/game/client/gc_client.hpp | 2 +- src/game/client/gc_console.cpp | 2 +- src/game/client/gc_flow.cpp | 2 +- src/game/client/gc_hooks.cpp | 6 +- src/game/client/gc_map_image.cpp | 2 +- src/game/client/gc_menu.cpp | 2 +- src/game/client/gc_render.cpp | 2 +- src/game/client/gc_render.hpp | 2 +- src/game/collision.cpp | 99 +++++++ src/game/collision.hpp | 13 + src/game/editor/ed_editor.cpp | 2 +- src/game/editor/ed_editor.hpp | 2 +- src/game/g_collision.cpp | 99 ------- src/game/g_collision.hpp | 13 - src/game/g_game.cpp | 475 --------------------------------- src/game/g_game.hpp | 161 ----------- src/game/g_layers.cpp | 57 ---- src/game/g_layers.hpp | 12 - src/game/g_mapitems.hpp | 177 ------------ src/game/g_tuning.hpp | 38 --- src/game/g_variables.hpp | 60 ----- src/game/g_version.hpp | 4 - src/game/gamecore.cpp | 475 +++++++++++++++++++++++++++++++++ src/game/gamecore.hpp | 161 +++++++++++ src/game/layers.cpp | 57 ++++ src/game/layers.hpp | 12 + src/game/mapitems.hpp | 177 ++++++++++++ src/game/server/entities/character.hpp | 2 +- src/game/server/gamecontroller.cpp | 2 +- src/game/server/gamemodes/ctf.cpp | 2 +- src/game/server/gameworld.hpp | 2 +- src/game/server/hooks.cpp | 8 +- src/game/tuning.hpp | 38 +++ src/game/variables.hpp | 60 +++++ src/game/version.hpp | 4 + src/tools/fake_server.c | 2 +- 39 files changed, 1123 insertions(+), 1123 deletions(-) create mode 100644 src/game/collision.cpp create mode 100644 src/game/collision.hpp delete mode 100644 src/game/g_collision.cpp delete mode 100644 src/game/g_collision.hpp delete mode 100644 src/game/g_game.cpp delete mode 100644 src/game/g_game.hpp delete mode 100644 src/game/g_layers.cpp delete mode 100644 src/game/g_layers.hpp delete mode 100644 src/game/g_mapitems.hpp delete mode 100644 src/game/g_tuning.hpp delete mode 100644 src/game/g_variables.hpp delete mode 100644 src/game/g_version.hpp create mode 100644 src/game/gamecore.cpp create mode 100644 src/game/gamecore.hpp create mode 100644 src/game/layers.cpp create mode 100644 src/game/layers.hpp create mode 100644 src/game/mapitems.hpp create mode 100644 src/game/tuning.hpp create mode 100644 src/game/variables.hpp create mode 100644 src/game/version.hpp diff --git a/default.bam b/default.bam index 02c04077..bac5326f 100644 --- a/default.bam +++ b/default.bam @@ -107,8 +107,8 @@ nethash = CHash( "src/game/generated/nethash.c", "src/engine/e_protocol.h", "src/game/generated/g_protocol.hpp", - "src/game/g_tuning.hpp", - "src/game/g_game.cpp", network_header) + "src/game/tuning.hpp", + "src/game/gamecore.cpp", network_header) client_link_other = {} if config.compiler.value == "cl" then diff --git a/src/engine/e_config_variables.h b/src/engine/e_config_variables.h index 8396aa88..bceda2fb 100644 --- a/src/engine/e_config_variables.h +++ b/src/engine/e_config_variables.h @@ -1,7 +1,7 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ /* TODO: remove this */ -#include "../game/g_variables.hpp" +#include "../game/variables.hpp" MACRO_CONFIG_STR(player_name, 32, "nameless tee") diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 2be38637..f9900ab3 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -11,9 +11,9 @@ extern "C" { #include }; -#include "../g_game.hpp" -#include "../g_version.hpp" -#include "../g_layers.hpp" +#include "../gamecore.hpp" +#include "../version.hpp" +#include "../layers.hpp" #include "gc_map_image.hpp" #include "../generated/gc_data.hpp" #include "gc_menu.hpp" diff --git a/src/game/client/gc_client.hpp b/src/game/client/gc_client.hpp index 4634aa58..2b6ccd46 100644 --- a/src/game/client/gc_client.hpp +++ b/src/game/client/gc_client.hpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp index d1e517de..eb73ebc6 100644 --- a/src/game/client/gc_console.cpp +++ b/src/game/client/gc_console.cpp @@ -17,7 +17,7 @@ extern "C" { #include "gc_ui.hpp" #include "gc_client.hpp" -#include "../g_version.hpp" +#include "../version.hpp" enum { diff --git a/src/game/client/gc_flow.cpp b/src/game/client/gc_flow.cpp index 63e60617..b18a41e6 100644 --- a/src/game/client/gc_flow.cpp +++ b/src/game/client/gc_flow.cpp @@ -1,7 +1,7 @@ #include #include #include "gc_client.hpp" -#include "../g_layers.hpp" +#include "../layers.hpp" struct FLOWCELL { diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp index 5d9570fb..8db0995f 100644 --- a/src/game/client/gc_hooks.cpp +++ b/src/game/client/gc_hooks.cpp @@ -9,10 +9,10 @@ extern "C" { }; #include -#include -#include +#include +#include -#include +#include #include "gc_client.hpp" #include "gc_skin.hpp" diff --git a/src/game/client/gc_map_image.cpp b/src/game/client/gc_map_image.cpp index b48b6b1d..ca16674a 100644 --- a/src/game/client/gc_map_image.cpp +++ b/src/game/client/gc_map_image.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include "gc_map_image.hpp" static int map_textures[64] = {0}; diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp index c867720b..fb7c5437 100644 --- a/src/game/client/gc_menu.cpp +++ b/src/game/client/gc_menu.cpp @@ -15,7 +15,7 @@ extern "C" { #include } -#include "../g_version.hpp" +#include "../version.hpp" #include #include "../generated/gc_data.hpp" diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp index 28e16686..56e82c69 100644 --- a/src/game/client/gc_render.cpp +++ b/src/game/client/gc_render.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "gc_render.hpp" #include "gc_anim.hpp" #include "gc_client.hpp" diff --git a/src/game/client/gc_render.hpp b/src/game/client/gc_render.hpp index faaff094..e48d0fcd 100644 --- a/src/game/client/gc_render.hpp +++ b/src/game/client/gc_render.hpp @@ -4,7 +4,7 @@ #include -#include "../g_mapitems.hpp" +#include "../mapitems.hpp" #include "gc_ui.hpp" struct TEE_RENDER_INFO diff --git a/src/game/collision.cpp b/src/game/collision.cpp new file mode 100644 index 00000000..c1e08441 --- /dev/null +++ b/src/game/collision.cpp @@ -0,0 +1,99 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#include +#include +#include + +#include +#include +#include +#include + +static TILE *tiles; +static int width = 0; +static int height = 0; + +int col_width() { return width; } +int col_height() { return height; } + +int col_init() +{ + width = layers_game_layer()->width; + height = layers_game_layer()->height; + tiles = (TILE *)map_get_data(layers_game_layer()->data); + return 1; +} + + +int col_is_solid(int x, int y) +{ + int nx = x/32; + int ny = y/32; + if(nx < 0 || nx >= width || ny >= height) + return 1; + + if(y < 0) + return 0; // up == sky == free + + return tiles[ny*width+nx].index == TILE_SOLID; +} + +// TODO: rewrite this smarter! +bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) +{ + float d = distance(pos0, pos1); + + for(float f = 0; f < d; f++) + { + float a = f/d; + vec2 pos = mix(pos0, pos1, a); + if(col_is_solid((int)pos.x, (int)pos.y)) + { + if(out) + *out = pos; + return true; + } + } + if(out) + *out = pos1; + return false; +} + +/* + Simple collision rutines! +*/ +/* +struct collision +{ + int w, h; + unsigned char *data; +}; + +static collision col; +static int global_dividor; + +int col_width() +{ + return col.w; +} + +int col_height() +{ + return col.h; +} + +int col_init(int dividor) +{ + mapres_collision *c = (mapres_collision*)map_find_item(MAPRES_COLLISIONMAP,0); + if(!c) + { + dbg_msg("mapres_col", "failed!"); + return 0; + } + col.w = c->width; + col.h = c->height; + global_dividor = dividor; + col.data = (unsigned char *)map_get_data(c->data_index); + return col.data ? 1 : 0; +} + +*/ diff --git a/src/game/collision.hpp b/src/game/collision.hpp new file mode 100644 index 00000000..735e26c5 --- /dev/null +++ b/src/game/collision.hpp @@ -0,0 +1,13 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef GAME_MAPRES_COL_H +#define GAME_MAPRES_COL_H + +#include + +int col_init(); +int col_is_solid(int x, int y); +int col_width(); +int col_height(); +bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out); + +#endif diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 429c88db..c474d16a 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -14,7 +14,7 @@ extern "C" { #include #include -#include +#include #include #include "ed_editor.hpp" diff --git a/src/game/editor/ed_editor.hpp b/src/game/editor/ed_editor.hpp index a8e8815b..e32b5cb7 100644 --- a/src/game/editor/ed_editor.hpp +++ b/src/game/editor/ed_editor.hpp @@ -6,7 +6,7 @@ #include #include #include "array.hpp" -#include "../g_mapitems.hpp" +#include "../mapitems.hpp" #include "../client/gc_render.hpp" extern "C" { diff --git a/src/game/g_collision.cpp b/src/game/g_collision.cpp deleted file mode 100644 index 510cfba6..00000000 --- a/src/game/g_collision.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include -#include -#include - -#include -#include -#include -#include - -static TILE *tiles; -static int width = 0; -static int height = 0; - -int col_width() { return width; } -int col_height() { return height; } - -int col_init() -{ - width = layers_game_layer()->width; - height = layers_game_layer()->height; - tiles = (TILE *)map_get_data(layers_game_layer()->data); - return 1; -} - - -int col_is_solid(int x, int y) -{ - int nx = x/32; - int ny = y/32; - if(nx < 0 || nx >= width || ny >= height) - return 1; - - if(y < 0) - return 0; // up == sky == free - - return tiles[ny*width+nx].index == TILE_SOLID; -} - -// TODO: rewrite this smarter! -bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out) -{ - float d = distance(pos0, pos1); - - for(float f = 0; f < d; f++) - { - float a = f/d; - vec2 pos = mix(pos0, pos1, a); - if(col_is_solid((int)pos.x, (int)pos.y)) - { - if(out) - *out = pos; - return true; - } - } - if(out) - *out = pos1; - return false; -} - -/* - Simple collision rutines! -*/ -/* -struct collision -{ - int w, h; - unsigned char *data; -}; - -static collision col; -static int global_dividor; - -int col_width() -{ - return col.w; -} - -int col_height() -{ - return col.h; -} - -int col_init(int dividor) -{ - mapres_collision *c = (mapres_collision*)map_find_item(MAPRES_COLLISIONMAP,0); - if(!c) - { - dbg_msg("mapres_col", "failed!"); - return 0; - } - col.w = c->width; - col.h = c->height; - global_dividor = dividor; - col.data = (unsigned char *)map_get_data(c->data_index); - return col.data ? 1 : 0; -} - -*/ diff --git a/src/game/g_collision.hpp b/src/game/g_collision.hpp deleted file mode 100644 index 735e26c5..00000000 --- a/src/game/g_collision.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef GAME_MAPRES_COL_H -#define GAME_MAPRES_COL_H - -#include - -int col_init(); -int col_is_solid(int x, int y); -int col_width(); -int col_height(); -bool col_intersect_line(vec2 pos0, vec2 pos1, vec2 *out); - -#endif diff --git a/src/game/g_game.cpp b/src/game/g_game.cpp deleted file mode 100644 index 2f14b25f..00000000 --- a/src/game/g_game.cpp +++ /dev/null @@ -1,475 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include -#include "g_game.hpp" - -const char *TUNING_PARAMS::names[] = -{ - #define MACRO_TUNING_PARAM(name,value) #name, - #include "g_tuning.hpp" - #undef MACRO_TUNING_PARAM -}; - - -bool TUNING_PARAMS::set(int index, float value) -{ - if(index < 0 || index >= num()) - return false; - ((tune_param *)this)[index] = value; - return true; -} - -bool TUNING_PARAMS::get(int index, float *value) -{ - if(index < 0 || index >= num()) - return false; - *value = (float)((tune_param *)this)[index]; - return true; -} - -bool TUNING_PARAMS::set(const char *name, float value) -{ - for(int i = 0; i < num(); i++) - if(strcmp(name, names[i]) == 0) - return set(i, value); - return false; -} - -bool TUNING_PARAMS::get(const char *name, float *value) -{ - for(int i = 0; i < num(); i++) - if(strcmp(name, names[i]) == 0) - return get(i, value); - - return false; -} - -// TODO: OPT: rewrite this smarter! -void move_point(vec2 *inout_pos, vec2 *inout_vel, float elasticity, int *bounces) -{ - if(bounces) - *bounces = 0; - - vec2 pos = *inout_pos; - vec2 vel = *inout_vel; - if(col_check_point(pos + vel)) - { - int affected = 0; - if(col_check_point(pos.x + vel.x, pos.y)) - { - inout_vel->x *= -elasticity; - if(bounces) - (*bounces)++; - affected++; - } - - if(col_check_point(pos.x, pos.y + vel.y)) - { - inout_vel->y *= -elasticity; - if(bounces) - (*bounces)++; - affected++; - } - - if(affected == 0) - { - inout_vel->x *= -elasticity; - inout_vel->y *= -elasticity; - } - } - else - { - *inout_pos = pos + vel; - } -} - -bool test_box(vec2 pos, vec2 size) -{ - size *= 0.5f; - if(col_check_point(pos.x-size.x, pos.y-size.y)) - return true; - if(col_check_point(pos.x+size.x, pos.y-size.y)) - return true; - if(col_check_point(pos.x-size.x, pos.y+size.y)) - return true; - if(col_check_point(pos.x+size.x, pos.y+size.y)) - return true; - return false; -} - -void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity) -{ - // do the move - vec2 pos = *inout_pos; - vec2 vel = *inout_vel; - - float distance = length(vel); - int max = (int)distance; - - if(distance > 0.00001f) - { - //vec2 old_pos = pos; - float fraction = 1.0f/(float)(max+1); - for(int i = 0; i <= max; i++) - { - //float amount = i/(float)max; - //if(max == 0) - //amount = 0; - - vec2 new_pos = pos + vel*fraction; // TODO: this row is not nice - - if(test_box(vec2(new_pos.x, new_pos.y), size)) - { - int hits = 0; - - if(test_box(vec2(pos.x, new_pos.y), size)) - { - new_pos.y = pos.y; - vel.y *= -elasticity; - hits++; - } - - if(test_box(vec2(new_pos.x, pos.y), size)) - { - new_pos.x = pos.x; - vel.x *= -elasticity; - hits++; - } - - // neither of the tests got a collision. - // this is a real _corner case_! - if(hits == 0) - { - new_pos.y = pos.y; - vel.y *= -elasticity; - new_pos.x = pos.x; - vel.x *= -elasticity; - } - } - - pos = new_pos; - } - } - - *inout_pos = pos; - *inout_vel = vel; -} - -float hermite_basis1(float v) -{ - return 2*v*v*v - 3*v*v+1; -} - -float velocity_ramp(float value, float start, float range, float curvature) -{ - if(value < start) - return 1.0f; - return 1.0f/pow(curvature, (value-start)/range); -} - -void CHARACTER_CORE::reset() -{ - pos = vec2(0,0); - vel = vec2(0,0); - hook_pos = vec2(0,0); - hook_dir = vec2(0,0); - hook_tick = 0; - hook_state = HOOK_IDLE; - hooked_player = -1; - jumped = 0; - triggered_events = 0; -} - -void CHARACTER_CORE::tick() -{ - float phys_size = 28.0f; - triggered_events = 0; - - bool grounded = false; - if(col_check_point((int)(pos.x+phys_size/2), (int)(pos.y+phys_size/2+5))) - grounded = true; - if(col_check_point((int)(pos.x-phys_size/2), (int)(pos.y+phys_size/2+5))) - grounded = true; - - vec2 direction = normalize(vec2(input.target_x, input.target_y)); - - vel.y += world->tuning.gravity; - - float max_speed = grounded ? world->tuning.ground_control_speed : world->tuning.air_control_speed; - float accel = grounded ? world->tuning.ground_control_accel : world->tuning.air_control_accel; - float friction = grounded ? world->tuning.ground_friction : world->tuning.air_friction; - - // handle movement - if(input.direction < 0) - vel.x = saturated_add(-max_speed, max_speed, vel.x, -accel); - if(input.direction > 0) - vel.x = saturated_add(-max_speed, max_speed, vel.x, accel); - - if(input.direction == 0) - vel.x *= friction; - - // handle jumping - // 1 bit = to keep track if a jump has been made on this input - // 2 bit = to keep track if a air-jump has been made - if(grounded) - jumped &= ~2; - - if(input.jump) - { - if(!(jumped&1)) - { - if(grounded) - { - triggered_events |= COREEVENT_GROUND_JUMP; - vel.y = -world->tuning.ground_jump_impulse; - jumped |= 1; - } - else if(!(jumped&2)) - { - triggered_events |= COREEVENT_AIR_JUMP; - vel.y = -world->tuning.air_jump_impulse; - jumped |= 3; - } - } - } - else - jumped &= ~1; - - // do hook - if(input.hook) - { - if(hook_state == HOOK_IDLE) - { - hook_state = HOOK_FLYING; - hook_pos = pos+direction*phys_size*1.5f; - hook_dir = direction; - hooked_player = -1; - hook_tick = 0; - triggered_events |= COREEVENT_HOOK_LAUNCH; - } - else if(hook_state >= HOOK_RETRACT_START && hook_state < HOOK_RETRACT_END) - { - hook_state++; - } - else if(hook_state == HOOK_RETRACT_END) - { - hook_state = HOOK_RETRACTED; - triggered_events |= COREEVENT_HOOK_RETRACT; - hook_state = HOOK_RETRACTED; - } - else if(hook_state == HOOK_FLYING) - { - vec2 new_pos = hook_pos+hook_dir*world->tuning.hook_fire_speed; - if(distance(pos, new_pos) > world->tuning.hook_length) - { - hook_state = HOOK_RETRACT_START; - new_pos = pos + normalize(new_pos-pos) * world->tuning.hook_length; - } - - // make sure that the hook doesn't go though the ground - bool going_to_hit_ground = false; - if(col_intersect_line(hook_pos, new_pos, &new_pos)) - going_to_hit_ground = true; - - // Check against other players first - for(int i = 0; i < MAX_CLIENTS; i++) - { - CHARACTER_CORE *p = world->characters[i]; - if(!p || p == this) - continue; - - vec2 closest_point = closest_point_on_line(hook_pos, new_pos, p->pos); - if(distance(p->pos, closest_point) < phys_size+2.0f) - { - triggered_events |= COREEVENT_HOOK_ATTACH_PLAYER; - hook_state = HOOK_GRABBED; - hooked_player = i; - break; - } - } - - if(hook_state == HOOK_FLYING) - { - // check against ground - if(going_to_hit_ground) - { - triggered_events |= COREEVENT_HOOK_ATTACH_GROUND; - hook_state = HOOK_GRABBED; - } - - hook_pos = new_pos; - } - } - } - else - { - //release_hooked(); - hooked_player = -1; - hook_state = HOOK_IDLE; - hook_pos = pos; - } - - if(hook_state == HOOK_GRABBED) - { - if(hooked_player != -1) - { - CHARACTER_CORE *p = world->characters[hooked_player]; - if(p) - hook_pos = p->pos; - else - { - // release hook - hooked_player = -1; - hook_state = HOOK_RETRACTED; - hook_pos = pos; - } - - // keep players hooked for a max of 1.5sec - //if(server_tick() > hook_tick+(server_tickspeed()*3)/2) - //release_hooked(); - } - - // don't do this hook rutine when we are hook to a player - if(hooked_player == -1 && distance(hook_pos, pos) > 46.0f) - { - vec2 hookvel = normalize(hook_pos-pos)*world->tuning.hook_drag_accel; - // the hook as more power to drag you up then down. - // this makes it easier to get on top of an platform - if(hookvel.y > 0) - hookvel.y *= 0.3f; - - // the hook will boost it's power if the player wants to move - // in that direction. otherwise it will dampen everything abit - if((hookvel.x < 0 && input.direction < 0) || (hookvel.x > 0 && input.direction > 0)) - hookvel.x *= 0.95f; - else - hookvel.x *= 0.75f; - - vec2 new_vel = vel+hookvel; - - // check if we are under the legal limit for the hook - if(length(new_vel) < world->tuning.hook_drag_speed || length(new_vel) < length(vel)) - vel = new_vel; // no problem. apply - - } - - // release hook - hook_tick++; - if(hooked_player != -1 && hook_tick > SERVER_TICK_SPEED*2) - { - hooked_player = -1; - hook_state = HOOK_RETRACTED; - hook_pos = pos; - } - } - - if(true) - { - for(int i = 0; i < MAX_CLIENTS; i++) - { - CHARACTER_CORE *p = world->characters[i]; - if(!p) - continue; - - //player *p = (player*)ent; - if(p == this) // || !(p->flags&FLAG_ALIVE) - continue; // make sure that we don't nudge our self - - // handle player <-> player collision - float d = distance(pos, p->pos); - vec2 dir = normalize(pos - p->pos); - if(d < phys_size*1.25f && d > 1.0f) - { - float a = (phys_size*1.45f - d); - - // make sure that we don't add excess force by checking the - // direction against the current velocity - vec2 veldir = normalize(vel); - float v = 1-(dot(veldir, dir)+1)/2; - vel = vel + dir*a*(v*0.75f); - vel = vel * 0.85f; - } - - // handle hook influence - if(hooked_player == i) - { - if(d > phys_size*1.50f) // TODO: fix tweakable variable - { - float accel = world->tuning.hook_drag_accel * (d/world->tuning.hook_length); - float drag_speed = world->tuning.hook_drag_speed; - - // add force to the hooked player - p->vel.x = saturated_add(-drag_speed, drag_speed, p->vel.x, accel*dir.x*1.5f); - p->vel.y = saturated_add(-drag_speed, drag_speed, p->vel.y, accel*dir.y*1.5f); - - // add a little bit force to the guy who has the grip - vel.x = saturated_add(-drag_speed, drag_speed, vel.x, -accel*dir.x*0.25f); - vel.y = saturated_add(-drag_speed, drag_speed, vel.y, -accel*dir.y*0.25f); - } - } - } - } - - // clamp the velocity to something sane - if(length(vel) > 6000) - vel = normalize(vel) * 6000; -} - -void CHARACTER_CORE::move() -{ - float rampvalue = velocity_ramp(length(vel)*50, world->tuning.velramp_start, world->tuning.velramp_range, world->tuning.velramp_curvature); - - vel.x = vel.x*rampvalue; - move_box(&pos, &vel, vec2(28.0f, 28.0f), 0); - vel.x = vel.x*(1.0f/rampvalue); -} - -void CHARACTER_CORE::write(NETOBJ_CHARACTER_CORE *obj_core) -{ - obj_core->x = (int)pos.x; - obj_core->y = (int)pos.y; - obj_core->vx = (int)(vel.x*256.0f); - obj_core->vy = (int)(vel.y*256.0f); - obj_core->hook_state = hook_state; - obj_core->hook_tick = hook_tick; - obj_core->hook_x = (int)hook_pos.x; - obj_core->hook_y = (int)hook_pos.y; - obj_core->hook_dx = (int)(hook_dir.x*256.0f); - obj_core->hook_dy = (int)(hook_dir.y*256.0f); - obj_core->hooked_player = hooked_player; - obj_core->jumped = jumped; - - float a = 0; - if(input.target_x == 0) - a = atan((float)input.target_y); - else - a = atan((float)input.target_y/(float)input.target_x); - - if(input.target_x < 0) - a = a+pi; - - obj_core->angle = (int)(a*256.0f); -} - -void CHARACTER_CORE::read(const NETOBJ_CHARACTER_CORE *obj_core) -{ - pos.x = obj_core->x; - pos.y = obj_core->y; - vel.x = obj_core->vx/256.0f; - vel.y = obj_core->vy/256.0f; - hook_state = obj_core->hook_state; - hook_tick = obj_core->hook_tick; - hook_pos.x = obj_core->hook_x; - hook_pos.y = obj_core->hook_y; - hook_dir.x = obj_core->hook_dx/256.0f; - hook_dir.y = obj_core->hook_dy/256.0f; - hooked_player = obj_core->hooked_player; - jumped = obj_core->jumped; -} - -void CHARACTER_CORE::quantize() -{ - NETOBJ_CHARACTER_CORE c; - write(&c); - read(&c); -} - diff --git a/src/game/g_game.hpp b/src/game/g_game.hpp deleted file mode 100644 index 29c948b9..00000000 --- a/src/game/g_game.hpp +++ /dev/null @@ -1,161 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef GAME_GAME_H -#define GAME_GAME_H - -#include -#include - -#include -#include -#include "g_collision.hpp" -#include - -struct TUNING_PARAMS -{ - TUNING_PARAMS() - { - const float ticks_per_second = 50.0f; - #define MACRO_TUNING_PARAM(name,value) name.set((int)(value*100.0f)); - #include "g_tuning.hpp" - #undef MACRO_TUNING_PARAM - } - - static const char *names[]; - - #define MACRO_TUNING_PARAM(name,value) tune_param name; - #include "g_tuning.hpp" - #undef MACRO_TUNING_PARAM - - static int num() { return sizeof(TUNING_PARAMS)/sizeof(int); } - bool set(int index, float value); - bool set(const char *name, float value); - bool get(int index, float *value); - bool get(const char *name, float *value); -}; - - -inline vec2 get_direction(int angle) -{ - float a = angle/256.0f; - return vec2(cosf(a), sinf(a)); -} - -inline vec2 get_dir(float a) -{ - return vec2(cosf(a), sinf(a)); -} - -inline float get_angle(vec2 dir) -{ - float a = atan(dir.y/dir.x); - if(dir.x < 0) - a = a+pi; - return a; -} - - -inline vec2 calc_pos(vec2 p, vec2 v, float curvature, float speed, float t) -{ - vec2 n; - t *= speed; - n.x = p.x + v.x*t; - n.y = p.y + v.y*t + curvature/10000*(t*t); - return n; -} - - -template -inline T saturated_add(T min, T max, T current, T modifier) -{ - if(modifier < 0) - { - if(current < min) - return current; - current += modifier; - if(current < min) - current = min; - return current; - } - else - { - if(current > max) - return current; - current += modifier; - if(current > max) - current = max; - return current; - } -} - -void move_point(vec2 *inout_pos, vec2 *inout_vel, float elasticity, int *bounces); -void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity); -bool test_box(vec2 pos, vec2 size); -float velocity_ramp(float value, float start, float range, float curvature); - -// hooking stuff -enum -{ - HOOK_RETRACTED=-1, - HOOK_IDLE=0, - HOOK_RETRACT_START=1, - HOOK_RETRACT_END=3, - HOOK_FLYING, - HOOK_GRABBED, - - COREEVENT_GROUND_JUMP=0x01, - COREEVENT_AIR_JUMP=0x02, - COREEVENT_HOOK_LAUNCH=0x04, - COREEVENT_HOOK_ATTACH_PLAYER=0x08, - COREEVENT_HOOK_ATTACH_GROUND=0x10, - COREEVENT_HOOK_RETRACT=0x20, -}; - -class WORLD_CORE -{ -public: - WORLD_CORE() - { - mem_zero(characters, sizeof(characters)); - } - - TUNING_PARAMS tuning; - class CHARACTER_CORE *characters[MAX_CLIENTS]; -}; - -class CHARACTER_CORE -{ -public: - WORLD_CORE *world; - - vec2 pos; - vec2 vel; - - vec2 hook_pos; - vec2 hook_dir; - int hook_tick; - int hook_state; - int hooked_player; - - int jumped; - NETOBJ_PLAYER_INPUT input; - - int triggered_events; - - void reset(); - void tick(); - void move(); - - void read(const NETOBJ_CHARACTER_CORE *obj_core); - void write(NETOBJ_CHARACTER_CORE *obj_core); - void quantize(); -}; - - -#define LERP(a,b,t) (a + (b-a) * t) -#define min(a, b) ( a > b ? b : a) -#define max(a, b) ( a > b ? a : b) - -inline bool col_check_point(float x, float y) { return col_is_solid((int)x, (int)y) != 0; } -inline bool col_check_point(vec2 p) { return col_check_point(p.x, p.y); } - -#endif diff --git a/src/game/g_layers.cpp b/src/game/g_layers.cpp deleted file mode 100644 index 254bc083..00000000 --- a/src/game/g_layers.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include "g_layers.hpp" - -static MAPITEM_LAYER_TILEMAP *game_layer = 0; -static MAPITEM_GROUP *game_group = 0; - -static int groups_start = 0; -static int groups_num = 0; -static int layers_start = 0; -static int layers_num = 0; - -void layers_init() -{ - map_get_type(MAPITEMTYPE_GROUP, &groups_start, &groups_num); - map_get_type(MAPITEMTYPE_LAYER, &layers_start, &layers_num); - - for(int g = 0; g < layers_num_groups(); g++) - { - MAPITEM_GROUP *group = layers_get_group(g); - for(int l = 0; l < group->num_layers; l++) - { - MAPITEM_LAYER *layer = layers_get_layer(group->start_layer+l); - - if(layer->type == LAYERTYPE_TILES) - { - MAPITEM_LAYER_TILEMAP *tilemap = (MAPITEM_LAYER_TILEMAP *)layer; - if(tilemap->flags&1) - { - game_layer = tilemap; - game_group = group; - } - } - } - } -} - -int layers_num_groups() { return groups_num; } -MAPITEM_GROUP *layers_get_group(int index) -{ - return (MAPITEM_GROUP *)map_get_item(groups_start+index, 0, 0); -} - -MAPITEM_LAYER *layers_get_layer(int index) -{ - return (MAPITEM_LAYER *)map_get_item(layers_start+index, 0, 0); -} - -MAPITEM_LAYER_TILEMAP *layers_game_layer() -{ - return game_layer; -} - -MAPITEM_GROUP *layers_game_group() -{ - return game_group; -} - diff --git a/src/game/g_layers.hpp b/src/game/g_layers.hpp deleted file mode 100644 index f977bd65..00000000 --- a/src/game/g_layers.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "g_mapitems.hpp" - -void layers_init(); - -MAPITEM_LAYER_TILEMAP *layers_game_layer(); -MAPITEM_GROUP *layers_game_group(); - -int layers_num_groups(); -MAPITEM_GROUP *layers_get_group(int index); -MAPITEM_LAYER *layers_get_layer(int index); - - diff --git a/src/game/g_mapitems.hpp b/src/game/g_mapitems.hpp deleted file mode 100644 index 8093435a..00000000 --- a/src/game/g_mapitems.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef GAME_MAPITEMS_H -#define GAME_MAPITEMS_H - -// layer types -enum -{ - LAYERTYPE_INVALID=0, - LAYERTYPE_GAME, // not used - LAYERTYPE_TILES, - LAYERTYPE_QUADS, - - MAPITEMTYPE_VERSION=0, - MAPITEMTYPE_INFO, - MAPITEMTYPE_IMAGE, - MAPITEMTYPE_ENVELOPE, - MAPITEMTYPE_GROUP, - MAPITEMTYPE_LAYER, - MAPITEMTYPE_ENVPOINTS, - - - CURVETYPE_STEP=0, - CURVETYPE_LINEAR, - CURVETYPE_SLOW, - CURVETYPE_FAST, - CURVETYPE_SMOOTH, - NUM_CURVETYPES, - - // game layer tiles - ENTITY_NULL=0, - ENTITY_SPAWN, - ENTITY_SPAWN_RED, - ENTITY_SPAWN_BLUE, - ENTITY_FLAGSTAND_RED, - ENTITY_FLAGSTAND_BLUE, - ENTITY_ARMOR_1, - ENTITY_HEALTH_1, - ENTITY_WEAPON_SHOTGUN, - ENTITY_WEAPON_GRENADE, - ENTITY_POWERUP_NINJA, - ENTITY_WEAPON_RIFLE, - NUM_ENTITIES, - - TILE_AIR=0, - TILE_SOLID, - TILE_NOHOOK, - - TILEFLAG_VFLIP=1, - TILEFLAG_HFLIP=2, - TILEFLAG_OPAQUE=4, - - LAYERFLAG_DETAIL=1, - - ENTITY_OFFSET=255-16*4, -}; - -typedef struct -{ - int x, y; // 22.10 fixed point -} POINT; - -typedef struct -{ - int r, g, b, a; -} COLOR; - -typedef struct -{ - POINT points[5]; - COLOR colors[4]; - POINT texcoords[4]; - - int pos_env; - int pos_env_offset; - - int color_env; - int color_env_offset; -} QUAD; - -typedef struct -{ - unsigned char index; - unsigned char flags; - unsigned char skip; - unsigned char reserved; -} TILE; - -typedef struct -{ - int version; - int width; - int height; - int external; - int image_name; - int image_data; -} MAPITEM_IMAGE; - -struct MAPITEM_GROUP_v1 -{ - int version; - int offset_x; - int offset_y; - int parallax_x; - int parallax_y; - - int start_layer; - int num_layers; -} ; - - -struct MAPITEM_GROUP : public MAPITEM_GROUP_v1 -{ - enum { CURRENT_VERSION=2 }; - - int use_clipping; - int clip_x; - int clip_y; - int clip_w; - int clip_h; -} ; - -typedef struct -{ - int version; - int type; - int flags; -} MAPITEM_LAYER; - -typedef struct -{ - MAPITEM_LAYER layer; - int version; - - int width; - int height; - int flags; - - COLOR color; - int color_env; - int color_env_offset; - - int image; - int data; -} MAPITEM_LAYER_TILEMAP; - -typedef struct -{ - MAPITEM_LAYER layer; - int version; - - int num_quads; - int data; - int image; -} MAPITEM_LAYER_QUADS; - -typedef struct -{ - int version; -} MAPITEM_VERSION; - -typedef struct -{ - int time; // in ms - int curvetype; - int values[4]; // 1-4 depending on envelope (22.10 fixed point) -} ENVPOINT; - -typedef struct -{ - int version; - int channels; - int start_point; - int num_points; - int name; -} MAPITEM_ENVELOPE; - -#endif diff --git a/src/game/g_tuning.hpp b/src/game/g_tuning.hpp deleted file mode 100644 index d35ef148..00000000 --- a/src/game/g_tuning.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* physics tuning */ -MACRO_TUNING_PARAM(ground_control_speed, 10.0f) -MACRO_TUNING_PARAM(ground_control_accel, 100.0f / ticks_per_second) -MACRO_TUNING_PARAM(ground_friction, 0.5f) -MACRO_TUNING_PARAM(ground_jump_impulse, 12.6f) -MACRO_TUNING_PARAM(air_jump_impulse, 11.5f) -MACRO_TUNING_PARAM(air_control_speed, 250.0f / ticks_per_second) -MACRO_TUNING_PARAM(air_control_accel, 1.5f) -MACRO_TUNING_PARAM(air_friction, 0.95f) -MACRO_TUNING_PARAM(hook_length, 380.0f) -MACRO_TUNING_PARAM(hook_fire_speed, 80.0f) -MACRO_TUNING_PARAM(hook_drag_accel, 3.0f) -MACRO_TUNING_PARAM(hook_drag_speed, 15.0f) -MACRO_TUNING_PARAM(gravity, 0.5f) - -MACRO_TUNING_PARAM(velramp_start, 550) -MACRO_TUNING_PARAM(velramp_range, 2000) -MACRO_TUNING_PARAM(velramp_curvature, 1.4f) - -/* weapon tuning */ -MACRO_TUNING_PARAM(gun_curvature, 1.25f) -MACRO_TUNING_PARAM(gun_speed, 2200.0f) -MACRO_TUNING_PARAM(gun_lifetime, 2.0f) - -MACRO_TUNING_PARAM(shotgun_curvature, 1.25f) -MACRO_TUNING_PARAM(shotgun_speed, 2200.0f) -MACRO_TUNING_PARAM(shotgun_speeddiff, 0.8f) -MACRO_TUNING_PARAM(shotgun_lifetime, 0.25f) - -MACRO_TUNING_PARAM(grenade_curvature, 7.0f) -MACRO_TUNING_PARAM(grenade_speed, 1000.0f) -MACRO_TUNING_PARAM(grenade_lifetime, 2.0f) - -MACRO_TUNING_PARAM(laser_reach, 800.0f) -MACRO_TUNING_PARAM(laser_bounce_delay, 150) -MACRO_TUNING_PARAM(laser_bounce_num, 1) -MACRO_TUNING_PARAM(laser_bounce_cost, 0) -MACRO_TUNING_PARAM(laser_damage, 5) diff --git a/src/game/g_variables.hpp b/src/game/g_variables.hpp deleted file mode 100644 index c0852bc4..00000000 --- a/src/game/g_variables.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -MACRO_CONFIG_INT(cl_predict, 1, 0, 1) -MACRO_CONFIG_INT(cl_nameplates, 0, 0, 1) -MACRO_CONFIG_INT(cl_nameplates_always, 0, 0, 1) -MACRO_CONFIG_INT(cl_autoswitch_weapons, 0, 0, 1) - -MACRO_CONFIG_INT(cl_showfps, 0, 0, 1) - -MACRO_CONFIG_INT(cl_airjumpindicator, 1, 0, 1) -MACRO_CONFIG_INT(cl_threadsoundloading, 0, 0, 1) - - -MACRO_CONFIG_INT(cl_warning_tuning, 1, 0, 1) - -MACRO_CONFIG_INT(cl_mouse_deadzone, 300, 0, 0) -MACRO_CONFIG_INT(cl_mouse_followfactor, 60, 0, 200) -MACRO_CONFIG_INT(cl_mouse_max_distance, 800, 0, 0) - -MACRO_CONFIG_INT(cl_layershot, 0, 0, 1) - -MACRO_CONFIG_INT(ed_showkeys, 0, 0, 1) - -MACRO_CONFIG_INT(cl_flow, 0, 0, 1) - -MACRO_CONFIG_INT(cl_show_welcome, 1, 0, 1) -MACRO_CONFIG_INT(cl_motd_time, 10, 0, 100) - -MACRO_CONFIG_INT(player_use_custom_color, 0, 0, 1) -MACRO_CONFIG_INT(player_color_body, 65408, 0, 0) -MACRO_CONFIG_INT(player_color_feet, 65408, 0, 0) -MACRO_CONFIG_STR(player_skin, 64, "default") - -MACRO_CONFIG_INT(dbg_dummies, 0, 0, 11) -MACRO_CONFIG_INT(dbg_firedelay, 0, 0, 1) -MACRO_CONFIG_INT(dbg_flow, 0, 0, 1) -MACRO_CONFIG_INT(dbg_tuning, 0, 0, 1) - -MACRO_CONFIG_INT(ui_page, 3, 0, 5) -MACRO_CONFIG_STR(ui_server_address, 128, "localhost:8303") -MACRO_CONFIG_INT(ui_scale, 100, 1, 100000) - -MACRO_CONFIG_INT(ui_color_hue, 160, 0, 255) -MACRO_CONFIG_INT(ui_color_sat, 70, 0, 255) -MACRO_CONFIG_INT(ui_color_lht, 175, 0, 255) -MACRO_CONFIG_INT(ui_color_alpha, 228, 0, 255) - - -MACRO_CONFIG_INT(sv_warmup, 0, 0, 0) -MACRO_CONFIG_STR(sv_motd, 900, "") -MACRO_CONFIG_INT(sv_teamdamage, 0, 0, 1) -MACRO_CONFIG_STR(sv_maprotation, 512, "") -MACRO_CONFIG_INT(sv_rounds_per_map, 1, 1, 100) -MACRO_CONFIG_INT(sv_powerups, 1, 0, 1) -MACRO_CONFIG_INT(sv_scorelimit, 20, 0, 1000) -MACRO_CONFIG_INT(sv_timelimit, 0, 0, 1000) -MACRO_CONFIG_STR(sv_gametype, 32, "dm") -MACRO_CONFIG_INT(sv_tournament_mode, 0, 0, 1) -MACRO_CONFIG_INT(sv_spamprotection, 1, 0, 1) - -MACRO_CONFIG_INT(sv_spectator_slots, 0, 0, 12) diff --git a/src/game/g_version.hpp b/src/game/g_version.hpp deleted file mode 100644 index 7472c783..00000000 --- a/src/game/g_version.hpp +++ /dev/null @@ -1,4 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include "generated/nethash.c" -#define GAME_VERSION "0.5.0-dev" -#define GAME_NETVERSION "0.5 " GAME_NETVERSION_HASH diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp new file mode 100644 index 00000000..7c8dabe0 --- /dev/null +++ b/src/game/gamecore.cpp @@ -0,0 +1,475 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#include +#include "gamecore.hpp" + +const char *TUNING_PARAMS::names[] = +{ + #define MACRO_TUNING_PARAM(name,value) #name, + #include "tuning.hpp" + #undef MACRO_TUNING_PARAM +}; + + +bool TUNING_PARAMS::set(int index, float value) +{ + if(index < 0 || index >= num()) + return false; + ((tune_param *)this)[index] = value; + return true; +} + +bool TUNING_PARAMS::get(int index, float *value) +{ + if(index < 0 || index >= num()) + return false; + *value = (float)((tune_param *)this)[index]; + return true; +} + +bool TUNING_PARAMS::set(const char *name, float value) +{ + for(int i = 0; i < num(); i++) + if(strcmp(name, names[i]) == 0) + return set(i, value); + return false; +} + +bool TUNING_PARAMS::get(const char *name, float *value) +{ + for(int i = 0; i < num(); i++) + if(strcmp(name, names[i]) == 0) + return get(i, value); + + return false; +} + +// TODO: OPT: rewrite this smarter! +void move_point(vec2 *inout_pos, vec2 *inout_vel, float elasticity, int *bounces) +{ + if(bounces) + *bounces = 0; + + vec2 pos = *inout_pos; + vec2 vel = *inout_vel; + if(col_check_point(pos + vel)) + { + int affected = 0; + if(col_check_point(pos.x + vel.x, pos.y)) + { + inout_vel->x *= -elasticity; + if(bounces) + (*bounces)++; + affected++; + } + + if(col_check_point(pos.x, pos.y + vel.y)) + { + inout_vel->y *= -elasticity; + if(bounces) + (*bounces)++; + affected++; + } + + if(affected == 0) + { + inout_vel->x *= -elasticity; + inout_vel->y *= -elasticity; + } + } + else + { + *inout_pos = pos + vel; + } +} + +bool test_box(vec2 pos, vec2 size) +{ + size *= 0.5f; + if(col_check_point(pos.x-size.x, pos.y-size.y)) + return true; + if(col_check_point(pos.x+size.x, pos.y-size.y)) + return true; + if(col_check_point(pos.x-size.x, pos.y+size.y)) + return true; + if(col_check_point(pos.x+size.x, pos.y+size.y)) + return true; + return false; +} + +void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity) +{ + // do the move + vec2 pos = *inout_pos; + vec2 vel = *inout_vel; + + float distance = length(vel); + int max = (int)distance; + + if(distance > 0.00001f) + { + //vec2 old_pos = pos; + float fraction = 1.0f/(float)(max+1); + for(int i = 0; i <= max; i++) + { + //float amount = i/(float)max; + //if(max == 0) + //amount = 0; + + vec2 new_pos = pos + vel*fraction; // TODO: this row is not nice + + if(test_box(vec2(new_pos.x, new_pos.y), size)) + { + int hits = 0; + + if(test_box(vec2(pos.x, new_pos.y), size)) + { + new_pos.y = pos.y; + vel.y *= -elasticity; + hits++; + } + + if(test_box(vec2(new_pos.x, pos.y), size)) + { + new_pos.x = pos.x; + vel.x *= -elasticity; + hits++; + } + + // neither of the tests got a collision. + // this is a real _corner case_! + if(hits == 0) + { + new_pos.y = pos.y; + vel.y *= -elasticity; + new_pos.x = pos.x; + vel.x *= -elasticity; + } + } + + pos = new_pos; + } + } + + *inout_pos = pos; + *inout_vel = vel; +} + +float hermite_basis1(float v) +{ + return 2*v*v*v - 3*v*v+1; +} + +float velocity_ramp(float value, float start, float range, float curvature) +{ + if(value < start) + return 1.0f; + return 1.0f/pow(curvature, (value-start)/range); +} + +void CHARACTER_CORE::reset() +{ + pos = vec2(0,0); + vel = vec2(0,0); + hook_pos = vec2(0,0); + hook_dir = vec2(0,0); + hook_tick = 0; + hook_state = HOOK_IDLE; + hooked_player = -1; + jumped = 0; + triggered_events = 0; +} + +void CHARACTER_CORE::tick() +{ + float phys_size = 28.0f; + triggered_events = 0; + + bool grounded = false; + if(col_check_point((int)(pos.x+phys_size/2), (int)(pos.y+phys_size/2+5))) + grounded = true; + if(col_check_point((int)(pos.x-phys_size/2), (int)(pos.y+phys_size/2+5))) + grounded = true; + + vec2 direction = normalize(vec2(input.target_x, input.target_y)); + + vel.y += world->tuning.gravity; + + float max_speed = grounded ? world->tuning.ground_control_speed : world->tuning.air_control_speed; + float accel = grounded ? world->tuning.ground_control_accel : world->tuning.air_control_accel; + float friction = grounded ? world->tuning.ground_friction : world->tuning.air_friction; + + // handle movement + if(input.direction < 0) + vel.x = saturated_add(-max_speed, max_speed, vel.x, -accel); + if(input.direction > 0) + vel.x = saturated_add(-max_speed, max_speed, vel.x, accel); + + if(input.direction == 0) + vel.x *= friction; + + // handle jumping + // 1 bit = to keep track if a jump has been made on this input + // 2 bit = to keep track if a air-jump has been made + if(grounded) + jumped &= ~2; + + if(input.jump) + { + if(!(jumped&1)) + { + if(grounded) + { + triggered_events |= COREEVENT_GROUND_JUMP; + vel.y = -world->tuning.ground_jump_impulse; + jumped |= 1; + } + else if(!(jumped&2)) + { + triggered_events |= COREEVENT_AIR_JUMP; + vel.y = -world->tuning.air_jump_impulse; + jumped |= 3; + } + } + } + else + jumped &= ~1; + + // do hook + if(input.hook) + { + if(hook_state == HOOK_IDLE) + { + hook_state = HOOK_FLYING; + hook_pos = pos+direction*phys_size*1.5f; + hook_dir = direction; + hooked_player = -1; + hook_tick = 0; + triggered_events |= COREEVENT_HOOK_LAUNCH; + } + else if(hook_state >= HOOK_RETRACT_START && hook_state < HOOK_RETRACT_END) + { + hook_state++; + } + else if(hook_state == HOOK_RETRACT_END) + { + hook_state = HOOK_RETRACTED; + triggered_events |= COREEVENT_HOOK_RETRACT; + hook_state = HOOK_RETRACTED; + } + else if(hook_state == HOOK_FLYING) + { + vec2 new_pos = hook_pos+hook_dir*world->tuning.hook_fire_speed; + if(distance(pos, new_pos) > world->tuning.hook_length) + { + hook_state = HOOK_RETRACT_START; + new_pos = pos + normalize(new_pos-pos) * world->tuning.hook_length; + } + + // make sure that the hook doesn't go though the ground + bool going_to_hit_ground = false; + if(col_intersect_line(hook_pos, new_pos, &new_pos)) + going_to_hit_ground = true; + + // Check against other players first + for(int i = 0; i < MAX_CLIENTS; i++) + { + CHARACTER_CORE *p = world->characters[i]; + if(!p || p == this) + continue; + + vec2 closest_point = closest_point_on_line(hook_pos, new_pos, p->pos); + if(distance(p->pos, closest_point) < phys_size+2.0f) + { + triggered_events |= COREEVENT_HOOK_ATTACH_PLAYER; + hook_state = HOOK_GRABBED; + hooked_player = i; + break; + } + } + + if(hook_state == HOOK_FLYING) + { + // check against ground + if(going_to_hit_ground) + { + triggered_events |= COREEVENT_HOOK_ATTACH_GROUND; + hook_state = HOOK_GRABBED; + } + + hook_pos = new_pos; + } + } + } + else + { + //release_hooked(); + hooked_player = -1; + hook_state = HOOK_IDLE; + hook_pos = pos; + } + + if(hook_state == HOOK_GRABBED) + { + if(hooked_player != -1) + { + CHARACTER_CORE *p = world->characters[hooked_player]; + if(p) + hook_pos = p->pos; + else + { + // release hook + hooked_player = -1; + hook_state = HOOK_RETRACTED; + hook_pos = pos; + } + + // keep players hooked for a max of 1.5sec + //if(server_tick() > hook_tick+(server_tickspeed()*3)/2) + //release_hooked(); + } + + // don't do this hook rutine when we are hook to a player + if(hooked_player == -1 && distance(hook_pos, pos) > 46.0f) + { + vec2 hookvel = normalize(hook_pos-pos)*world->tuning.hook_drag_accel; + // the hook as more power to drag you up then down. + // this makes it easier to get on top of an platform + if(hookvel.y > 0) + hookvel.y *= 0.3f; + + // the hook will boost it's power if the player wants to move + // in that direction. otherwise it will dampen everything abit + if((hookvel.x < 0 && input.direction < 0) || (hookvel.x > 0 && input.direction > 0)) + hookvel.x *= 0.95f; + else + hookvel.x *= 0.75f; + + vec2 new_vel = vel+hookvel; + + // check if we are under the legal limit for the hook + if(length(new_vel) < world->tuning.hook_drag_speed || length(new_vel) < length(vel)) + vel = new_vel; // no problem. apply + + } + + // release hook + hook_tick++; + if(hooked_player != -1 && hook_tick > SERVER_TICK_SPEED*2) + { + hooked_player = -1; + hook_state = HOOK_RETRACTED; + hook_pos = pos; + } + } + + if(true) + { + for(int i = 0; i < MAX_CLIENTS; i++) + { + CHARACTER_CORE *p = world->characters[i]; + if(!p) + continue; + + //player *p = (player*)ent; + if(p == this) // || !(p->flags&FLAG_ALIVE) + continue; // make sure that we don't nudge our self + + // handle player <-> player collision + float d = distance(pos, p->pos); + vec2 dir = normalize(pos - p->pos); + if(d < phys_size*1.25f && d > 1.0f) + { + float a = (phys_size*1.45f - d); + + // make sure that we don't add excess force by checking the + // direction against the current velocity + vec2 veldir = normalize(vel); + float v = 1-(dot(veldir, dir)+1)/2; + vel = vel + dir*a*(v*0.75f); + vel = vel * 0.85f; + } + + // handle hook influence + if(hooked_player == i) + { + if(d > phys_size*1.50f) // TODO: fix tweakable variable + { + float accel = world->tuning.hook_drag_accel * (d/world->tuning.hook_length); + float drag_speed = world->tuning.hook_drag_speed; + + // add force to the hooked player + p->vel.x = saturated_add(-drag_speed, drag_speed, p->vel.x, accel*dir.x*1.5f); + p->vel.y = saturated_add(-drag_speed, drag_speed, p->vel.y, accel*dir.y*1.5f); + + // add a little bit force to the guy who has the grip + vel.x = saturated_add(-drag_speed, drag_speed, vel.x, -accel*dir.x*0.25f); + vel.y = saturated_add(-drag_speed, drag_speed, vel.y, -accel*dir.y*0.25f); + } + } + } + } + + // clamp the velocity to something sane + if(length(vel) > 6000) + vel = normalize(vel) * 6000; +} + +void CHARACTER_CORE::move() +{ + float rampvalue = velocity_ramp(length(vel)*50, world->tuning.velramp_start, world->tuning.velramp_range, world->tuning.velramp_curvature); + + vel.x = vel.x*rampvalue; + move_box(&pos, &vel, vec2(28.0f, 28.0f), 0); + vel.x = vel.x*(1.0f/rampvalue); +} + +void CHARACTER_CORE::write(NETOBJ_CHARACTER_CORE *obj_core) +{ + obj_core->x = (int)pos.x; + obj_core->y = (int)pos.y; + obj_core->vx = (int)(vel.x*256.0f); + obj_core->vy = (int)(vel.y*256.0f); + obj_core->hook_state = hook_state; + obj_core->hook_tick = hook_tick; + obj_core->hook_x = (int)hook_pos.x; + obj_core->hook_y = (int)hook_pos.y; + obj_core->hook_dx = (int)(hook_dir.x*256.0f); + obj_core->hook_dy = (int)(hook_dir.y*256.0f); + obj_core->hooked_player = hooked_player; + obj_core->jumped = jumped; + + float a = 0; + if(input.target_x == 0) + a = atan((float)input.target_y); + else + a = atan((float)input.target_y/(float)input.target_x); + + if(input.target_x < 0) + a = a+pi; + + obj_core->angle = (int)(a*256.0f); +} + +void CHARACTER_CORE::read(const NETOBJ_CHARACTER_CORE *obj_core) +{ + pos.x = obj_core->x; + pos.y = obj_core->y; + vel.x = obj_core->vx/256.0f; + vel.y = obj_core->vy/256.0f; + hook_state = obj_core->hook_state; + hook_tick = obj_core->hook_tick; + hook_pos.x = obj_core->hook_x; + hook_pos.y = obj_core->hook_y; + hook_dir.x = obj_core->hook_dx/256.0f; + hook_dir.y = obj_core->hook_dy/256.0f; + hooked_player = obj_core->hooked_player; + jumped = obj_core->jumped; +} + +void CHARACTER_CORE::quantize() +{ + NETOBJ_CHARACTER_CORE c; + write(&c); + read(&c); +} + diff --git a/src/game/gamecore.hpp b/src/game/gamecore.hpp new file mode 100644 index 00000000..1f9dda81 --- /dev/null +++ b/src/game/gamecore.hpp @@ -0,0 +1,161 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef GAME_GAME_H +#define GAME_GAME_H + +#include +#include + +#include +#include +#include "collision.hpp" +#include + +struct TUNING_PARAMS +{ + TUNING_PARAMS() + { + const float ticks_per_second = 50.0f; + #define MACRO_TUNING_PARAM(name,value) name.set((int)(value*100.0f)); + #include "tuning.hpp" + #undef MACRO_TUNING_PARAM + } + + static const char *names[]; + + #define MACRO_TUNING_PARAM(name,value) tune_param name; + #include "tuning.hpp" + #undef MACRO_TUNING_PARAM + + static int num() { return sizeof(TUNING_PARAMS)/sizeof(int); } + bool set(int index, float value); + bool set(const char *name, float value); + bool get(int index, float *value); + bool get(const char *name, float *value); +}; + + +inline vec2 get_direction(int angle) +{ + float a = angle/256.0f; + return vec2(cosf(a), sinf(a)); +} + +inline vec2 get_dir(float a) +{ + return vec2(cosf(a), sinf(a)); +} + +inline float get_angle(vec2 dir) +{ + float a = atan(dir.y/dir.x); + if(dir.x < 0) + a = a+pi; + return a; +} + + +inline vec2 calc_pos(vec2 p, vec2 v, float curvature, float speed, float t) +{ + vec2 n; + t *= speed; + n.x = p.x + v.x*t; + n.y = p.y + v.y*t + curvature/10000*(t*t); + return n; +} + + +template +inline T saturated_add(T min, T max, T current, T modifier) +{ + if(modifier < 0) + { + if(current < min) + return current; + current += modifier; + if(current < min) + current = min; + return current; + } + else + { + if(current > max) + return current; + current += modifier; + if(current > max) + current = max; + return current; + } +} + +void move_point(vec2 *inout_pos, vec2 *inout_vel, float elasticity, int *bounces); +void move_box(vec2 *inout_pos, vec2 *inout_vel, vec2 size, float elasticity); +bool test_box(vec2 pos, vec2 size); +float velocity_ramp(float value, float start, float range, float curvature); + +// hooking stuff +enum +{ + HOOK_RETRACTED=-1, + HOOK_IDLE=0, + HOOK_RETRACT_START=1, + HOOK_RETRACT_END=3, + HOOK_FLYING, + HOOK_GRABBED, + + COREEVENT_GROUND_JUMP=0x01, + COREEVENT_AIR_JUMP=0x02, + COREEVENT_HOOK_LAUNCH=0x04, + COREEVENT_HOOK_ATTACH_PLAYER=0x08, + COREEVENT_HOOK_ATTACH_GROUND=0x10, + COREEVENT_HOOK_RETRACT=0x20, +}; + +class WORLD_CORE +{ +public: + WORLD_CORE() + { + mem_zero(characters, sizeof(characters)); + } + + TUNING_PARAMS tuning; + class CHARACTER_CORE *characters[MAX_CLIENTS]; +}; + +class CHARACTER_CORE +{ +public: + WORLD_CORE *world; + + vec2 pos; + vec2 vel; + + vec2 hook_pos; + vec2 hook_dir; + int hook_tick; + int hook_state; + int hooked_player; + + int jumped; + NETOBJ_PLAYER_INPUT input; + + int triggered_events; + + void reset(); + void tick(); + void move(); + + void read(const NETOBJ_CHARACTER_CORE *obj_core); + void write(NETOBJ_CHARACTER_CORE *obj_core); + void quantize(); +}; + + +#define LERP(a,b,t) (a + (b-a) * t) +#define min(a, b) ( a > b ? b : a) +#define max(a, b) ( a > b ? a : b) + +inline bool col_check_point(float x, float y) { return col_is_solid((int)x, (int)y) != 0; } +inline bool col_check_point(vec2 p) { return col_check_point(p.x, p.y); } + +#endif diff --git a/src/game/layers.cpp b/src/game/layers.cpp new file mode 100644 index 00000000..832dc766 --- /dev/null +++ b/src/game/layers.cpp @@ -0,0 +1,57 @@ +#include +#include "layers.hpp" + +static MAPITEM_LAYER_TILEMAP *game_layer = 0; +static MAPITEM_GROUP *game_group = 0; + +static int groups_start = 0; +static int groups_num = 0; +static int layers_start = 0; +static int layers_num = 0; + +void layers_init() +{ + map_get_type(MAPITEMTYPE_GROUP, &groups_start, &groups_num); + map_get_type(MAPITEMTYPE_LAYER, &layers_start, &layers_num); + + for(int g = 0; g < layers_num_groups(); g++) + { + MAPITEM_GROUP *group = layers_get_group(g); + for(int l = 0; l < group->num_layers; l++) + { + MAPITEM_LAYER *layer = layers_get_layer(group->start_layer+l); + + if(layer->type == LAYERTYPE_TILES) + { + MAPITEM_LAYER_TILEMAP *tilemap = (MAPITEM_LAYER_TILEMAP *)layer; + if(tilemap->flags&1) + { + game_layer = tilemap; + game_group = group; + } + } + } + } +} + +int layers_num_groups() { return groups_num; } +MAPITEM_GROUP *layers_get_group(int index) +{ + return (MAPITEM_GROUP *)map_get_item(groups_start+index, 0, 0); +} + +MAPITEM_LAYER *layers_get_layer(int index) +{ + return (MAPITEM_LAYER *)map_get_item(layers_start+index, 0, 0); +} + +MAPITEM_LAYER_TILEMAP *layers_game_layer() +{ + return game_layer; +} + +MAPITEM_GROUP *layers_game_group() +{ + return game_group; +} + diff --git a/src/game/layers.hpp b/src/game/layers.hpp new file mode 100644 index 00000000..cb18419b --- /dev/null +++ b/src/game/layers.hpp @@ -0,0 +1,12 @@ +#include "mapitems.hpp" + +void layers_init(); + +MAPITEM_LAYER_TILEMAP *layers_game_layer(); +MAPITEM_GROUP *layers_game_group(); + +int layers_num_groups(); +MAPITEM_GROUP *layers_get_group(int index); +MAPITEM_LAYER *layers_get_layer(int index); + + diff --git a/src/game/mapitems.hpp b/src/game/mapitems.hpp new file mode 100644 index 00000000..8093435a --- /dev/null +++ b/src/game/mapitems.hpp @@ -0,0 +1,177 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef GAME_MAPITEMS_H +#define GAME_MAPITEMS_H + +// layer types +enum +{ + LAYERTYPE_INVALID=0, + LAYERTYPE_GAME, // not used + LAYERTYPE_TILES, + LAYERTYPE_QUADS, + + MAPITEMTYPE_VERSION=0, + MAPITEMTYPE_INFO, + MAPITEMTYPE_IMAGE, + MAPITEMTYPE_ENVELOPE, + MAPITEMTYPE_GROUP, + MAPITEMTYPE_LAYER, + MAPITEMTYPE_ENVPOINTS, + + + CURVETYPE_STEP=0, + CURVETYPE_LINEAR, + CURVETYPE_SLOW, + CURVETYPE_FAST, + CURVETYPE_SMOOTH, + NUM_CURVETYPES, + + // game layer tiles + ENTITY_NULL=0, + ENTITY_SPAWN, + ENTITY_SPAWN_RED, + ENTITY_SPAWN_BLUE, + ENTITY_FLAGSTAND_RED, + ENTITY_FLAGSTAND_BLUE, + ENTITY_ARMOR_1, + ENTITY_HEALTH_1, + ENTITY_WEAPON_SHOTGUN, + ENTITY_WEAPON_GRENADE, + ENTITY_POWERUP_NINJA, + ENTITY_WEAPON_RIFLE, + NUM_ENTITIES, + + TILE_AIR=0, + TILE_SOLID, + TILE_NOHOOK, + + TILEFLAG_VFLIP=1, + TILEFLAG_HFLIP=2, + TILEFLAG_OPAQUE=4, + + LAYERFLAG_DETAIL=1, + + ENTITY_OFFSET=255-16*4, +}; + +typedef struct +{ + int x, y; // 22.10 fixed point +} POINT; + +typedef struct +{ + int r, g, b, a; +} COLOR; + +typedef struct +{ + POINT points[5]; + COLOR colors[4]; + POINT texcoords[4]; + + int pos_env; + int pos_env_offset; + + int color_env; + int color_env_offset; +} QUAD; + +typedef struct +{ + unsigned char index; + unsigned char flags; + unsigned char skip; + unsigned char reserved; +} TILE; + +typedef struct +{ + int version; + int width; + int height; + int external; + int image_name; + int image_data; +} MAPITEM_IMAGE; + +struct MAPITEM_GROUP_v1 +{ + int version; + int offset_x; + int offset_y; + int parallax_x; + int parallax_y; + + int start_layer; + int num_layers; +} ; + + +struct MAPITEM_GROUP : public MAPITEM_GROUP_v1 +{ + enum { CURRENT_VERSION=2 }; + + int use_clipping; + int clip_x; + int clip_y; + int clip_w; + int clip_h; +} ; + +typedef struct +{ + int version; + int type; + int flags; +} MAPITEM_LAYER; + +typedef struct +{ + MAPITEM_LAYER layer; + int version; + + int width; + int height; + int flags; + + COLOR color; + int color_env; + int color_env_offset; + + int image; + int data; +} MAPITEM_LAYER_TILEMAP; + +typedef struct +{ + MAPITEM_LAYER layer; + int version; + + int num_quads; + int data; + int image; +} MAPITEM_LAYER_QUADS; + +typedef struct +{ + int version; +} MAPITEM_VERSION; + +typedef struct +{ + int time; // in ms + int curvetype; + int values[4]; // 1-4 depending on envelope (22.10 fixed point) +} ENVPOINT; + +typedef struct +{ + int version; + int channels; + int start_point; + int num_points; + int name; +} MAPITEM_ENVELOPE; + +#endif diff --git a/src/game/server/entities/character.hpp b/src/game/server/entities/character.hpp index 6ceb987c..2536bb79 100644 --- a/src/game/server/entities/character.hpp +++ b/src/game/server/entities/character.hpp @@ -7,7 +7,7 @@ #include #include -#include +#include class CHARACTER : public ENTITY { diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 30cc6e78..b0a16cd6 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include diff --git a/src/game/server/gamemodes/ctf.cpp b/src/game/server/gamemodes/ctf.cpp index 4733ae82..8d1cdef8 100644 --- a/src/game/server/gamemodes/ctf.cpp +++ b/src/game/server/gamemodes/ctf.cpp @@ -1,6 +1,6 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include +#include #include #include #include diff --git a/src/game/server/gameworld.hpp b/src/game/server/gameworld.hpp index de441f8d..4757ad67 100644 --- a/src/game/server/gameworld.hpp +++ b/src/game/server/gameworld.hpp @@ -1,7 +1,7 @@ #ifndef GAME_SERVER_GAMEWORLD_H #define GAME_SERVER_GAMEWORLD_H -#include +#include class ENTITY; class CHARACTER; diff --git a/src/game/server/hooks.cpp b/src/game/server/hooks.cpp index 43563483..328cfb4f 100644 --- a/src/game/server/hooks.cpp +++ b/src/game/server/hooks.cpp @@ -7,12 +7,12 @@ #include #include -#include -#include -#include +#include +#include +#include -#include +#include #include "gamecontext.hpp" #include "gamemodes/dm.hpp" diff --git a/src/game/tuning.hpp b/src/game/tuning.hpp new file mode 100644 index 00000000..d35ef148 --- /dev/null +++ b/src/game/tuning.hpp @@ -0,0 +1,38 @@ +/* physics tuning */ +MACRO_TUNING_PARAM(ground_control_speed, 10.0f) +MACRO_TUNING_PARAM(ground_control_accel, 100.0f / ticks_per_second) +MACRO_TUNING_PARAM(ground_friction, 0.5f) +MACRO_TUNING_PARAM(ground_jump_impulse, 12.6f) +MACRO_TUNING_PARAM(air_jump_impulse, 11.5f) +MACRO_TUNING_PARAM(air_control_speed, 250.0f / ticks_per_second) +MACRO_TUNING_PARAM(air_control_accel, 1.5f) +MACRO_TUNING_PARAM(air_friction, 0.95f) +MACRO_TUNING_PARAM(hook_length, 380.0f) +MACRO_TUNING_PARAM(hook_fire_speed, 80.0f) +MACRO_TUNING_PARAM(hook_drag_accel, 3.0f) +MACRO_TUNING_PARAM(hook_drag_speed, 15.0f) +MACRO_TUNING_PARAM(gravity, 0.5f) + +MACRO_TUNING_PARAM(velramp_start, 550) +MACRO_TUNING_PARAM(velramp_range, 2000) +MACRO_TUNING_PARAM(velramp_curvature, 1.4f) + +/* weapon tuning */ +MACRO_TUNING_PARAM(gun_curvature, 1.25f) +MACRO_TUNING_PARAM(gun_speed, 2200.0f) +MACRO_TUNING_PARAM(gun_lifetime, 2.0f) + +MACRO_TUNING_PARAM(shotgun_curvature, 1.25f) +MACRO_TUNING_PARAM(shotgun_speed, 2200.0f) +MACRO_TUNING_PARAM(shotgun_speeddiff, 0.8f) +MACRO_TUNING_PARAM(shotgun_lifetime, 0.25f) + +MACRO_TUNING_PARAM(grenade_curvature, 7.0f) +MACRO_TUNING_PARAM(grenade_speed, 1000.0f) +MACRO_TUNING_PARAM(grenade_lifetime, 2.0f) + +MACRO_TUNING_PARAM(laser_reach, 800.0f) +MACRO_TUNING_PARAM(laser_bounce_delay, 150) +MACRO_TUNING_PARAM(laser_bounce_num, 1) +MACRO_TUNING_PARAM(laser_bounce_cost, 0) +MACRO_TUNING_PARAM(laser_damage, 5) diff --git a/src/game/variables.hpp b/src/game/variables.hpp new file mode 100644 index 00000000..c0852bc4 --- /dev/null +++ b/src/game/variables.hpp @@ -0,0 +1,60 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +MACRO_CONFIG_INT(cl_predict, 1, 0, 1) +MACRO_CONFIG_INT(cl_nameplates, 0, 0, 1) +MACRO_CONFIG_INT(cl_nameplates_always, 0, 0, 1) +MACRO_CONFIG_INT(cl_autoswitch_weapons, 0, 0, 1) + +MACRO_CONFIG_INT(cl_showfps, 0, 0, 1) + +MACRO_CONFIG_INT(cl_airjumpindicator, 1, 0, 1) +MACRO_CONFIG_INT(cl_threadsoundloading, 0, 0, 1) + + +MACRO_CONFIG_INT(cl_warning_tuning, 1, 0, 1) + +MACRO_CONFIG_INT(cl_mouse_deadzone, 300, 0, 0) +MACRO_CONFIG_INT(cl_mouse_followfactor, 60, 0, 200) +MACRO_CONFIG_INT(cl_mouse_max_distance, 800, 0, 0) + +MACRO_CONFIG_INT(cl_layershot, 0, 0, 1) + +MACRO_CONFIG_INT(ed_showkeys, 0, 0, 1) + +MACRO_CONFIG_INT(cl_flow, 0, 0, 1) + +MACRO_CONFIG_INT(cl_show_welcome, 1, 0, 1) +MACRO_CONFIG_INT(cl_motd_time, 10, 0, 100) + +MACRO_CONFIG_INT(player_use_custom_color, 0, 0, 1) +MACRO_CONFIG_INT(player_color_body, 65408, 0, 0) +MACRO_CONFIG_INT(player_color_feet, 65408, 0, 0) +MACRO_CONFIG_STR(player_skin, 64, "default") + +MACRO_CONFIG_INT(dbg_dummies, 0, 0, 11) +MACRO_CONFIG_INT(dbg_firedelay, 0, 0, 1) +MACRO_CONFIG_INT(dbg_flow, 0, 0, 1) +MACRO_CONFIG_INT(dbg_tuning, 0, 0, 1) + +MACRO_CONFIG_INT(ui_page, 3, 0, 5) +MACRO_CONFIG_STR(ui_server_address, 128, "localhost:8303") +MACRO_CONFIG_INT(ui_scale, 100, 1, 100000) + +MACRO_CONFIG_INT(ui_color_hue, 160, 0, 255) +MACRO_CONFIG_INT(ui_color_sat, 70, 0, 255) +MACRO_CONFIG_INT(ui_color_lht, 175, 0, 255) +MACRO_CONFIG_INT(ui_color_alpha, 228, 0, 255) + + +MACRO_CONFIG_INT(sv_warmup, 0, 0, 0) +MACRO_CONFIG_STR(sv_motd, 900, "") +MACRO_CONFIG_INT(sv_teamdamage, 0, 0, 1) +MACRO_CONFIG_STR(sv_maprotation, 512, "") +MACRO_CONFIG_INT(sv_rounds_per_map, 1, 1, 100) +MACRO_CONFIG_INT(sv_powerups, 1, 0, 1) +MACRO_CONFIG_INT(sv_scorelimit, 20, 0, 1000) +MACRO_CONFIG_INT(sv_timelimit, 0, 0, 1000) +MACRO_CONFIG_STR(sv_gametype, 32, "dm") +MACRO_CONFIG_INT(sv_tournament_mode, 0, 0, 1) +MACRO_CONFIG_INT(sv_spamprotection, 1, 0, 1) + +MACRO_CONFIG_INT(sv_spectator_slots, 0, 0, 12) diff --git a/src/game/version.hpp b/src/game/version.hpp new file mode 100644 index 00000000..7472c783 --- /dev/null +++ b/src/game/version.hpp @@ -0,0 +1,4 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#include "generated/nethash.c" +#define GAME_VERSION "0.5.0-dev" +#define GAME_NETVERSION "0.5 " GAME_NETVERSION_HASH diff --git a/src/tools/fake_server.c b/src/tools/fake_server.c index 602617ad..1ea999fe 100644 --- a/src/tools/fake_server.c +++ b/src/tools/fake_server.c @@ -180,7 +180,7 @@ int main(int argc, char **argv) if(strcmp(*argv, "-m") == 0) { argc--; argv++; - net_host_lookup(*argv, 0, &master_servers[num_masters]); + net_host_lookup(*argv, &master_servers[num_masters], NETTYPE_IPV4); argc--; argv++; master_servers[num_masters].port = atoi(*argv); num_masters++; -- cgit 1.4.1