From 3705064b109580103a3d13f44693503da9927281 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Thu, 12 Jun 2008 12:09:34 +0000 Subject: renamed .h to .hpp in game because they are c++ headers --- datasrc/compile.py | 6 +- datasrc/network.py | 2 +- default.bam | 10 +- src/engine/e_config_variables.h | 4 +- src/game/client/gc_anim.h | 14 -- src/game/client/gc_anim.hpp | 14 ++ src/game/client/gc_client.cpp | 28 +-- src/game/client/gc_client.h | 275 ---------------------------- src/game/client/gc_client.hpp | 275 ++++++++++++++++++++++++++++ src/game/client/gc_console.cpp | 10 +- src/game/client/gc_console.h | 19 -- src/game/client/gc_console.hpp | 19 ++ src/game/client/gc_effects.cpp | 6 +- src/game/client/gc_flow.cpp | 4 +- src/game/client/gc_hooks.cpp | 18 +- src/game/client/gc_map_image.cpp | 4 +- src/game/client/gc_map_image.h | 10 -- src/game/client/gc_map_image.hpp | 10 ++ src/game/client/gc_menu.cpp | 20 +-- src/game/client/gc_menu.h | 5 - src/game/client/gc_menu.hpp | 5 + src/game/client/gc_particles.cpp | 4 +- src/game/client/gc_render.cpp | 16 +- src/game/client/gc_render.h | 82 --------- src/game/client/gc_render.hpp | 82 +++++++++ src/game/client/gc_render_map.cpp | 4 +- src/game/client/gc_render_obj.cpp | 14 +- src/game/client/gc_skin.cpp | 4 +- src/game/client/gc_skin.h | 21 --- src/game/client/gc_skin.hpp | 21 +++ src/game/client/gc_ui.cpp | 2 +- src/game/client/gc_ui.h | 65 ------- src/game/client/gc_ui.hpp | 65 +++++++ src/game/editor/array.h | 238 ------------------------- src/game/editor/array.hpp | 238 +++++++++++++++++++++++++ src/game/editor/ed_editor.cpp | 8 +- src/game/editor/ed_editor.hpp | 10 +- src/game/editor/ed_layer_quads.cpp | 6 +- src/game/editor/ed_layer_tiles.cpp | 6 +- src/game/g_collision.cpp | 8 +- src/game/g_collision.h | 14 -- src/game/g_collision.hpp | 14 ++ src/game/g_game.cpp | 4 +- src/game/g_game.h | 160 ----------------- src/game/g_game.hpp | 160 +++++++++++++++++ src/game/g_layers.cpp | 2 +- src/game/g_layers.h | 12 -- src/game/g_layers.hpp | 12 ++ src/game/g_mapitems.h | 177 ------------------ src/game/g_mapitems.hpp | 177 ++++++++++++++++++ src/game/g_math.h | 61 ------- src/game/g_math.hpp | 61 +++++++ src/game/g_protocol.h | 217 ---------------------- src/game/g_protocol.hpp | 217 ++++++++++++++++++++++ src/game/g_tuning.h | 38 ---- src/game/g_tuning.hpp | 38 ++++ src/game/g_variables.h | 59 ------ src/game/g_variables.hpp | 59 ++++++ src/game/g_version.h | 4 - src/game/g_version.hpp | 4 + src/game/g_vmath.h | 198 -------------------- src/game/g_vmath.hpp | 198 ++++++++++++++++++++ src/game/server/gs_common.h | 357 ------------------------------------- src/game/server/gs_common.hpp | 357 +++++++++++++++++++++++++++++++++++++ src/game/server/gs_game.cpp | 4 +- src/game/server/gs_game_ctf.cpp | 6 +- src/game/server/gs_game_ctf.h | 35 ---- src/game/server/gs_game_ctf.hpp | 35 ++++ src/game/server/gs_game_dm.cpp | 4 +- src/game/server/gs_game_dm.h | 7 - src/game/server/gs_game_dm.hpp | 7 + src/game/server/gs_game_tdm.cpp | 4 +- src/game/server/gs_game_tdm.h | 10 -- src/game/server/gs_game_tdm.hpp | 10 ++ src/game/server/gs_server.cpp | 16 +- 75 files changed, 2196 insertions(+), 2194 deletions(-) delete mode 100644 src/game/client/gc_anim.h create mode 100644 src/game/client/gc_anim.hpp delete mode 100644 src/game/client/gc_client.h create mode 100644 src/game/client/gc_client.hpp delete mode 100644 src/game/client/gc_console.h create mode 100644 src/game/client/gc_console.hpp delete mode 100644 src/game/client/gc_map_image.h create mode 100644 src/game/client/gc_map_image.hpp delete mode 100644 src/game/client/gc_menu.h create mode 100644 src/game/client/gc_menu.hpp delete mode 100644 src/game/client/gc_render.h create mode 100644 src/game/client/gc_render.hpp delete mode 100644 src/game/client/gc_skin.h create mode 100644 src/game/client/gc_skin.hpp delete mode 100644 src/game/client/gc_ui.h create mode 100644 src/game/client/gc_ui.hpp delete mode 100755 src/game/editor/array.h create mode 100755 src/game/editor/array.hpp delete mode 100644 src/game/g_collision.h create mode 100644 src/game/g_collision.hpp delete mode 100644 src/game/g_game.h create mode 100644 src/game/g_game.hpp delete mode 100644 src/game/g_layers.h create mode 100644 src/game/g_layers.hpp delete mode 100644 src/game/g_mapitems.h create mode 100644 src/game/g_mapitems.hpp delete mode 100644 src/game/g_math.h create mode 100644 src/game/g_math.hpp delete mode 100644 src/game/g_protocol.h create mode 100644 src/game/g_protocol.hpp delete mode 100644 src/game/g_tuning.h create mode 100644 src/game/g_tuning.hpp delete mode 100644 src/game/g_variables.h create mode 100644 src/game/g_variables.hpp delete mode 100644 src/game/g_version.h create mode 100644 src/game/g_version.hpp delete mode 100644 src/game/g_vmath.h create mode 100644 src/game/g_vmath.hpp delete mode 100644 src/game/server/gs_common.h create mode 100644 src/game/server/gs_common.hpp delete mode 100644 src/game/server/gs_game_ctf.h create mode 100644 src/game/server/gs_game_ctf.hpp delete mode 100644 src/game/server/gs_game_dm.h create mode 100644 src/game/server/gs_game_dm.hpp delete mode 100644 src/game/server/gs_game_tdm.h create mode 100644 src/game/server/gs_game_tdm.hpp diff --git a/datasrc/compile.py b/datasrc/compile.py index 38457e91..af0671de 100644 --- a/datasrc/compile.py +++ b/datasrc/compile.py @@ -57,9 +57,9 @@ if gen_client_content_header or gen_server_content_header: if gen_client_content_source or gen_server_content_source: if gen_client_content_source: - print '#include "gc_data.h"' + print '#include "gc_data.hpp"' if gen_server_content_source: - print '#include "gs_data.h"' + print '#include "gs_data.hpp"' EmitDefinition(content.container, "datacontainer") print 'DATACONTAINER *data = &datacontainer;'; @@ -99,7 +99,7 @@ if gen_network_source: lines = [] lines += ['#include '] - lines += ['#include "g_protocol.h"'] + lines += ['#include "g_protocol.hpp"'] lines += ['const char *msg_failed_on = "";'] lines += ['const char *obj_corrected_on = "";'] diff --git a/datasrc/network.py b/datasrc/network.py index 6f03adb9..46add62b 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -17,7 +17,7 @@ enum RawSource = ''' #include -#include "g_protocol.h" +#include "g_protocol.hpp" ''' Enums = [ diff --git a/default.bam b/default.bam index 672f77c4..f79b20ae 100644 --- a/default.bam +++ b/default.bam @@ -93,11 +93,11 @@ end -- Content Compile network_source = ContentCompile("network_source", "src/game/generated/g_protocol.cpp") -network_header = ContentCompile("network_header", "src/game/generated/g_protocol.h") +network_header = ContentCompile("network_header", "src/game/generated/g_protocol.hpp") client_content_source = ContentCompile("client_content_source", "src/game/generated/gc_data.cpp") -client_content_header = ContentCompile("client_content_header", "src/game/generated/gc_data.h") +client_content_header = ContentCompile("client_content_header", "src/game/generated/gc_data.hpp") server_content_source = ContentCompile("server_content_source", "src/game/generated/gs_data.cpp") -server_content_header = ContentCompile("server_content_header", "src/game/generated/gs_data.h") +server_content_header = ContentCompile("server_content_header", "src/game/generated/gs_data.hpp") bam_add_dependency(network_source, network_header) bam_add_dependency(client_content_source, client_content_header) @@ -106,8 +106,8 @@ bam_add_dependency(server_content_source, server_content_header) nethash = CHash( "src/game/generated/nethash.c", "src/engine/e_protocol.h", - "src/game/generated/g_protocol.h", - "src/game/g_tuning.h", + "src/game/generated/g_protocol.hpp", + "src/game/g_tuning.hpp", "src/game/g_game.cpp", network_header) client_link_other = {} diff --git a/src/engine/e_config_variables.h b/src/engine/e_config_variables.h index 3683fc85..3707f0e6 100644 --- a/src/engine/e_config_variables.h +++ b/src/engine/e_config_variables.h @@ -1,5 +1,7 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include "../game/g_variables.h" + +/* TODO: remove this */ +#include "../game/g_variables.hpp" MACRO_CONFIG_STR(player_name, 32, "nameless tee") diff --git a/src/game/client/gc_anim.h b/src/game/client/gc_anim.h deleted file mode 100644 index f6e9aac3..00000000 --- a/src/game/client/gc_anim.h +++ /dev/null @@ -1,14 +0,0 @@ - -struct ANIM_STATE -{ - ANIM_KEYFRAME body; - ANIM_KEYFRAME back_foot; - ANIM_KEYFRAME front_foot; - ANIM_KEYFRAME attach; -}; - -void anim_seq_eval(ANIM_SEQUENCE *seq, float time, ANIM_KEYFRAME *frame); -void anim_eval(ANIMATION *anim, float time, ANIM_STATE *state); -void anim_add_keyframe(ANIM_KEYFRAME *seq, ANIM_KEYFRAME *added, float amount); -void anim_add(ANIM_STATE *state, ANIM_STATE *added, float amount); -void anim_eval_add(ANIM_STATE *state, ANIMATION *anim, float time, float amount); diff --git a/src/game/client/gc_anim.hpp b/src/game/client/gc_anim.hpp new file mode 100644 index 00000000..f6e9aac3 --- /dev/null +++ b/src/game/client/gc_anim.hpp @@ -0,0 +1,14 @@ + +struct ANIM_STATE +{ + ANIM_KEYFRAME body; + ANIM_KEYFRAME back_foot; + ANIM_KEYFRAME front_foot; + ANIM_KEYFRAME attach; +}; + +void anim_seq_eval(ANIM_SEQUENCE *seq, float time, ANIM_KEYFRAME *frame); +void anim_eval(ANIMATION *anim, float time, ANIM_STATE *state); +void anim_add_keyframe(ANIM_KEYFRAME *seq, ANIM_KEYFRAME *added, float amount); +void anim_add(ANIM_STATE *state, ANIM_STATE *added, float amount); +void anim_eval_add(ANIM_STATE *state, ANIMATION *anim, float time, float amount); diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp index 89c7ffcd..c42c354e 100644 --- a/src/game/client/gc_client.cpp +++ b/src/game/client/gc_client.cpp @@ -1,5 +1,5 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include +#include #include #include #include @@ -10,19 +10,19 @@ extern "C" { #include }; -#include "../g_game.h" -#include "../g_version.h" -#include "../g_layers.h" -#include "../g_math.h" -#include "gc_map_image.h" -#include "../generated/gc_data.h" -#include "gc_menu.h" -#include "gc_skin.h" -#include "gc_ui.h" -#include "gc_client.h" -#include "gc_render.h" -#include "gc_anim.h" -#include "gc_console.h" +#include "../g_game.hpp" +#include "../g_version.hpp" +#include "../g_layers.hpp" +#include "../g_math.hpp" +#include "gc_map_image.hpp" +#include "../generated/gc_data.hpp" +#include "gc_menu.hpp" +#include "gc_skin.hpp" +#include "gc_ui.hpp" +#include "gc_client.hpp" +#include "gc_render.hpp" +#include "gc_anim.hpp" +#include "gc_console.hpp" //struct data_container *data = 0; int64 debug_firedelay = 0; diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h deleted file mode 100644 index bb8a69cf..00000000 --- a/src/game/client/gc_client.h +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include - -#include - -// sound channels -enum -{ - CHN_GUI=0, - CHN_MUSIC, - CHN_WORLD, - CHN_GLOBAL, -}; - -//extern struct data_container *data; - -extern vec2 mouse_pos; -extern vec2 local_character_pos; -extern vec2 local_target_pos; - -// snap pointers -struct SNAPSTATE -{ - const NETOBJ_PLAYER_CHARACTER *local_character; - const NETOBJ_PLAYER_CHARACTER *local_prev_character; - const NETOBJ_PLAYER_INFO *local_info; - const NETOBJ_FLAG *flags[2]; - const NETOBJ_GAME *gameobj; - - const NETOBJ_PLAYER_INFO *player_infos[MAX_CLIENTS]; - const NETOBJ_PLAYER_INFO *info_by_score[MAX_CLIENTS]; - int num_players; -}; - -extern SNAPSTATE netobjects; - -/* -extern const NETOBJ_PLAYER_CHARACTER *local_character; -extern const NETOBJ_PLAYER_CHARACTER *local_prev_character; -extern const NETOBJ_PLAYER_INFO *local_info; -extern const NETOBJ_FLAG *flags[2]; -extern const NETOBJ_GAME *gameobj; -* */ - -extern TUNING_PARAMS tuning; - -// predicted players -extern PLAYER_CORE predicted_prev_player; -extern PLAYER_CORE predicted_player; - -// input -extern NETOBJ_PLAYER_INPUT input_data; -extern int input_direction_left; -extern int input_direction_right; - -// debug -extern int64 debug_firedelay; - -// extra projs -enum -{ - MAX_EXTRA_PROJECTILES=32, -}; - -extern NETOBJ_PROJECTILE extraproj_projectiles[MAX_EXTRA_PROJECTILES]; -extern int extraproj_num; - -void extraproj_reset(); - -// chat -enum -{ - CHATMODE_NONE=0, - CHATMODE_ALL, - CHATMODE_TEAM, -}; - -extern int chat_mode; -void chat_add_line(int client_id, int team, const char *line); -void chat_reset(); -bool chat_input_handle(INPUT_EVENT e, void *user_data); - -// broadcasts -extern char broadcast_text[1024]; -extern int64 broadcast_time; - -// motd -extern int64 server_motd_time; -extern char server_motd[900]; // FUGLY - -// line input helter -class line_input -{ - char str[256]; - unsigned len; - unsigned cursor_pos; -public: - class callback - { - public: - virtual ~callback() {} - virtual bool event(INPUT_EVENT e) = 0; - }; - - line_input(); - void clear(); - void process_input(INPUT_EVENT e); - void set(const char *string); - const char *get_string() const { return str; } - int get_length() const { return len; } - unsigned cursor_offset() const { return cursor_pos; } -}; - -class INPUT_STACK_HANDLER -{ -public: - typedef bool (*CALLBACK)(INPUT_EVENT e, void *user); - - INPUT_STACK_HANDLER(); - void add_handler(CALLBACK cb, void *user_data); - void dispatch_input(); - -private: - enum - { - MAX_HANDLERS=16 - }; - - CALLBACK handlers[MAX_HANDLERS]; - void *user_data[MAX_HANDLERS]; - int num_handlers; -}; - -extern INPUT_STACK_HANDLER input_stack; - - -extern int emoticon_selector_active; // TODO: ugly -extern int scoreboard_active; // TODO: ugly - -// client data -struct CLIENT_DATA -{ - char name[64]; - char skin_name[64]; - int skin_id; - int skin_color; - int team; - int emoticon; - int emoticon_start; - PLAYER_CORE predicted; - - TEE_RENDER_INFO skin_info; // this is what the server reports - TEE_RENDER_INFO render_info; // this is what we use - - float angle; - - void update_render_info(); -}; - -extern CLIENT_DATA client_datas[MAX_CLIENTS]; - -// kill messages -struct KILLMSG -{ - int weapon; - int victim; - int killer; - int mode_special; // for CTF, if the guy is carrying a flag for example - int tick; -}; - -const int killmsg_max = 5; -extern KILLMSG killmsgs[killmsg_max]; -extern int killmsg_current; - -// -void send_switch_team(int team); - -// various helpers -void snd_play_random(int chn, int setid, float vol, vec2 pos); -void process_events(int snaptype); -void clear_object_pointers(); -void reset_projectile_particles(); -void send_info(bool start); -void send_emoticon(int emoticon); - -void chat_say(int team, const char *line); -void chat_enable_mode(int team); - -inline vec2 random_dir() { return normalize(vec2(frandom()-0.5f, frandom()-0.5f)); } - - -// effects -void effects_update(); - -void effect_bullettrail(vec2 pos); -void effect_smoketrail(vec2 pos, vec2 vel); -void effect_skidtrail(vec2 pos, vec2 vel); -void effect_explosion(vec2 pos); -void effect_air_jump(vec2 pos); -void effect_damage_indicator(vec2 pos, vec2 dir); -void effect_playerspawn(vec2 pos); -void effect_playerdeath(vec2 pos, int cid); -void effect_powerupshine(vec2 pos, vec2 size); - -// particles -struct PARTICLE -{ - void set_default() - { - vel = vec2(0,0); - life_span = 0; - start_size = 32; - end_size = 32; - rot = 0; - rotspeed = 0; - gravity = 0; - friction = 0; - flow_affected = 1.0f; - color = vec4(1,1,1,1); - } - - vec2 pos; - vec2 vel; - - int spr; - - float flow_affected; - - float life_span; - - float start_size; - float end_size; - - float rot; - float rotspeed; - - float gravity; - float friction; - - vec4 color; - - // set by the particle system - float life; - int prev_part; - int next_part; -}; - -enum -{ - PARTGROUP_PROJECTILE_TRAIL=0, - PARTGROUP_EXPLOSIONS, - PARTGROUP_GENERAL, - NUM_PARTGROUPS -}; - -void particle_add(int group, PARTICLE *part); -void particle_render(int group); -void particle_update(float time_passed); -void particle_reset(); - -// flow grid -vec2 flow_get(vec2 pos); -void flow_add(vec2 pos, vec2 vel, float size); -void flow_dbg_render(); -void flow_init(); -void flow_update(); - -// -void binds_default(); -void binds_save(); -void binds_set(int keyid, const char *str); -const char *binds_get(int keyid); - diff --git a/src/game/client/gc_client.hpp b/src/game/client/gc_client.hpp new file mode 100644 index 00000000..750154b3 --- /dev/null +++ b/src/game/client/gc_client.hpp @@ -0,0 +1,275 @@ +#include +#include +#include + +#include + +// sound channels +enum +{ + CHN_GUI=0, + CHN_MUSIC, + CHN_WORLD, + CHN_GLOBAL, +}; + +//extern struct data_container *data; + +extern vec2 mouse_pos; +extern vec2 local_character_pos; +extern vec2 local_target_pos; + +// snap pointers +struct SNAPSTATE +{ + const NETOBJ_PLAYER_CHARACTER *local_character; + const NETOBJ_PLAYER_CHARACTER *local_prev_character; + const NETOBJ_PLAYER_INFO *local_info; + const NETOBJ_FLAG *flags[2]; + const NETOBJ_GAME *gameobj; + + const NETOBJ_PLAYER_INFO *player_infos[MAX_CLIENTS]; + const NETOBJ_PLAYER_INFO *info_by_score[MAX_CLIENTS]; + int num_players; +}; + +extern SNAPSTATE netobjects; + +/* +extern const NETOBJ_PLAYER_CHARACTER *local_character; +extern const NETOBJ_PLAYER_CHARACTER *local_prev_character; +extern const NETOBJ_PLAYER_INFO *local_info; +extern const NETOBJ_FLAG *flags[2]; +extern const NETOBJ_GAME *gameobj; +* */ + +extern TUNING_PARAMS tuning; + +// predicted players +extern PLAYER_CORE predicted_prev_player; +extern PLAYER_CORE predicted_player; + +// input +extern NETOBJ_PLAYER_INPUT input_data; +extern int input_direction_left; +extern int input_direction_right; + +// debug +extern int64 debug_firedelay; + +// extra projs +enum +{ + MAX_EXTRA_PROJECTILES=32, +}; + +extern NETOBJ_PROJECTILE extraproj_projectiles[MAX_EXTRA_PROJECTILES]; +extern int extraproj_num; + +void extraproj_reset(); + +// chat +enum +{ + CHATMODE_NONE=0, + CHATMODE_ALL, + CHATMODE_TEAM, +}; + +extern int chat_mode; +void chat_add_line(int client_id, int team, const char *line); +void chat_reset(); +bool chat_input_handle(INPUT_EVENT e, void *user_data); + +// broadcasts +extern char broadcast_text[1024]; +extern int64 broadcast_time; + +// motd +extern int64 server_motd_time; +extern char server_motd[900]; // FUGLY + +// line input helter +class line_input +{ + char str[256]; + unsigned len; + unsigned cursor_pos; +public: + class callback + { + public: + virtual ~callback() {} + virtual bool event(INPUT_EVENT e) = 0; + }; + + line_input(); + void clear(); + void process_input(INPUT_EVENT e); + void set(const char *string); + const char *get_string() const { return str; } + int get_length() const { return len; } + unsigned cursor_offset() const { return cursor_pos; } +}; + +class INPUT_STACK_HANDLER +{ +public: + typedef bool (*CALLBACK)(INPUT_EVENT e, void *user); + + INPUT_STACK_HANDLER(); + void add_handler(CALLBACK cb, void *user_data); + void dispatch_input(); + +private: + enum + { + MAX_HANDLERS=16 + }; + + CALLBACK handlers[MAX_HANDLERS]; + void *user_data[MAX_HANDLERS]; + int num_handlers; +}; + +extern INPUT_STACK_HANDLER input_stack; + + +extern int emoticon_selector_active; // TODO: ugly +extern int scoreboard_active; // TODO: ugly + +// client data +struct CLIENT_DATA +{ + char name[64]; + char skin_name[64]; + int skin_id; + int skin_color; + int team; + int emoticon; + int emoticon_start; + PLAYER_CORE predicted; + + TEE_RENDER_INFO skin_info; // this is what the server reports + TEE_RENDER_INFO render_info; // this is what we use + + float angle; + + void update_render_info(); +}; + +extern CLIENT_DATA client_datas[MAX_CLIENTS]; + +// kill messages +struct KILLMSG +{ + int weapon; + int victim; + int killer; + int mode_special; // for CTF, if the guy is carrying a flag for example + int tick; +}; + +const int killmsg_max = 5; +extern KILLMSG killmsgs[killmsg_max]; +extern int killmsg_current; + +// +void send_switch_team(int team); + +// various helpers +void snd_play_random(int chn, int setid, float vol, vec2 pos); +void process_events(int snaptype); +void clear_object_pointers(); +void reset_projectile_particles(); +void send_info(bool start); +void send_emoticon(int emoticon); + +void chat_say(int team, const char *line); +void chat_enable_mode(int team); + +inline vec2 random_dir() { return normalize(vec2(frandom()-0.5f, frandom()-0.5f)); } + + +// effects +void effects_update(); + +void effect_bullettrail(vec2 pos); +void effect_smoketrail(vec2 pos, vec2 vel); +void effect_skidtrail(vec2 pos, vec2 vel); +void effect_explosion(vec2 pos); +void effect_air_jump(vec2 pos); +void effect_damage_indicator(vec2 pos, vec2 dir); +void effect_playerspawn(vec2 pos); +void effect_playerdeath(vec2 pos, int cid); +void effect_powerupshine(vec2 pos, vec2 size); + +// particles +struct PARTICLE +{ + void set_default() + { + vel = vec2(0,0); + life_span = 0; + start_size = 32; + end_size = 32; + rot = 0; + rotspeed = 0; + gravity = 0; + friction = 0; + flow_affected = 1.0f; + color = vec4(1,1,1,1); + } + + vec2 pos; + vec2 vel; + + int spr; + + float flow_affected; + + float life_span; + + float start_size; + float end_size; + + float rot; + float rotspeed; + + float gravity; + float friction; + + vec4 color; + + // set by the particle system + float life; + int prev_part; + int next_part; +}; + +enum +{ + PARTGROUP_PROJECTILE_TRAIL=0, + PARTGROUP_EXPLOSIONS, + PARTGROUP_GENERAL, + NUM_PARTGROUPS +}; + +void particle_add(int group, PARTICLE *part); +void particle_render(int group); +void particle_update(float time_passed); +void particle_reset(); + +// flow grid +vec2 flow_get(vec2 pos); +void flow_add(vec2 pos, vec2 vel, float size); +void flow_dbg_render(); +void flow_init(); +void flow_update(); + +// +void binds_default(); +void binds_save(); +void binds_set(int keyid, const char *str); +const char *binds_get(int keyid); + diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp index 76bf7218..45666a01 100644 --- a/src/game/client/gc_console.cpp +++ b/src/game/client/gc_console.cpp @@ -1,5 +1,5 @@ -#include "gc_console.h" -#include "../generated/gc_data.h" +#include "gc_console.hpp" +#include "../generated/gc_data.hpp" extern "C" { #include @@ -13,10 +13,10 @@ extern "C" { #include #include -#include "gc_ui.h" -#include "gc_client.h" +#include "gc_ui.hpp" +#include "gc_client.hpp" -#include "../g_version.h" +#include "../g_version.hpp" enum { diff --git a/src/game/client/gc_console.h b/src/game/client/gc_console.h deleted file mode 100644 index 0f5e7b9f..00000000 --- a/src/game/client/gc_console.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _GC_CONSOLE_H -#define _GC_CONSOLE_H - -#include - -bool console_input_cli(INPUT_EVENT e, void *user_data); -bool console_input_special_binds(INPUT_EVENT e, void *user_data); -bool console_input_normal_binds(INPUT_EVENT e, void *user_data); - -//void console_handle_input(); - -void console_clear(int type); -void console_toggle(int tpye); -void console_render(); -int console_active(); -void client_console_init(); -void console_rcon_print(const char *line); - -#endif diff --git a/src/game/client/gc_console.hpp b/src/game/client/gc_console.hpp new file mode 100644 index 00000000..0f5e7b9f --- /dev/null +++ b/src/game/client/gc_console.hpp @@ -0,0 +1,19 @@ +#ifndef _GC_CONSOLE_H +#define _GC_CONSOLE_H + +#include + +bool console_input_cli(INPUT_EVENT e, void *user_data); +bool console_input_special_binds(INPUT_EVENT e, void *user_data); +bool console_input_normal_binds(INPUT_EVENT e, void *user_data); + +//void console_handle_input(); + +void console_clear(int type); +void console_toggle(int tpye); +void console_render(); +int console_active(); +void client_console_init(); +void console_rcon_print(const char *line); + +#endif diff --git a/src/game/client/gc_effects.cpp b/src/game/client/gc_effects.cpp index 5a9ebfc6..387e1471 100644 --- a/src/game/client/gc_effects.cpp +++ b/src/game/client/gc_effects.cpp @@ -1,7 +1,7 @@ #include -#include "gc_client.h" -#include "gc_skin.h" -#include "../generated/gc_data.h" +#include "gc_client.hpp" +#include "gc_skin.hpp" +#include "../generated/gc_data.hpp" static bool add_50hz = false; static bool add_100hz = false; diff --git a/src/game/client/gc_flow.cpp b/src/game/client/gc_flow.cpp index aac35058..63e60617 100644 --- a/src/game/client/gc_flow.cpp +++ b/src/game/client/gc_flow.cpp @@ -1,7 +1,7 @@ #include #include -#include "gc_client.h" -#include "../g_layers.h" +#include "gc_client.hpp" +#include "../g_layers.hpp" struct FLOWCELL { diff --git a/src/game/client/gc_hooks.cpp b/src/game/client/gc_hooks.cpp index 61e5f2e8..2aaca900 100644 --- a/src/game/client/gc_hooks.cpp +++ b/src/game/client/gc_hooks.cpp @@ -8,17 +8,17 @@ extern "C" { #include }; -#include -#include -#include +#include +#include +#include -#include +#include -#include "gc_client.h" -#include "gc_skin.h" -#include "gc_render.h" -#include "gc_map_image.h" -#include "gc_console.h" +#include "gc_client.hpp" +#include "gc_skin.hpp" +#include "gc_render.hpp" +#include "gc_map_image.hpp" +#include "gc_console.hpp" extern unsigned char internal_data[]; diff --git a/src/game/client/gc_map_image.cpp b/src/game/client/gc_map_image.cpp index 65cb0608..63a57c70 100644 --- a/src/game/client/gc_map_image.cpp +++ b/src/game/client/gc_map_image.cpp @@ -2,8 +2,8 @@ #include #include #include -#include -#include "gc_map_image.h" +#include +#include "gc_map_image.hpp" static int map_textures[64] = {0}; static int count = 0; diff --git a/src/game/client/gc_map_image.h b/src/game/client/gc_map_image.h deleted file mode 100644 index d73f43d3..00000000 --- a/src/game/client/gc_map_image.h +++ /dev/null @@ -1,10 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ - -// loads images from the map to textures -int img_init(); - -// returns the number of images in the map -int img_num(); - -// fetches the texture id for the image -int img_get(int index); diff --git a/src/game/client/gc_map_image.hpp b/src/game/client/gc_map_image.hpp new file mode 100644 index 00000000..d73f43d3 --- /dev/null +++ b/src/game/client/gc_map_image.hpp @@ -0,0 +1,10 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ + +// loads images from the map to textures +int img_init(); + +// returns the number of images in the map +int img_num(); + +// fetches the texture id for the image +int img_get(int index); diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp index 3a41aee4..cb8324a7 100644 --- a/src/game/client/gc_menu.cpp +++ b/src/game/client/gc_menu.cpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include extern "C" { #include @@ -14,15 +14,15 @@ extern "C" { #include } -#include "../g_version.h" -#include "../g_protocol.h" +#include "../g_version.hpp" +#include "../g_protocol.hpp" -#include "../generated/gc_data.h" -#include "gc_render.h" -#include "gc_anim.h" -#include "gc_skin.h" -#include "gc_ui.h" -#include "gc_client.h" +#include "../generated/gc_data.hpp" +#include "gc_render.hpp" +#include "gc_anim.hpp" +#include "gc_skin.hpp" +#include "gc_ui.hpp" +#include "gc_client.hpp" #include //extern data_container *data; diff --git a/src/game/client/gc_menu.h b/src/game/client/gc_menu.h deleted file mode 100644 index ba12894c..00000000 --- a/src/game/client/gc_menu.h +++ /dev/null @@ -1,5 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef __MENU_H -#define __MENU_H - -#endif diff --git a/src/game/client/gc_menu.hpp b/src/game/client/gc_menu.hpp new file mode 100644 index 00000000..ba12894c --- /dev/null +++ b/src/game/client/gc_menu.hpp @@ -0,0 +1,5 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef __MENU_H +#define __MENU_H + +#endif diff --git a/src/game/client/gc_particles.cpp b/src/game/client/gc_particles.cpp index 2c3ef36c..504ebbab 100644 --- a/src/game/client/gc_particles.cpp +++ b/src/game/client/gc_particles.cpp @@ -1,6 +1,6 @@ #include -#include "gc_client.h" -#include "../generated/gc_data.h" +#include "gc_client.hpp" +#include "../generated/gc_data.hpp" // NOTE: the way the particle system works isn't very cache friendly diff --git a/src/game/client/gc_render.cpp b/src/game/client/gc_render.cpp index 364b33eb..2e5a3d50 100644 --- a/src/game/client/gc_render.cpp +++ b/src/game/client/gc_render.cpp @@ -2,14 +2,14 @@ #include #include #include -#include -#include -#include -#include -#include "gc_render.h" -#include "gc_anim.h" -#include "gc_client.h" -#include "gc_map_image.h" +#include +#include +#include +#include +#include "gc_render.hpp" +#include "gc_anim.hpp" +#include "gc_client.hpp" +#include "gc_map_image.hpp" static float sprite_w_scale; static float sprite_h_scale; diff --git a/src/game/client/gc_render.h b/src/game/client/gc_render.h deleted file mode 100644 index 508ab195..00000000 --- a/src/game/client/gc_render.h +++ /dev/null @@ -1,82 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef GAME_CLIENT_RENDER_H -#define GAME_CLIENT_RENDER_H - -#include "../g_vmath.h" -#include "../g_mapitems.h" -#include "gc_ui.h" - -struct TEE_RENDER_INFO -{ - TEE_RENDER_INFO() - { - texture = -1; - color_body = vec4(1,1,1,1); - color_feet = vec4(1,1,1,1); - size = 1.0f; - got_airjump = 1; - }; - - int texture; - vec4 color_body; - vec4 color_feet; - float size; - int got_airjump; -}; - -// sprite renderings -enum -{ - SPRITE_FLAG_FLIP_Y=1, - SPRITE_FLAG_FLIP_X=2, - - LAYERRENDERFLAG_OPAQUE=1, - LAYERRENDERFLAG_TRANSPARENT=2, - - TILERENDERFLAG_EXTEND=4, -}; - -typedef struct SPRITE; - -void select_sprite(SPRITE *spr, int flags=0, int sx=0, int sy=0); -void select_sprite(int id, int flags=0, int sx=0, int sy=0); - -void draw_sprite(float x, float y, float size); - -// rects -void draw_round_rect(float x, float y, float w, float h, float r); -void draw_round_rect_ext(float x, float y, float w, float h, float r, int corners); -void ui_draw_rect(const RECT *r, vec4 color, int corners, float rounding); - -// larger rendering methods -void menu_render(); -void render_game(); -void render_world(float center_x, float center_y, float zoom); -void render_loading(float percent); - -void render_damage_indicators(); -void render_particles(); - -void render_tilemap_generate_skip(); - -// object render methods (gc_render_obj.cpp) -void render_tee(class ANIM_STATE *anim, TEE_RENDER_INFO *info, int emote, vec2 dir, vec2 pos); -void render_flag(const struct NETOBJ_FLAG *prev, const struct NETOBJ_FLAG *current); -void render_pickup(const struct NETOBJ_PICKUP *prev, const struct NETOBJ_PICKUP *current); -void render_projectile(const struct NETOBJ_PROJECTILE *current, int itemid); -void render_laser(const struct NETOBJ_LASER *current); -void render_player( - const struct NETOBJ_PLAYER_CHARACTER *prev_char, const struct NETOBJ_PLAYER_CHARACTER *player_char, - const struct NETOBJ_PLAYER_INFO *prev_info, const struct NETOBJ_PLAYER_INFO *player_info); - -// map render methods (gc_render_map.cpp) -void render_eval_envelope(ENVPOINT *points, int num_points, int channels, float time, float *result); -void render_quads(QUAD *quads, int num_quads, void (*eval)(float time_offset, int env, float *channels), int flags); -void render_tilemap(TILE *tiles, int w, int h, float scale, vec4 color, int flags); - -// helpers -void mapscreen_to_world(float center_x, float center_y, float parallax_x, float parallax_y, - float offset_x, float offset_y, float aspect, float zoom, float *points); - - -#endif diff --git a/src/game/client/gc_render.hpp b/src/game/client/gc_render.hpp new file mode 100644 index 00000000..02bc224d --- /dev/null +++ b/src/game/client/gc_render.hpp @@ -0,0 +1,82 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef GAME_CLIENT_RENDER_H +#define GAME_CLIENT_RENDER_H + +#include "../g_vmath.hpp" +#include "../g_mapitems.hpp" +#include "gc_ui.hpp" + +struct TEE_RENDER_INFO +{ + TEE_RENDER_INFO() + { + texture = -1; + color_body = vec4(1,1,1,1); + color_feet = vec4(1,1,1,1); + size = 1.0f; + got_airjump = 1; + }; + + int texture; + vec4 color_body; + vec4 color_feet; + float size; + int got_airjump; +}; + +// sprite renderings +enum +{ + SPRITE_FLAG_FLIP_Y=1, + SPRITE_FLAG_FLIP_X=2, + + LAYERRENDERFLAG_OPAQUE=1, + LAYERRENDERFLAG_TRANSPARENT=2, + + TILERENDERFLAG_EXTEND=4, +}; + +typedef struct SPRITE; + +void select_sprite(SPRITE *spr, int flags=0, int sx=0, int sy=0); +void select_sprite(int id, int flags=0, int sx=0, int sy=0); + +void draw_sprite(float x, float y, float size); + +// rects +void draw_round_rect(float x, float y, float w, float h, float r); +void draw_round_rect_ext(float x, float y, float w, float h, float r, int corners); +void ui_draw_rect(const RECT *r, vec4 color, int corners, float rounding); + +// larger rendering methods +void menu_render(); +void render_game(); +void render_world(float center_x, float center_y, float zoom); +void render_loading(float percent); + +void render_damage_indicators(); +void render_particles(); + +void render_tilemap_generate_skip(); + +// object render methods (gc_render_obj.cpp) +void render_tee(class ANIM_STATE *anim, TEE_RENDER_INFO *info, int emote, vec2 dir, vec2 pos); +void render_flag(const struct NETOBJ_FLAG *prev, const struct NETOBJ_FLAG *current); +void render_pickup(const struct NETOBJ_PICKUP *prev, const struct NETOBJ_PICKUP *current); +void render_projectile(const struct NETOBJ_PROJECTILE *current, int itemid); +void render_laser(const struct NETOBJ_LASER *current); +void render_player( + const struct NETOBJ_PLAYER_CHARACTER *prev_char, const struct NETOBJ_PLAYER_CHARACTER *player_char, + const struct NETOBJ_PLAYER_INFO *prev_info, const struct NETOBJ_PLAYER_INFO *player_info); + +// map render methods (gc_render_map.cpp) +void render_eval_envelope(ENVPOINT *points, int num_points, int channels, float time, float *result); +void render_quads(QUAD *quads, int num_quads, void (*eval)(float time_offset, int env, float *channels), int flags); +void render_tilemap(TILE *tiles, int w, int h, float scale, vec4 color, int flags); + +// helpers +void mapscreen_to_world(float center_x, float center_y, float parallax_x, float parallax_y, + float offset_x, float offset_y, float aspect, float zoom, float *points); + + +#endif diff --git a/src/game/client/gc_render_map.cpp b/src/game/client/gc_render_map.cpp index 2ad3ad94..90579aa7 100644 --- a/src/game/client/gc_render_map.cpp +++ b/src/game/client/gc_render_map.cpp @@ -1,7 +1,7 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include "../g_math.h" -#include "gc_client.h" +#include "../g_math.hpp" +#include "gc_client.hpp" void render_eval_envelope(ENVPOINT *points, int num_points, int channels, float time, float *result) { diff --git a/src/game/client/gc_render_obj.cpp b/src/game/client/gc_render_obj.cpp index a6cd2b69..119db4d6 100644 --- a/src/game/client/gc_render_obj.cpp +++ b/src/game/client/gc_render_obj.cpp @@ -3,13 +3,13 @@ #include #include #include -#include "../generated/gc_data.h" -#include "../g_protocol.h" -#include "../g_math.h" -#include "gc_render.h" -#include "gc_anim.h" -#include "gc_client.h" -#include "gc_skin.h" +#include "../generated/gc_data.hpp" +#include "../g_protocol.hpp" +#include "../g_math.hpp" +#include "gc_render.hpp" +#include "gc_anim.hpp" +#include "gc_client.hpp" +#include "gc_skin.hpp" void render_projectile(const NETOBJ_PROJECTILE *current, int itemid) diff --git a/src/game/client/gc_skin.cpp b/src/game/client/gc_skin.cpp index a876c960..2bd2d4ff 100644 --- a/src/game/client/gc_skin.cpp +++ b/src/game/client/gc_skin.cpp @@ -4,8 +4,8 @@ #include #include #include -#include "gc_skin.h" -#include "../g_math.h" +#include "gc_skin.hpp" +#include "../g_math.hpp" enum { diff --git a/src/game/client/gc_skin.h b/src/game/client/gc_skin.h deleted file mode 100644 index d3840302..00000000 --- a/src/game/client/gc_skin.h +++ /dev/null @@ -1,21 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include "../g_vmath.h" - -// do this better and nicer -typedef struct -{ - int org_texture; - int color_texture; - char name[31]; - char term[1]; - vec3 blood_color; -} skin; - -vec4 skin_get_color(int v); -void skin_init(); -int skin_num(); -const skin *skin_get(int index); -int skin_find(const char *name); - - -vec3 hsl_to_rgb(vec3 in); diff --git a/src/game/client/gc_skin.hpp b/src/game/client/gc_skin.hpp new file mode 100644 index 00000000..3a746589 --- /dev/null +++ b/src/game/client/gc_skin.hpp @@ -0,0 +1,21 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#include "../g_vmath.hpp" + +// do this better and nicer +typedef struct +{ + int org_texture; + int color_texture; + char name[31]; + char term[1]; + vec3 blood_color; +} skin; + +vec4 skin_get_color(int v); +void skin_init(); +int skin_num(); +const skin *skin_get(int index); +int skin_find(const char *name); + + +vec3 hsl_to_rgb(vec3 in); diff --git a/src/game/client/gc_ui.cpp b/src/game/client/gc_ui.cpp index dc78c0ca..a344d661 100644 --- a/src/game/client/gc_ui.cpp +++ b/src/game/client/gc_ui.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "gc_ui.h" +#include "gc_ui.hpp" /******************************************************** UI diff --git a/src/game/client/gc_ui.h b/src/game/client/gc_ui.h deleted file mode 100644 index 26c4dcdb..00000000 --- a/src/game/client/gc_ui.h +++ /dev/null @@ -1,65 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef _UI_H -#define _UI_H - -typedef struct -{ - float x, y, w, h; -} RECT; - -enum -{ - CORNER_TL=1, - CORNER_TR=2, - CORNER_BL=4, - CORNER_BR=8, - - CORNER_T=CORNER_TL|CORNER_TR, - CORNER_B=CORNER_BL|CORNER_BR, - CORNER_R=CORNER_TR|CORNER_BR, - CORNER_L=CORNER_TL|CORNER_BL, - - CORNER_ALL=CORNER_T|CORNER_B -}; - -int ui_update(float mx, float my, float mwx, float mwy, int buttons); - -float ui_mouse_x(); -float ui_mouse_y(); -float ui_mouse_world_x(); -float ui_mouse_world_y(); -int ui_mouse_button(int index); -int ui_mouse_button_clicked(int index); - -void ui_set_hot_item(const void *id); -void ui_set_active_item(const void *id); -void ui_clear_last_active_item(); -const void *ui_hot_item(); -const void *ui_next_hot_item(); -const void *ui_active_item(); -const void *ui_last_active_item(); - -int ui_mouse_inside(const RECT *r); - -RECT *ui_screen(); -void ui_set_scale(float s); -float ui_scale(); -void ui_clip_enable(const RECT *r); -void ui_clip_disable(); - -void ui_hsplit_t(const RECT *original, float cut, RECT *top, RECT *bottom); -void ui_hsplit_b(const RECT *original, float cut, RECT *top, RECT *bottom); -void ui_vsplit_mid(const RECT *original, RECT *left, RECT *right); -void ui_vsplit_l(const RECT *original, float cut, RECT *left, RECT *right); -void ui_vsplit_r(const RECT *original, float cut, RECT *left, RECT *right); - -void ui_margin(const RECT *original, float cut, RECT *other_rect); -void ui_vmargin(const RECT *original, float cut, RECT *other_rect); -void ui_hmargin(const RECT *original, float cut, RECT *other_rect); - -typedef void (*ui_draw_button_func)(const void *id, const char *text, int checked, const RECT *r, const void *extra); -int ui_do_button(const void *id, const char *text, int checked, const RECT *r, ui_draw_button_func draw_func, const void *extra); -void ui_do_label(const RECT *r, const char *text, float size, int align, int max_width = -1); - - -#endif diff --git a/src/game/client/gc_ui.hpp b/src/game/client/gc_ui.hpp new file mode 100644 index 00000000..26c4dcdb --- /dev/null +++ b/src/game/client/gc_ui.hpp @@ -0,0 +1,65 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef _UI_H +#define _UI_H + +typedef struct +{ + float x, y, w, h; +} RECT; + +enum +{ + CORNER_TL=1, + CORNER_TR=2, + CORNER_BL=4, + CORNER_BR=8, + + CORNER_T=CORNER_TL|CORNER_TR, + CORNER_B=CORNER_BL|CORNER_BR, + CORNER_R=CORNER_TR|CORNER_BR, + CORNER_L=CORNER_TL|CORNER_BL, + + CORNER_ALL=CORNER_T|CORNER_B +}; + +int ui_update(float mx, float my, float mwx, float mwy, int buttons); + +float ui_mouse_x(); +float ui_mouse_y(); +float ui_mouse_world_x(); +float ui_mouse_world_y(); +int ui_mouse_button(int index); +int ui_mouse_button_clicked(int index); + +void ui_set_hot_item(const void *id); +void ui_set_active_item(const void *id); +void ui_clear_last_active_item(); +const void *ui_hot_item(); +const void *ui_next_hot_item(); +const void *ui_active_item(); +const void *ui_last_active_item(); + +int ui_mouse_inside(const RECT *r); + +RECT *ui_screen(); +void ui_set_scale(float s); +float ui_scale(); +void ui_clip_enable(const RECT *r); +void ui_clip_disable(); + +void ui_hsplit_t(const RECT *original, float cut, RECT *top, RECT *bottom); +void ui_hsplit_b(const RECT *original, float cut, RECT *top, RECT *bottom); +void ui_vsplit_mid(const RECT *original, RECT *left, RECT *right); +void ui_vsplit_l(const RECT *original, float cut, RECT *left, RECT *right); +void ui_vsplit_r(const RECT *original, float cut, RECT *left, RECT *right); + +void ui_margin(const RECT *original, float cut, RECT *other_rect); +void ui_vmargin(const RECT *original, float cut, RECT *other_rect); +void ui_hmargin(const RECT *original, float cut, RECT *other_rect); + +typedef void (*ui_draw_button_func)(const void *id, const char *text, int checked, const RECT *r, const void *extra); +int ui_do_button(const void *id, const char *text, int checked, const RECT *r, ui_draw_button_func draw_func, const void *extra); +void ui_do_label(const RECT *r, const char *text, float size, int align, int max_width = -1); + + +#endif diff --git a/src/game/editor/array.h b/src/game/editor/array.h deleted file mode 100755 index fe9f2739..00000000 --- a/src/game/editor/array.h +++ /dev/null @@ -1,238 +0,0 @@ - -template -class array -{ - // - // - void init() - { - list = 0; - clear(); - } - -public: - array() - { - init(); - } - - // - array(const array &other) - { - init(); - setsize(other.len()); - for(int i = 0; i < len(); i++) - (*this)[i] = other[i]; - } - - - // - // - virtual ~array() - { - delete [] list; - list = 0; - } - - // - // - void deleteall() - { - for(int i = 0; i < len(); i++) - delete list[i]; - - clear(); - } - - - // - // - void clear() - { - delete [] list; - - list_size = 1; - list = new T[1]; - num_elements = 0; - } - - int find(T val) - { - for(int i = 0; i < len(); i++) - if((*this)[i] == val) - return i; - return -1; - } - - bool exist(T val) - { - return find(val) != -1; - } - - // - // returns the number of elements in the list - // - int len() const - { - return num_elements; - } - - // - // This doesn't conserve the order in the list. Be careful - // - void removebyindexfast(int index) - { - //ASSUME(_Pos >= 0 && _Pos < num_elements); - list[index] = list[num_elements-1]; - setsize(len()-1); - } - - void removefast(const T& _Elem) - { - for(int i = 0; i < len(); i++) - if(list[i] == _Elem) - { - removebyindexfast(i); - return; - } - } - - // - // - void removebyindex(int index) - { - //ASSUME(_Pos >= 0 && _Pos < num_elements); - - for(int i = index+1; i < num_elements; i++) - list[i-1] = list[i]; - - setsize(len()-1); - } - - void insert(int index, const T& element) - { - int some_len = len(); - if (index < some_len) - setsize(some_len+1); - else - setsize(index + 1); - - for(int i = num_elements-2; i >= index; i--) - list[i+1] = list[i]; - - list[index] = element; - } - - bool remove(const T& element) - { - for(int i = 0; i < len(); i++) - if(list[i] == element) - { - removebyindex(i); - return true; - } - return false; - } - - // - // - int add(const T& element) - { - //if(num_elements == list_size) - setsize(len()+1); - list[num_elements-1] = element; - return num_elements-1; - } - - // - // - int add(const T& elem, int index) - { - setsize(len()+1); - - for(int i = num_elements-1; i > index; i--) - list[i] = list[i-1]; - - list[index] = elem; - - //num_elements++; - return num_elements-1; - } - - // - // - T& operator[] (int index) - { - return list[index]; - } - - const T& operator[] (int index) const - { - return list[index]; - } - - // - // - T *getptr() - { - return list; - } - - const T *getptr() const - { - return list; - } - - // - // - // - void setsize(int new_len) - { - if (list_size < new_len) - allocsize(new_len); - num_elements = new_len; - } - - // removes unnessasary data, returns how many bytes was earned - int optimize() - { - int Before = memoryusage(); - setsize(num_elements); - return Before - memoryusage(); - } - - // returns how much memory this dynamic array is using - int memoryusage() - { - return sizeof(array) + sizeof(T)*list_size; - } - - // - array &operator = (const array &other) - { - setsize(other.len()); - for(int i = 0; i < len(); i++) - (*this)[i] = other[i]; - return *this; - } -private: - void allocsize(int new_len) - { - list_size = new_len; - T *new_list = new T[list_size]; - - long end = num_elements < list_size ? num_elements : list_size; - for(int i = 0; i < end; i++) - new_list[i] = list[i]; - - delete [] list; - list = 0; - num_elements = num_elements < list_size ? num_elements : list_size; - list = new_list; - } - - T *list; - long list_size; - long num_elements; -}; - diff --git a/src/game/editor/array.hpp b/src/game/editor/array.hpp new file mode 100755 index 00000000..fe9f2739 --- /dev/null +++ b/src/game/editor/array.hpp @@ -0,0 +1,238 @@ + +template +class array +{ + // + // + void init() + { + list = 0; + clear(); + } + +public: + array() + { + init(); + } + + // + array(const array &other) + { + init(); + setsize(other.len()); + for(int i = 0; i < len(); i++) + (*this)[i] = other[i]; + } + + + // + // + virtual ~array() + { + delete [] list; + list = 0; + } + + // + // + void deleteall() + { + for(int i = 0; i < len(); i++) + delete list[i]; + + clear(); + } + + + // + // + void clear() + { + delete [] list; + + list_size = 1; + list = new T[1]; + num_elements = 0; + } + + int find(T val) + { + for(int i = 0; i < len(); i++) + if((*this)[i] == val) + return i; + return -1; + } + + bool exist(T val) + { + return find(val) != -1; + } + + // + // returns the number of elements in the list + // + int len() const + { + return num_elements; + } + + // + // This doesn't conserve the order in the list. Be careful + // + void removebyindexfast(int index) + { + //ASSUME(_Pos >= 0 && _Pos < num_elements); + list[index] = list[num_elements-1]; + setsize(len()-1); + } + + void removefast(const T& _Elem) + { + for(int i = 0; i < len(); i++) + if(list[i] == _Elem) + { + removebyindexfast(i); + return; + } + } + + // + // + void removebyindex(int index) + { + //ASSUME(_Pos >= 0 && _Pos < num_elements); + + for(int i = index+1; i < num_elements; i++) + list[i-1] = list[i]; + + setsize(len()-1); + } + + void insert(int index, const T& element) + { + int some_len = len(); + if (index < some_len) + setsize(some_len+1); + else + setsize(index + 1); + + for(int i = num_elements-2; i >= index; i--) + list[i+1] = list[i]; + + list[index] = element; + } + + bool remove(const T& element) + { + for(int i = 0; i < len(); i++) + if(list[i] == element) + { + removebyindex(i); + return true; + } + return false; + } + + // + // + int add(const T& element) + { + //if(num_elements == list_size) + setsize(len()+1); + list[num_elements-1] = element; + return num_elements-1; + } + + // + // + int add(const T& elem, int index) + { + setsize(len()+1); + + for(int i = num_elements-1; i > index; i--) + list[i] = list[i-1]; + + list[index] = elem; + + //num_elements++; + return num_elements-1; + } + + // + // + T& operator[] (int index) + { + return list[index]; + } + + const T& operator[] (int index) const + { + return list[index]; + } + + // + // + T *getptr() + { + return list; + } + + const T *getptr() const + { + return list; + } + + // + // + // + void setsize(int new_len) + { + if (list_size < new_len) + allocsize(new_len); + num_elements = new_len; + } + + // removes unnessasary data, returns how many bytes was earned + int optimize() + { + int Before = memoryusage(); + setsize(num_elements); + return Before - memoryusage(); + } + + // returns how much memory this dynamic array is using + int memoryusage() + { + return sizeof(array) + sizeof(T)*list_size; + } + + // + array &operator = (const array &other) + { + setsize(other.len()); + for(int i = 0; i < len(); i++) + (*this)[i] = other[i]; + return *this; + } +private: + void allocsize(int new_len) + { + list_size = new_len; + T *new_list = new T[list_size]; + + long end = num_elements < list_size ? num_elements : list_size; + for(int i = 0; i < end; i++) + new_list[i] = list[i]; + + delete [] list; + list = 0; + num_elements = num_elements < list_size ? num_elements : list_size; + list = new_list; + } + + T *list; + long list_size; + long num_elements; +}; + diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 3632a034..731d4f4a 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -11,10 +11,10 @@ extern "C" { #include } -#include -#include -#include -#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 62f8871a..dbca4a0e 100644 --- a/src/game/editor/ed_editor.hpp +++ b/src/game/editor/ed_editor.hpp @@ -2,10 +2,10 @@ #include #include -#include "array.h" -#include "../g_mapitems.h" -#include "../g_math.h" -#include "../client/gc_render.h" +#include "array.hpp" +#include "../g_mapitems.hpp" +#include "../g_math.hpp" +#include "../client/gc_render.hpp" extern "C" { #include @@ -14,7 +14,7 @@ extern "C" { #include } -#include +#include typedef void (*INDEX_MODIFY_FUNC)(int *index); diff --git a/src/game/editor/ed_layer_quads.cpp b/src/game/editor/ed_layer_quads.cpp index f3df3818..8c8a47a7 100644 --- a/src/game/editor/ed_layer_quads.cpp +++ b/src/game/editor/ed_layer_quads.cpp @@ -1,7 +1,7 @@ #include "ed_editor.hpp" -#include -#include -#include +#include +#include +#include LAYER_QUADS::LAYER_QUADS() { diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index 18e3b695..d77f0970 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include "ed_editor.hpp" LAYER_TILES::LAYER_TILES(int w, int h) diff --git a/src/game/g_collision.cpp b/src/game/g_collision.cpp index 6c50064b..b91c0e29 100644 --- a/src/game/g_collision.cpp +++ b/src/game/g_collision.cpp @@ -1,11 +1,11 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include +#include #include #include -#include -#include -#include +#include +#include +#include static TILE *tiles; static int width = 0; diff --git a/src/game/g_collision.h b/src/game/g_collision.h deleted file mode 100644 index e738bc64..00000000 --- a/src/game/g_collision.h +++ /dev/null @@ -1,14 +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_collision.hpp b/src/game/g_collision.hpp new file mode 100644 index 00000000..e42764c1 --- /dev/null +++ b/src/game/g_collision.hpp @@ -0,0 +1,14 @@ +/* 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 index b5b37918..6545a75d 100644 --- a/src/game/g_game.cpp +++ b/src/game/g_game.cpp @@ -1,11 +1,11 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include "g_game.h" +#include "g_game.hpp" const char *TUNING_PARAMS::names[] = { #define MACRO_TUNING_PARAM(name,value) #name, - #include "g_tuning.h" + #include "g_tuning.hpp" #undef MACRO_TUNING_PARAM }; diff --git a/src/game/g_game.h b/src/game/g_game.h deleted file mode 100644 index 414dfdbf..00000000 --- a/src/game/g_game.h +++ /dev/null @@ -1,160 +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 "g_math.h" -#include "g_collision.h" -#include "g_protocol.h" - -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.h" - #undef MACRO_TUNING_PARAM - } - - static const char *names[]; - - #define MACRO_TUNING_PARAM(name,value) tune_param name; - #include "g_tuning.h" - #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(players, sizeof(players)); - } - - TUNING_PARAMS tuning; - class PLAYER_CORE *players[MAX_CLIENTS]; -}; - -class PLAYER_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_PLAYER_CORE *obj_core); - void write(NETOBJ_PLAYER_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_game.hpp b/src/game/g_game.hpp new file mode 100644 index 00000000..7ab8df40 --- /dev/null +++ b/src/game/g_game.hpp @@ -0,0 +1,160 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef GAME_GAME_H +#define GAME_GAME_H + +#include +#include +#include +#include "g_math.hpp" +#include "g_collision.hpp" +#include "g_protocol.hpp" + +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(players, sizeof(players)); + } + + TUNING_PARAMS tuning; + class PLAYER_CORE *players[MAX_CLIENTS]; +}; + +class PLAYER_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_PLAYER_CORE *obj_core); + void write(NETOBJ_PLAYER_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 index 07ffec4b..254bc083 100644 --- a/src/game/g_layers.cpp +++ b/src/game/g_layers.cpp @@ -1,5 +1,5 @@ #include -#include "g_layers.h" +#include "g_layers.hpp" static MAPITEM_LAYER_TILEMAP *game_layer = 0; static MAPITEM_GROUP *game_group = 0; diff --git a/src/game/g_layers.h b/src/game/g_layers.h deleted file mode 100644 index 3ece897f..00000000 --- a/src/game/g_layers.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "g_mapitems.h" - -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_layers.hpp b/src/game/g_layers.hpp new file mode 100644 index 00000000..f977bd65 --- /dev/null +++ b/src/game/g_layers.hpp @@ -0,0 +1,12 @@ +#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.h b/src/game/g_mapitems.h deleted file mode 100644 index 8093435a..00000000 --- a/src/game/g_mapitems.h +++ /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_mapitems.hpp b/src/game/g_mapitems.hpp new file mode 100644 index 00000000..8093435a --- /dev/null +++ b/src/game/g_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/g_math.h b/src/game/g_math.h deleted file mode 100644 index 5e3f7ede..00000000 --- a/src/game/g_math.h +++ /dev/null @@ -1,61 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef BASE_MATH_H -#define BASE_MATH_H - -#include - -template -inline T clamp(T val, T min, T max) -{ - if(val < min) - return min; - if(val > max) - return max; - return val; -} - -inline float sign(float f) -{ - return f<0.0f?-1.0f:1.0f; -} - -template -inline T mix(const T a, const T b, TB amount) -{ - return a + (b-a)*amount; -} - -inline float frandom() { return rand()/(float)(RAND_MAX); } - -// float to fixed -inline int f2fx(float v) { return (int)(v*(float)(1<<10)); } -inline float fx2f(int v) { return v*(1.0f/(1<<10)); } - -class fxp -{ - int value; -public: - void set(int v) { value = v; } - int get() const { return value; } - fxp &operator = (int v) { value = v<<10; return *this; } - fxp &operator = (float v) { value = (int)(v*(float)(1<<10)); return *this; } - operator float() const { return value/(float)(1<<10); } -}; - -class tune_param -{ - int value; -public: - void set(int v) { value = v; } - int get() const { return value; } - tune_param &operator = (int v) { value = (int)(v*100.0f); return *this; } - tune_param &operator = (float v) { value = (int)(v*100.0f); return *this; } - operator float() const { return value/100.0f; } -}; - -const float pi = 3.1415926535897932384626433f; - -template inline T min(T a, T b) { return a inline T max(T a, T b) { return a>b?a:b; } - -#endif // BASE_MATH_H diff --git a/src/game/g_math.hpp b/src/game/g_math.hpp new file mode 100644 index 00000000..5e3f7ede --- /dev/null +++ b/src/game/g_math.hpp @@ -0,0 +1,61 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef BASE_MATH_H +#define BASE_MATH_H + +#include + +template +inline T clamp(T val, T min, T max) +{ + if(val < min) + return min; + if(val > max) + return max; + return val; +} + +inline float sign(float f) +{ + return f<0.0f?-1.0f:1.0f; +} + +template +inline T mix(const T a, const T b, TB amount) +{ + return a + (b-a)*amount; +} + +inline float frandom() { return rand()/(float)(RAND_MAX); } + +// float to fixed +inline int f2fx(float v) { return (int)(v*(float)(1<<10)); } +inline float fx2f(int v) { return v*(1.0f/(1<<10)); } + +class fxp +{ + int value; +public: + void set(int v) { value = v; } + int get() const { return value; } + fxp &operator = (int v) { value = v<<10; return *this; } + fxp &operator = (float v) { value = (int)(v*(float)(1<<10)); return *this; } + operator float() const { return value/(float)(1<<10); } +}; + +class tune_param +{ + int value; +public: + void set(int v) { value = v; } + int get() const { return value; } + tune_param &operator = (int v) { value = (int)(v*100.0f); return *this; } + tune_param &operator = (float v) { value = (int)(v*100.0f); return *this; } + operator float() const { return value/100.0f; } +}; + +const float pi = 3.1415926535897932384626433f; + +template inline T min(T a, T b) { return a inline T max(T a, T b) { return a>b?a:b; } + +#endif // BASE_MATH_H diff --git a/src/game/g_protocol.h b/src/game/g_protocol.h deleted file mode 100644 index 195f5ae2..00000000 --- a/src/game/g_protocol.h +++ /dev/null @@ -1,217 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -// NOTE: Be very careful when editing this file as it will change the network version - -#ifndef GAME_PROTOCOL_H -#define GAME_PROTOCOL_H - -#include - -// Network stuff -/* -enum -{ - OBJTYPE_NULL=0, - OBJTYPE_GAME, - OBJTYPE_PLAYER_INFO, - OBJTYPE_PLAYER_CHARACTER, // use this if you are searching for the player entity - OBJTYPE_PROJECTILE, - OBJTYPE_LASER, - OBJTYPE_POWERUP, - OBJTYPE_FLAG, - EVENT_EXPLOSION, - EVENT_DAMAGEINDICATION, - EVENT_SOUND_WORLD, - EVENT_SMOKE, - EVENT_PLAYERSPAWN, - EVENT_DEATH, - EVENT_AIR_JUMP, - - EVENT_DUMMY -}; - -enum -{ - MSG_NULL=0, - MSG_SAY, // client -> server - MSG_CHAT, // server -> client - MSG_SETINFO, // server -> client - contains name, skin and color info - MSG_KILLMSG, // server -> client - MSG_SETTEAM, - MSG_JOIN, - MSG_QUIT, - MSG_EMOTICON, - MSG_STARTINFO, // client -> server - MSG_CHANGEINFO, // client -> server - MSG_READY_TO_ENTER, // server -> client - MSG_WEAPON_PICKUP, - MSG_SOUND_GLOBAL, - MSG_TUNE_PARAMS, - MSG_KILL, - MSG_EXTRA_PROJECTILE, // server -> client - -}; - -enum -{ - EMOTE_NORMAL=0, - EMOTE_PAIN, - EMOTE_HAPPY, - EMOTE_SURPRISE, - EMOTE_ANGRY, - EMOTE_BLINK, -}; - -enum -{ - INPUT_STATE_MASK=0x1f, -}; - -enum -{ - PLAYERSTATE_UNKNOWN=0, - PLAYERSTATE_PLAYING, - PLAYERSTATE_IN_MENU, - PLAYERSTATE_CHATTING, - - GAMETYPE_DM=0, - GAMETYPE_TDM, - GAMETYPE_CTF, -}; - -struct player_input -{ - int left; - int right; - - int target_x; - int target_y; - - int jump; - int fire; - int hook; - int blink; - - int player_state; - - int wanted_weapon; - int next_weapon; - int prev_weapon; -}; - -struct ev_common -{ - int x, y; -}; - -struct ev_explosion : public ev_common -{ -}; - -struct ev_spawn : public ev_common -{ -}; - -struct ev_death : public ev_common -{ -}; - -struct ev_sound : public ev_common -{ - int sound; -}; - -struct ev_damageind : public ev_common -{ - int angle; -}; - -struct obj_game -{ - int round_start_tick; - int game_over; - int sudden_death; - int paused; - - int score_limit; - int time_limit; - int gametype; - - int warmup; - - int teamscore[2]; -}; - -struct obj_projectile -{ - int x, y; - int vx, vy; // should be an angle instead - int type; - int start_tick; -}; - -struct obj_laser -{ - int x, y; - int from_x, from_y; - int eval_tick; -}; - -struct obj_powerup -{ - int x, y; - int type; // why do we need two types? - int subtype; -}; - -struct obj_flag -{ - int x, y; - int team; - int carried_by; // is set if the local player has the flag -}; - -// core object needed for physics -struct obj_player_core -{ - int x, y; - int vx, vy; - int angle; - int jumped; - - int hooked_player; - int hook_state; - int hook_tick; - int hook_x, hook_y; - int hook_dx, hook_dy; -}; - -// info about the player that is only needed when it's on screen -struct obj_player_character : public obj_player_core -{ - int player_state; - - int health; - int armor; - int ammocount; - int weaponstage; - - int weapon; // current active weapon - - int emote; - - int attacktick; // num attack ticks left of current attack -}; - -// information about the player that is always needed -struct obj_player_info -{ - int local; - int clientid; - - int team; - int score; - int latency; - int latency_flux; -};*/ - -#endif diff --git a/src/game/g_protocol.hpp b/src/game/g_protocol.hpp new file mode 100644 index 00000000..8650b8be --- /dev/null +++ b/src/game/g_protocol.hpp @@ -0,0 +1,217 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +// NOTE: Be very careful when editing this file as it will change the network version + +#ifndef GAME_PROTOCOL_H +#define GAME_PROTOCOL_H + +#include + +// Network stuff +/* +enum +{ + OBJTYPE_NULL=0, + OBJTYPE_GAME, + OBJTYPE_PLAYER_INFO, + OBJTYPE_PLAYER_CHARACTER, // use this if you are searching for the player entity + OBJTYPE_PROJECTILE, + OBJTYPE_LASER, + OBJTYPE_POWERUP, + OBJTYPE_FLAG, + EVENT_EXPLOSION, + EVENT_DAMAGEINDICATION, + EVENT_SOUND_WORLD, + EVENT_SMOKE, + EVENT_PLAYERSPAWN, + EVENT_DEATH, + EVENT_AIR_JUMP, + + EVENT_DUMMY +}; + +enum +{ + MSG_NULL=0, + MSG_SAY, // client -> server + MSG_CHAT, // server -> client + MSG_SETINFO, // server -> client - contains name, skin and color info + MSG_KILLMSG, // server -> client + MSG_SETTEAM, + MSG_JOIN, + MSG_QUIT, + MSG_EMOTICON, + MSG_STARTINFO, // client -> server + MSG_CHANGEINFO, // client -> server + MSG_READY_TO_ENTER, // server -> client + MSG_WEAPON_PICKUP, + MSG_SOUND_GLOBAL, + MSG_TUNE_PARAMS, + MSG_KILL, + MSG_EXTRA_PROJECTILE, // server -> client + +}; + +enum +{ + EMOTE_NORMAL=0, + EMOTE_PAIN, + EMOTE_HAPPY, + EMOTE_SURPRISE, + EMOTE_ANGRY, + EMOTE_BLINK, +}; + +enum +{ + INPUT_STATE_MASK=0x1f, +}; + +enum +{ + PLAYERSTATE_UNKNOWN=0, + PLAYERSTATE_PLAYING, + PLAYERSTATE_IN_MENU, + PLAYERSTATE_CHATTING, + + GAMETYPE_DM=0, + GAMETYPE_TDM, + GAMETYPE_CTF, +}; + +struct player_input +{ + int left; + int right; + + int target_x; + int target_y; + + int jump; + int fire; + int hook; + int blink; + + int player_state; + + int wanted_weapon; + int next_weapon; + int prev_weapon; +}; + +struct ev_common +{ + int x, y; +}; + +struct ev_explosion : public ev_common +{ +}; + +struct ev_spawn : public ev_common +{ +}; + +struct ev_death : public ev_common +{ +}; + +struct ev_sound : public ev_common +{ + int sound; +}; + +struct ev_damageind : public ev_common +{ + int angle; +}; + +struct obj_game +{ + int round_start_tick; + int game_over; + int sudden_death; + int paused; + + int score_limit; + int time_limit; + int gametype; + + int warmup; + + int teamscore[2]; +}; + +struct obj_projectile +{ + int x, y; + int vx, vy; // should be an angle instead + int type; + int start_tick; +}; + +struct obj_laser +{ + int x, y; + int from_x, from_y; + int eval_tick; +}; + +struct obj_powerup +{ + int x, y; + int type; // why do we need two types? + int subtype; +}; + +struct obj_flag +{ + int x, y; + int team; + int carried_by; // is set if the local player has the flag +}; + +// core object needed for physics +struct obj_player_core +{ + int x, y; + int vx, vy; + int angle; + int jumped; + + int hooked_player; + int hook_state; + int hook_tick; + int hook_x, hook_y; + int hook_dx, hook_dy; +}; + +// info about the player that is only needed when it's on screen +struct obj_player_character : public obj_player_core +{ + int player_state; + + int health; + int armor; + int ammocount; + int weaponstage; + + int weapon; // current active weapon + + int emote; + + int attacktick; // num attack ticks left of current attack +}; + +// information about the player that is always needed +struct obj_player_info +{ + int local; + int clientid; + + int team; + int score; + int latency; + int latency_flux; +};*/ + +#endif diff --git a/src/game/g_tuning.h b/src/game/g_tuning.h deleted file mode 100644 index d35ef148..00000000 --- a/src/game/g_tuning.h +++ /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_tuning.hpp b/src/game/g_tuning.hpp new file mode 100644 index 00000000..d35ef148 --- /dev/null +++ b/src/game/g_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/g_variables.h b/src/game/g_variables.h deleted file mode 100644 index fb69584e..00000000 --- a/src/game/g_variables.h +++ /dev/null @@ -1,59 +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(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_variables.hpp b/src/game/g_variables.hpp new file mode 100644 index 00000000..fb69584e --- /dev/null +++ b/src/game/g_variables.hpp @@ -0,0 +1,59 @@ +/* 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(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.h b/src/game/g_version.h deleted file mode 100644 index 7472c783..00000000 --- a/src/game/g_version.h +++ /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/g_version.hpp b/src/game/g_version.hpp new file mode 100644 index 00000000..7472c783 --- /dev/null +++ b/src/game/g_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/game/g_vmath.h b/src/game/g_vmath.h deleted file mode 100644 index ac3e1870..00000000 --- a/src/game/g_vmath.h +++ /dev/null @@ -1,198 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#ifndef BASE_VMATH_H -#define BASE_VMATH_H - -//#include - -// ------------------------------------ - -template -class vector2_base -{ -public: - union { T x,u; }; - union { T y,v; }; - - vector2_base() {} - vector2_base(float nx, float ny) - { - x = nx; - y = ny; - } - - vector2_base operator -() const { return vector2_base(-x, -y); } - vector2_base operator -(const vector2_base &v) const { return vector2_base(x-v.x, y-v.y); } - vector2_base operator +(const vector2_base &v) const { return vector2_base(x+v.x, y+v.y); } - vector2_base operator *(const T v) const { return vector2_base(x*v, y*v); } - - const vector2_base &operator =(const vector2_base &v) { x = v.x; y = v.y; return *this; } - - const vector2_base &operator +=(const vector2_base &v) { x += v.x; y += v.y; return *this; } - const vector2_base &operator -=(const vector2_base &v) { x -= v.x; y -= v.y; return *this; } - const vector2_base &operator *=(const T v) { x *= v; y *= v; return *this; } - - bool operator ==(const vector2_base &v) const { return x == v.x && y == v.y; } //TODO: do this with an eps instead - - operator const T* () { return &x; } -}; - - -template -inline T length(const vector2_base &a) -{ - return sqrtf(a.x*a.x + a.y*a.y); -} - -template -inline T distance(const vector2_base a, const vector2_base &b) -{ - return length(a-b); -} - -template -inline T dot(const vector2_base a, const vector2_base &b) -{ - return a.x*b.x + a.y*b.y; -} - -template -inline vector2_base normalize(const vector2_base &v) -{ - T l = (T)(1.0f/sqrtf(v.x*v.x + v.y*v.y)); - return vector2_base(v.x*l, v.y*l); -} - -typedef vector2_base vec2; -typedef vector2_base bvec2; -typedef vector2_base ivec2; - -template -inline vector2_base closest_point_on_line(vector2_base line_point0, vector2_base line_point1, vector2_base target_point) -{ - vector2_base c = target_point - line_point0; - vector2_base v = (line_point1 - line_point0); - v = normalize(v); - T d = length(line_point0-line_point1); - T t = dot(v, c)/d; - return mix(line_point0, line_point1, clamp(t, (T)0, (T)1)); - /* - if (t < 0) t = 0; - if (t > 1.0f) return 1.0f; - return t;*/ -} - -// ------------------------------------ -template -class vector3_base -{ -public: - union { T x,r,h; }; - union { T y,g,s; }; - union { T z,b,v,l; }; - - vector3_base() {} - vector3_base(float nx, float ny, float nz) - { - x = nx; - y = ny; - z = nz; - } - - const vector3_base &operator =(const vector3_base &v) { x = v.x; y = v.y; z = v.z; return *this; } - - vector3_base operator -(const vector3_base &v) const { return vector3_base(x-v.x, y-v.y, z-v.z); } - vector3_base operator -() const { return vector3_base(-x, -y, -z); } - vector3_base operator +(const vector3_base &v) const { return vector3_base(x+v.x, y+v.y, z+v.z); } - vector3_base operator *(const T v) const { return vector3_base(x*v, y*v, z*v); } - vector3_base operator *(const vector3_base &v) const { return vector3_base(x*v.x, y*v.y, z*v.z); } - vector3_base operator /(const T v) const { return vector3_base(x/v, y/v, z/v); } - - const vector3_base &operator +=(const vector3_base &v) { x += v.x; y += v.y; z += v.z; return *this; } - const vector3_base &operator -=(const vector3_base &v) { x -= v.x; y -= v.y; z -= v.z; return *this; } - const vector3_base &operator *=(const T v) { x *= v; y *= v; z *= v; return *this; } - - bool operator ==(const vector3_base &v) const { return x == v.x && y == v.y && z == v.z; } //TODO: do this with an eps instead - - operator const T* () { return &x; } -}; - -template -inline T length(const vector3_base &a) -{ - return sqrtf(a.x*a.x + a.y*a.y + a.z*a.z); -} - -template -inline T distance(const vector3_base &a, const vector3_base &b) -{ - return length(a-b); -} - -template -inline T dot(const vector3_base &a, const vector3_base &b) -{ - return a.x*b.x + a.y*b.y + a.z*b.z; -} - -template -inline vector3_base normalize(const vector3_base &v) -{ - T l = (T)(1.0f/sqrtf(v.x*v.x + v.y*v.y + v.z*v.z)); - return vector3_base(v.x*l, v.y*l, v.z*l); -} - -template -inline vector3_base cross(const vector3_base &a, const vector3_base &b) -{ - return vector3_base( - a.y*b.z - a.z*b.y, - a.z*b.x - a.x*b.z, - a.x*b.y - a.y*b.x); -} - -typedef vector3_base vec3; -typedef vector3_base bvec3; -typedef vector3_base ivec3; - -// ------------------------------------ - -template -class vector4_base -{ -public: - union { T x,r; }; - union { T y,g; }; - union { T z,b; }; - union { T w,a; }; - - vector4_base() {} - vector4_base(float nx, float ny, float nz, float nw) - { - x = nx; - y = ny; - z = nz; - w = nw; - } - - vector4_base operator +(const vector4_base &v) const { return vector4_base(x+v.x, y+v.y, z+v.z, w+v.w); } - vector4_base operator -(const vector4_base &v) const { return vector4_base(x-v.x, y-v.y, z-v.z, w-v.w); } - vector4_base operator -() const { return vector4_base(-x, -y, -z, -w); } - vector4_base operator *(const vector4_base &v) const { return vector4_base(x*v.x, y*v.y, z*v.z, w*v.w); } - vector4_base operator *(const T v) const { return vector4_base(x*v, y*v, z*v, w*v); } - - const vector4_base &operator =(const vector4_base &v) { x = v.x; y = v.y; z = v.z; w = v.w; return *this; } - - const vector4_base &operator +=(const vector4_base &v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; } - const vector4_base &operator -=(const vector4_base &v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; } - const vector4_base &operator *=(const T v) { x *= v; y *= v; z *= v; w *= v; return *this; } - - bool operator ==(const vector4_base &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; } //TODO: do this with an eps instead - - operator const T* () { return &x; } -}; - -typedef vector4_base vec4; -typedef vector4_base bvec4; -typedef vector4_base ivec4; - -#endif diff --git a/src/game/g_vmath.hpp b/src/game/g_vmath.hpp new file mode 100644 index 00000000..ac3e1870 --- /dev/null +++ b/src/game/g_vmath.hpp @@ -0,0 +1,198 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +#ifndef BASE_VMATH_H +#define BASE_VMATH_H + +//#include + +// ------------------------------------ + +template +class vector2_base +{ +public: + union { T x,u; }; + union { T y,v; }; + + vector2_base() {} + vector2_base(float nx, float ny) + { + x = nx; + y = ny; + } + + vector2_base operator -() const { return vector2_base(-x, -y); } + vector2_base operator -(const vector2_base &v) const { return vector2_base(x-v.x, y-v.y); } + vector2_base operator +(const vector2_base &v) const { return vector2_base(x+v.x, y+v.y); } + vector2_base operator *(const T v) const { return vector2_base(x*v, y*v); } + + const vector2_base &operator =(const vector2_base &v) { x = v.x; y = v.y; return *this; } + + const vector2_base &operator +=(const vector2_base &v) { x += v.x; y += v.y; return *this; } + const vector2_base &operator -=(const vector2_base &v) { x -= v.x; y -= v.y; return *this; } + const vector2_base &operator *=(const T v) { x *= v; y *= v; return *this; } + + bool operator ==(const vector2_base &v) const { return x == v.x && y == v.y; } //TODO: do this with an eps instead + + operator const T* () { return &x; } +}; + + +template +inline T length(const vector2_base &a) +{ + return sqrtf(a.x*a.x + a.y*a.y); +} + +template +inline T distance(const vector2_base a, const vector2_base &b) +{ + return length(a-b); +} + +template +inline T dot(const vector2_base a, const vector2_base &b) +{ + return a.x*b.x + a.y*b.y; +} + +template +inline vector2_base normalize(const vector2_base &v) +{ + T l = (T)(1.0f/sqrtf(v.x*v.x + v.y*v.y)); + return vector2_base(v.x*l, v.y*l); +} + +typedef vector2_base vec2; +typedef vector2_base bvec2; +typedef vector2_base ivec2; + +template +inline vector2_base closest_point_on_line(vector2_base line_point0, vector2_base line_point1, vector2_base target_point) +{ + vector2_base c = target_point - line_point0; + vector2_base v = (line_point1 - line_point0); + v = normalize(v); + T d = length(line_point0-line_point1); + T t = dot(v, c)/d; + return mix(line_point0, line_point1, clamp(t, (T)0, (T)1)); + /* + if (t < 0) t = 0; + if (t > 1.0f) return 1.0f; + return t;*/ +} + +// ------------------------------------ +template +class vector3_base +{ +public: + union { T x,r,h; }; + union { T y,g,s; }; + union { T z,b,v,l; }; + + vector3_base() {} + vector3_base(float nx, float ny, float nz) + { + x = nx; + y = ny; + z = nz; + } + + const vector3_base &operator =(const vector3_base &v) { x = v.x; y = v.y; z = v.z; return *this; } + + vector3_base operator -(const vector3_base &v) const { return vector3_base(x-v.x, y-v.y, z-v.z); } + vector3_base operator -() const { return vector3_base(-x, -y, -z); } + vector3_base operator +(const vector3_base &v) const { return vector3_base(x+v.x, y+v.y, z+v.z); } + vector3_base operator *(const T v) const { return vector3_base(x*v, y*v, z*v); } + vector3_base operator *(const vector3_base &v) const { return vector3_base(x*v.x, y*v.y, z*v.z); } + vector3_base operator /(const T v) const { return vector3_base(x/v, y/v, z/v); } + + const vector3_base &operator +=(const vector3_base &v) { x += v.x; y += v.y; z += v.z; return *this; } + const vector3_base &operator -=(const vector3_base &v) { x -= v.x; y -= v.y; z -= v.z; return *this; } + const vector3_base &operator *=(const T v) { x *= v; y *= v; z *= v; return *this; } + + bool operator ==(const vector3_base &v) const { return x == v.x && y == v.y && z == v.z; } //TODO: do this with an eps instead + + operator const T* () { return &x; } +}; + +template +inline T length(const vector3_base &a) +{ + return sqrtf(a.x*a.x + a.y*a.y + a.z*a.z); +} + +template +inline T distance(const vector3_base &a, const vector3_base &b) +{ + return length(a-b); +} + +template +inline T dot(const vector3_base &a, const vector3_base &b) +{ + return a.x*b.x + a.y*b.y + a.z*b.z; +} + +template +inline vector3_base normalize(const vector3_base &v) +{ + T l = (T)(1.0f/sqrtf(v.x*v.x + v.y*v.y + v.z*v.z)); + return vector3_base(v.x*l, v.y*l, v.z*l); +} + +template +inline vector3_base cross(const vector3_base &a, const vector3_base &b) +{ + return vector3_base( + a.y*b.z - a.z*b.y, + a.z*b.x - a.x*b.z, + a.x*b.y - a.y*b.x); +} + +typedef vector3_base vec3; +typedef vector3_base bvec3; +typedef vector3_base ivec3; + +// ------------------------------------ + +template +class vector4_base +{ +public: + union { T x,r; }; + union { T y,g; }; + union { T z,b; }; + union { T w,a; }; + + vector4_base() {} + vector4_base(float nx, float ny, float nz, float nw) + { + x = nx; + y = ny; + z = nz; + w = nw; + } + + vector4_base operator +(const vector4_base &v) const { return vector4_base(x+v.x, y+v.y, z+v.z, w+v.w); } + vector4_base operator -(const vector4_base &v) const { return vector4_base(x-v.x, y-v.y, z-v.z, w-v.w); } + vector4_base operator -() const { return vector4_base(-x, -y, -z, -w); } + vector4_base operator *(const vector4_base &v) const { return vector4_base(x*v.x, y*v.y, z*v.z, w*v.w); } + vector4_base operator *(const T v) const { return vector4_base(x*v, y*v, z*v, w*v); } + + const vector4_base &operator =(const vector4_base &v) { x = v.x; y = v.y; z = v.z; w = v.w; return *this; } + + const vector4_base &operator +=(const vector4_base &v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; } + const vector4_base &operator -=(const vector4_base &v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; } + const vector4_base &operator *=(const T v) { x *= v; y *= v; z *= v; w *= v; return *this; } + + bool operator ==(const vector4_base &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; } //TODO: do this with an eps instead + + operator const T* () { return &x; } +}; + +typedef vector4_base vec4; +typedef vector4_base bvec4; +typedef vector4_base ivec4; + +#endif diff --git a/src/game/server/gs_common.h b/src/game/server/gs_common.h deleted file mode 100644 index 6b307cdf..00000000 --- a/src/game/server/gs_common.h +++ /dev/null @@ -1,357 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -#include "../g_game.h" -#include "../generated/gs_data.h" - - -extern TUNING_PARAMS tuning; - -void create_sound_global(int sound, int target=-1); - -inline int cmask_all() { return -1; } -inline int cmask_one(int cid) { return 1< #include #include -#include -#include "gs_common.h" +#include +#include "gs_common.hpp" GAMECONTROLLER::GAMECONTROLLER() : ENTITY(NETOBJTYPE_GAME) diff --git a/src/game/server/gs_game_ctf.cpp b/src/game/server/gs_game_ctf.cpp index 59ec3981..031be42a 100644 --- a/src/game/server/gs_game_ctf.cpp +++ b/src/game/server/gs_game_ctf.cpp @@ -1,8 +1,8 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include -#include "gs_common.h" -#include "gs_game_ctf.h" +#include +#include "gs_common.hpp" +#include "gs_game_ctf.hpp" GAMECONTROLLER_CTF::GAMECONTROLLER_CTF() { diff --git a/src/game/server/gs_game_ctf.h b/src/game/server/gs_game_ctf.h deleted file mode 100644 index 6d512815..00000000 --- a/src/game/server/gs_game_ctf.h +++ /dev/null @@ -1,35 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ - -// game object -class GAMECONTROLLER_CTF : public GAMECONTROLLER -{ -public: - class FLAG *flags[2]; - - GAMECONTROLLER_CTF(); - virtual void tick(); - - virtual bool on_entity(int index, vec2 pos); - - virtual void on_player_spawn(class PLAYER *p); - virtual int on_player_death(class PLAYER *victim, class PLAYER *killer, int weapon); -}; - -// TODO: move to seperate file -class FLAG : public ENTITY -{ -public: - static const int phys_size = 14; - PLAYER *carrying_player; - vec2 vel; - vec2 stand_pos; - - int team; - int at_stand; - int drop_tick; - - FLAG(int _team); - - virtual void reset(); - virtual void snap(int snapping_client); -}; diff --git a/src/game/server/gs_game_ctf.hpp b/src/game/server/gs_game_ctf.hpp new file mode 100644 index 00000000..6d512815 --- /dev/null +++ b/src/game/server/gs_game_ctf.hpp @@ -0,0 +1,35 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ + +// game object +class GAMECONTROLLER_CTF : public GAMECONTROLLER +{ +public: + class FLAG *flags[2]; + + GAMECONTROLLER_CTF(); + virtual void tick(); + + virtual bool on_entity(int index, vec2 pos); + + virtual void on_player_spawn(class PLAYER *p); + virtual int on_player_death(class PLAYER *victim, class PLAYER *killer, int weapon); +}; + +// TODO: move to seperate file +class FLAG : public ENTITY +{ +public: + static const int phys_size = 14; + PLAYER *carrying_player; + vec2 vel; + vec2 stand_pos; + + int team; + int at_stand; + int drop_tick; + + FLAG(int _team); + + virtual void reset(); + virtual void snap(int snapping_client); +}; diff --git a/src/game/server/gs_game_dm.cpp b/src/game/server/gs_game_dm.cpp index 1d565372..264063bf 100644 --- a/src/game/server/gs_game_dm.cpp +++ b/src/game/server/gs_game_dm.cpp @@ -1,7 +1,7 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include "gs_common.h" -#include "gs_game_dm.h" +#include "gs_common.hpp" +#include "gs_game_dm.hpp" void GAMECONTROLLER_DM::tick() { diff --git a/src/game/server/gs_game_dm.h b/src/game/server/gs_game_dm.h deleted file mode 100644 index 99ceaec1..00000000 --- a/src/game/server/gs_game_dm.h +++ /dev/null @@ -1,7 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -// game object -class GAMECONTROLLER_DM : public GAMECONTROLLER -{ -public: - virtual void tick(); -}; diff --git a/src/game/server/gs_game_dm.hpp b/src/game/server/gs_game_dm.hpp new file mode 100644 index 00000000..99ceaec1 --- /dev/null +++ b/src/game/server/gs_game_dm.hpp @@ -0,0 +1,7 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +// game object +class GAMECONTROLLER_DM : public GAMECONTROLLER +{ +public: + virtual void tick(); +}; diff --git a/src/game/server/gs_game_tdm.cpp b/src/game/server/gs_game_tdm.cpp index 10c5a7dc..c591b447 100644 --- a/src/game/server/gs_game_tdm.cpp +++ b/src/game/server/gs_game_tdm.cpp @@ -1,7 +1,7 @@ /* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ #include -#include "gs_common.h" -#include "gs_game_tdm.h" +#include "gs_common.hpp" +#include "gs_game_tdm.hpp" GAMECONTROLLER_TDM::GAMECONTROLLER_TDM() { diff --git a/src/game/server/gs_game_tdm.h b/src/game/server/gs_game_tdm.h deleted file mode 100644 index 516b581c..00000000 --- a/src/game/server/gs_game_tdm.h +++ /dev/null @@ -1,10 +0,0 @@ -/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ -// game object -class GAMECONTROLLER_TDM : public GAMECONTROLLER -{ -public: - GAMECONTROLLER_TDM(); - - int on_player_death(class PLAYER *victim, class PLAYER *killer, int weapon); - virtual void tick(); -}; diff --git a/src/game/server/gs_game_tdm.hpp b/src/game/server/gs_game_tdm.hpp new file mode 100644 index 00000000..516b581c --- /dev/null +++ b/src/game/server/gs_game_tdm.hpp @@ -0,0 +1,10 @@ +/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */ +// game object +class GAMECONTROLLER_TDM : public GAMECONTROLLER +{ +public: + GAMECONTROLLER_TDM(); + + int on_player_death(class PLAYER *victim, class PLAYER *killer, int weapon); + virtual void tick(); +}; diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp index 86d7fe32..4e7b4179 100644 --- a/src/game/server/gs_server.cpp +++ b/src/game/server/gs_server.cpp @@ -4,14 +4,14 @@ #include #include #include -#include -#include -#include -#include -#include "gs_common.h" -#include "gs_game_ctf.h" -#include "gs_game_tdm.h" -#include "gs_game_dm.h" +#include +#include +#include +#include +#include "gs_common.hpp" +#include "gs_game_ctf.hpp" +#include "gs_game_tdm.hpp" +#include "gs_game_dm.hpp" TUNING_PARAMS tuning; -- cgit 1.4.1