From: TimePath Date: Sat, 10 Oct 2015 02:06:58 +0000 (+1100) Subject: #includes: cleanup client X-Git-Tag: xonotic-v0.8.2~1839^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f40d50ebdbbfc5c65f0e75cdfa3bd176501e8d4a;p=xonotic%2Fxonotic-data.pk3dir.git #includes: cleanup client --- diff --git a/qcsrc/client/_all.qh b/qcsrc/client/_all.qh index 7ae1430d4..adff5ccff 100644 --- a/qcsrc/client/_all.qh +++ b/qcsrc/client/_all.qh @@ -1,12 +1,15 @@ #ifndef CLIENT_ALL_H #define CLIENT_ALL_H +#include "../common/util.qh" + +#include "../common/effects/all.qh" +#include "../common/models/all.qh" +#include "../common/sounds/all.qh" + #include "autocvars.qh" #include "defs.qh" #include "main.qh" #include "miscfunctions.qh" -#include "../common/models/all.qh" -#include "../common/sounds/all.qh" - #endif diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index b7b7bb5c6..e20557fa7 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -1,9 +1,7 @@ #include "announcer.qh" -#include "_all.qh" #include "../common/notifications.qh" #include "../common/stats.qh" -#include "../common/util.qh" bool announcer_1min; bool announcer_5min; diff --git a/qcsrc/client/announcer.qh b/qcsrc/client/announcer.qh index 620b84544..64be1433a 100644 --- a/qcsrc/client/announcer.qh +++ b/qcsrc/client/announcer.qh @@ -1,5 +1,5 @@ -#ifndef ANNOUNCER_H -#define ANNOUNCER_H +#ifndef CLIENT_ANNOUNCER_H +#define CLIENT_ANNOUNCER_H void Announcer(); diff --git a/qcsrc/client/bgmscript.qc b/qcsrc/client/bgmscript.qc index 894bf6955..a984a19a3 100644 --- a/qcsrc/client/bgmscript.qc +++ b/qcsrc/client/bgmscript.qc @@ -1,7 +1,4 @@ #include "bgmscript.qh" -#include "_all.qh" - -#include "../common/util.qh" #define CONSTANT_SPEED_DECAY diff --git a/qcsrc/client/bgmscript.qh b/qcsrc/client/bgmscript.qh index 5921bb4bc..d979e79d0 100644 --- a/qcsrc/client/bgmscript.qh +++ b/qcsrc/client/bgmscript.qh @@ -1,5 +1,5 @@ -#ifndef BGMSCRIPT_H -#define BGMSCRIPT_H +#ifndef CLIENT_BGMSCRIPT_H +#define CLIENT_BGMSCRIPT_H entityclass(BGMScript); class(BGMScript) .string bgmscript; diff --git a/qcsrc/client/command/all.qc b/qcsrc/client/command/all.qc deleted file mode 100644 index dcace6593..000000000 --- a/qcsrc/client/command/all.qc +++ /dev/null @@ -1,5 +0,0 @@ -#include "../_all.qh" - -#include "../../common/command/all.qc" - -#include "cl_cmd.qc" diff --git a/qcsrc/client/command/all.qh b/qcsrc/client/command/all.qh deleted file mode 100644 index 34fc423a4..000000000 --- a/qcsrc/client/command/all.qh +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef CLIENT_COMMANDS_ALL_H -#define CLIENT_COMMANDS_ALL_H - -#include "../../common/command/all.qh" - -#include "cl_cmd.qh" - -#endif diff --git a/qcsrc/client/command/cl_cmd.qc b/qcsrc/client/command/cl_cmd.qc deleted file mode 100644 index 88cd246ff..000000000 --- a/qcsrc/client/command/cl_cmd.qc +++ /dev/null @@ -1,675 +0,0 @@ -// ============================================== -// CSQC client commands code, written by Samual -// Last updated: December 28th, 2011 -// ============================================== - -#include "../../common/command/command.qh" -#include "cl_cmd.qh" - -#include "../autocvars.qh" -#include "../defs.qh" -#include "../hud.qh" -#include "../hud_config.qh" -#include "../main.qh" -#include "../mapvoting.qh" -#include "../miscfunctions.qh" - -#include "../mutators/events.qh" - -#include "../../common/mapinfo.qh" - -#include "../../common/command/generic.qh" - -void DrawDebugModel(entity this) -{ - if(time - floor(time) > 0.5) - { - PolyDrawModel(self); - self.drawmask = 0; - } - else - { - self.renderflags = 0; - self.drawmask = MASK_NORMAL; - } -} - - -// ======================= -// Command Sub-Functions -// ======================= - -void LocalCommand_blurtest(int request) -{ - // Simple command to work with postprocessing temporarily... possibly completely pointless, the glsl shader is used for a real feature now... - // Anyway, to enable it, just compile the client with -DBLURTEST and then you can use the command. - - #ifdef BLURTEST - switch(request) - { - case CMD_REQUEST_COMMAND: - { - blurtest_time0 = time; - blurtest_time1 = time + stof(argv(1)); - blurtest_radius = stof(argv(2)); - blurtest_power = stof(argv(3)); - LOG_INFO("Enabled blurtest\n"); - return; - } - - default: - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd blurtest\n"); - LOG_INFO(" No arguments required.\n"); - return; - } - } - #else - if(request) - { - LOG_INFO("Blurtest is not enabled on this client.\n"); - return; - } - #endif -} - -void LocalCommand_boxparticles(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - if (argc == 9) - { - int effect = _particleeffectnum(argv(1)); - if (effect >= 0) - { - int index = stoi(argv(2)); - entity own; - if(index <= 0) - own = entitybyindex(-index); - else - own = findfloat(world, entnum, index); - vector org_from = stov(argv(3)); - vector org_to = stov(argv(4)); - vector dir_from = stov(argv(5)); - vector dir_to = stov(argv(6)); - int countmultiplier = stoi(argv(7)); - int flags = stoi(argv(8)); - boxparticles(effect, own, org_from, org_to, dir_from, dir_to, countmultiplier, flags); - return; - } - } - } - - default: - LOG_INFO("Incorrect parameters for ^2boxparticles^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 lv_cmd boxparticles effectname own org_from org_to, dir_from, dir_to, countmultiplier, flags\n"); - LOG_INFO(" 'effectname' is the name of a particle effect in effectinfo.txt\n"); - LOG_INFO(" 'own' is the entity number of the owner (negative for csqc ent, positive for svqc ent)\n"); - LOG_INFO(" 'org_from' is the starting origin of the box\n"); - LOG_INFO(" 'org_to' is the ending origin of the box\n"); - LOG_INFO(" 'dir_from' is the minimum velocity\n"); - LOG_INFO(" 'dir_to' is the maximum velocity\n"); - LOG_INFO(" 'countmultiplier' defines a multiplier for the particle count (affects count only, not countabsolute or trailspacing)\n"); - LOG_INFO(" 'flags' can contain:\n"); - LOG_INFO(" 1 to respect globals particles_alphamin, particles_alphamax (set right before via prvm_globalset client)\n"); - LOG_INFO(" 2 to respect globals particles_colormin, particles_colormax (set right before via prvm_globalset client)\n"); - LOG_INFO(" 4 to respect globals particles_fade (set right before via prvm_globalset client)\n"); - LOG_INFO(" 128 to draw a trail, not a box\n"); - return; - } - } -} - -void LocalCommand_create_scrshot_ent(int request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - string filename = strcat(MapInfo_Map_bspname, "_scrshot_ent.txt"); - int fh = fopen(filename, FILE_WRITE); - - if(fh >= 0) - { - fputs(fh, "{\n"); - fputs(fh, strcat("\"classname\" \"info_autoscreenshot\"\n")); - fputs(fh, strcat("\"origin\" \"", strcat(ftos(view_origin.x), " ", ftos(view_origin.y), " ", ftos(view_origin.z)), "\"\n")); - fputs(fh, strcat("\"angles\" \"", strcat(ftos(view_angles.x), " ", ftos(view_angles.y), " ", ftos(view_angles.z)), "\"\n")); - fputs(fh, "}\n"); - - LOG_INFO("Completed screenshot entity dump in ^2data/data/", MapInfo_Map_bspname, "_scrshot_ent.txt^7.\n"); - - fclose(fh); - } - else - { - LOG_INFO("^1Error: ^7Could not dump to file!\n"); - } - return; - } - - default: - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd create_scrshot_ent\n"); - LOG_INFO(" No arguments required.\n"); - return; - } - } -} - -void LocalCommand_debugmodel(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - string modelname = argv(1); - entity debugmodel_entity; - - debugmodel_entity = spawn(); - precache_model(modelname); - _setmodel(debugmodel_entity, modelname); - setorigin(debugmodel_entity, view_origin); - debugmodel_entity.angles = view_angles; - debugmodel_entity.draw = DrawDebugModel; - debugmodel_entity.classname = "debugmodel"; - - return; - } - - default: - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd debugmodel model\n"); - LOG_INFO(" Where 'model' is a string of the model name to use for the debug model.\n"); - return; - } - } -} - -void LocalCommand_handlevote(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - int vote_selection; - string vote_string; - - if(InterpretBoolean(argv(1))) - { - vote_selection = 2; - vote_string = "yes"; - } - else - { - vote_selection = 1; - vote_string = "no"; - } - - if(vote_selection) - { - if(uid2name_dialog) // handled by "uid2name" option - { - vote_active = 0; - vote_prev = 0; - vote_change = -9999; - localcmd(strcat("setreport cl_allow_uid2name ", ftos(vote_selection - 1), "\n")); - uid2name_dialog = 0; - } - else { localcmd(strcat("cmd vote ", vote_string, "\n")); } - - return; - } - } - - default: - LOG_INFO("Incorrect parameters for ^2handlevote^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd handlevote vote\n"); - LOG_INFO(" Where 'vote' is the selection for either the current poll or uid2name.\n"); - return; - } - } -} - -void LocalCommand_hud(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - switch(argv(1)) - { - case "configure": - { - cvar_set("_hud_configure", ftos(!autocvar__hud_configure)); - return; - } - - case "quickmenu": - { - if(QuickMenu_IsOpened()) - QuickMenu_Close(); - else - QuickMenu_Open(argv(2), argv(3)); // mode, submenu - return; - } - - case "minigame": - { - if(HUD_MinigameMenu_IsOpened()) - HUD_MinigameMenu_Close(); - else - HUD_MinigameMenu_Open(); - return; - } - - case "save": - { - if(argv(2)) - { - HUD_Panel_ExportCfg(argv(2)); - return; - } - else - { - break; // go to usage, we're missing the paramater needed here. - } - } - - case "scoreboard_columns_set": - { - Cmd_HUD_SetFields(argc); - return; - } - - case "scoreboard_columns_help": - { - Cmd_HUD_Help(); - return; - } - - case "radar": - { - if(argv(2)) - HUD_Radar_Show_Maximized(InterpretBoolean(argv(2)),0); - else - HUD_Radar_Show_Maximized(!hud_panel_radar_maximized,0); - return; - } - - case "clickradar": - { - HUD_Radar_Show_Maximized(!hud_panel_radar_mouse,1); - return; - } - } - } - - default: - LOG_INFO("Incorrect parameters for ^2hud^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd hud action [configname | radartoggle | layout]\n"); - LOG_INFO(" Where 'action' is the command to complete,\n"); - LOG_INFO(" 'configname' is the name to save to for \"save\" action,\n"); - LOG_INFO(" 'radartoggle' is to control hud_panel_radar_maximized for \"radar\" action,\n"); - LOG_INFO(" and 'layout' is how to organize the scoreboard columns for the set action.\n"); - LOG_INFO(" quickmenu [[default | file | \"\"] submenu]\n"); - LOG_INFO(" Called without options (or with "") loads either the default quickmenu or a quickmenu file if hud_panel_quickmenu_file is set to a valid filename.\n"); - LOG_INFO(" Submenu option allows to open quickmenu directly in a submenu, it requires to specify 'default', 'file' or '\"\"' option.\n"); - LOG_INFO(" Full list of commands here: \"configure, minigame, save, scoreboard_columns_help, scoreboard_columns_set, radar.\"\n"); - return; - } - } -} - -void LocalCommand_localprint(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - if(argv(1)) - { - centerprint_hud(argv(1)); - return; - } - } - - default: - LOG_INFO("Incorrect parameters for ^2localprint^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd localprint \"message\"\n"); - LOG_INFO(" 'message' is the centerprint message to send to yourself.\n"); - return; - } - } -} - -void LocalCommand_mv_download(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - if(argv(1)) - { - Cmd_MapVote_MapDownload(argc); - return; - } - } - - default: - LOG_INFO("Incorrect parameters for ^2mv_download^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd mv_download mapid\n"); - LOG_INFO(" Where 'mapid' is the id number of the map to request an image of on the map vote selection menu.\n"); - return; - } - } -} - -void LocalCommand_find(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - entity client; - - for(client = world; (client = find(client, classname, argv(1))); ) - LOG_INFO(etos(client), "\n"); - - return; - } - - default: - LOG_INFO("Incorrect parameters for ^2find^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd find classname\n"); - LOG_INFO(" Where 'classname' is the classname to search for.\n"); - return; - } - } -} - -void LocalCommand_sendcvar(int request, int argc) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - if(argv(1)) - { - // W_FixWeaponOrder will trash argv, so save what we need. - string thiscvar = strzone(argv(1)); - string s = cvar_string(thiscvar); - - if(thiscvar == "cl_weaponpriority") - s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1); - else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18) - s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0); - - localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n"); - strunzone(thiscvar); - return; - } - } - - default: - LOG_INFO("Incorrect parameters for ^2sendcvar^7\n"); - case CMD_REQUEST_USAGE: - { - LOG_INFO("\nUsage:^3 cl_cmd sendcvar \n"); - LOG_INFO(" Where 'cvar' is the cvar plus arguments to send to the server.\n"); - return; - } - } -} - -/* use this when creating a new command, making sure to place it in alphabetical order... also, -** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! -void LocalCommand_(int request) -{ - switch(request) - { - case CMD_REQUEST_COMMAND: - { - - return; - } - - default: - case CMD_REQUEST_USAGE: - { - print("\nUsage:^3 cl_cmd \n"); - print(" No arguments required.\n"); - return; - } - } -} -*/ - - -// ================================== -// Macro system for client commands -// ================================== - -// Normally do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) -#define CLIENT_COMMANDS(request,arguments) \ - CLIENT_COMMAND("blurtest", LocalCommand_blurtest(request), "Feature for testing blur postprocessing") \ - CLIENT_COMMAND("boxparticles", LocalCommand_boxparticles(request, arguments), "Spawn particles manually") \ - CLIENT_COMMAND("create_scrshot_ent", LocalCommand_create_scrshot_ent(request), "Create an entity at this location for automatic screenshots") \ - CLIENT_COMMAND("debugmodel", LocalCommand_debugmodel(request, arguments), "Spawn a debug model manually") \ - CLIENT_COMMAND("handlevote", LocalCommand_handlevote(request, arguments), "System to handle selecting a vote or option") \ - CLIENT_COMMAND("hud", LocalCommand_hud(request, arguments), "Commands regarding/controlling the HUD system") \ - CLIENT_COMMAND("localprint", LocalCommand_localprint(request, arguments), "Create your own centerprint sent to yourself") \ - CLIENT_COMMAND("find", LocalCommand_find(request, arguments), "Search through entities for matching classname") \ - CLIENT_COMMAND("mv_download", LocalCommand_mv_download(request, arguments), "Retrieve mapshot picture from the server") \ - CLIENT_COMMAND("sendcvar", LocalCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \ - /* nothing */ - -void LocalCommand_macro_help() -{ - #define CLIENT_COMMAND(name,function,description) \ - { if(strtolower(description) != "") { LOG_INFO(" ^2", name, "^7: ", description, "\n"); } } - - CLIENT_COMMANDS(0, 0); - #undef CLIENT_COMMAND - - return; -} - -bool LocalCommand_macro_command(int argc) -{ - #define CLIENT_COMMAND(name,function,description) \ - { if(name == strtolower(argv(0))) { function; return true; } } - - CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc); - #undef CLIENT_COMMAND - - return false; -} - -bool LocalCommand_macro_usage(int argc) -{ - #define CLIENT_COMMAND(name,function,description) \ - { if(name == strtolower(argv(1))) { function; return true; } } - - CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc); - #undef CLIENT_COMMAND - - return false; -} - -void LocalCommand_macro_write_aliases(int fh) -{ - #define CLIENT_COMMAND(name,function,description) \ - { if(strtolower(description) != "") { CMD_Write_Alias("qc_cmd_cl", name, description); } } - - CLIENT_COMMANDS(0, 0); - #undef CLIENT_COMMAND - - return; -} - - -// ========================================= -// Main Function Called By Engine (cl_cmd) -// ========================================= -// If this function exists, client code handles gamecommand instead of the engine code. - -void GameCommand(string command) -{ - int argc = tokenize_console(command); - - // Guide for working with argc arguments by example: - // argc: 1 - 2 - 3 - 4 - // argv: 0 - 1 - 2 - 3 - // cmd vote - master - login - password - string s = strtolower(argv(0)); - if (s == "help") - { - if(argc == 1) - { - LOG_INFO("\nClient console commands:\n"); - LocalCommand_macro_help(); - - LOG_INFO("\nGeneric commands shared by all programs:\n"); - GenericCommand_macro_help(); - - LOG_INFO("\nUsage:^3 cl_cmd COMMAND...^7, where possible commands are listed above.\n"); - LOG_INFO("For help about a specific command, type cl_cmd help COMMAND\n"); - - return; - } - else if(GenericCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it - { - return; - } - else if(LocalCommand_macro_usage(argc)) // now try for normal commands too - { - return; - } - } - // continue as usual and scan for normal commands - if (GenericCommand(command)// handled by common/command/generic.qc - || LocalCommand_macro_command(argc) // handled by one of the above LocalCommand_* functions - || MUTATOR_CALLHOOK(CSQC_ConsoleCommand, s, argc, command) // handled by a mutator - ) return; - - // nothing above caught the command, must be invalid - LOG_INFO(((command != "") ? strcat("Unknown client command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try cl_cmd help.\n"); - - return; -} - - -// =================================== -// Macro system for console commands -// =================================== - -// These functions are here specifically to add special + - commands to the game, and are not really normal commands. -// Please add client commands to the function above this, as this is only for special reasons. -#define CONSOLE_COMMANDS_NORMAL() \ - CONSOLE_COMMAND("+showscores", { scoreboard_showscores = true; }) \ - CONSOLE_COMMAND("-showscores", { scoreboard_showscores = false; }) \ - CONSOLE_COMMAND("+showaccuracy", { scoreboard_showaccuracy = true; }) \ - CONSOLE_COMMAND("-showaccuracy", { scoreboard_showaccuracy = false; }) \ - /* nothing */ - -#define CONSOLE_COMMANDS_MOVEMENT() \ - CONSOLE_COMMAND("+forward", { ++camera_direction.x; }) \ - CONSOLE_COMMAND("-forward", { --camera_direction.x; }) \ - CONSOLE_COMMAND("+back", { --camera_direction.x; }) \ - CONSOLE_COMMAND("-back", { ++camera_direction.x; }) \ - CONSOLE_COMMAND("+moveup", { ++camera_direction.z; }) \ - CONSOLE_COMMAND("-moveup", { --camera_direction.z; }) \ - CONSOLE_COMMAND("+movedown", { --camera_direction.z; }) \ - CONSOLE_COMMAND("-movedown", { ++camera_direction.z; }) \ - CONSOLE_COMMAND("+moveright", { --camera_direction.y; }) \ - CONSOLE_COMMAND("-moveright", { ++camera_direction.y; }) \ - CONSOLE_COMMAND("+moveleft", { ++camera_direction.y; }) \ - CONSOLE_COMMAND("-moveleft", { --camera_direction.y; }) \ - CONSOLE_COMMAND("+roll_right", { ++camera_roll; }) \ - CONSOLE_COMMAND("-roll_right", { --camera_roll; }) \ - CONSOLE_COMMAND("+roll_left", { --camera_roll; }) \ - CONSOLE_COMMAND("-roll_left", { ++camera_roll; }) \ - /* nothing */ - -void ConsoleCommand_macro_init() -{ - // first init normal commands - #define CONSOLE_COMMAND(name,execution) \ - { registercommand(name); } - - CONSOLE_COMMANDS_NORMAL(); - #undef CONSOLE_COMMAND - - // then init movement commands - #ifndef CAMERATEST - if(isdemo()) - { - #endif - #define CONSOLE_COMMAND(name,execution) \ - { registercommand(name); } - - CONSOLE_COMMANDS_MOVEMENT(); - #undef CONSOLE_COMMAND - #ifndef CAMERATEST - } - #endif -} - -bool ConsoleCommand_macro_normal(string s, int argc) -{ - #define CONSOLE_COMMAND(name,execution) \ - { if (name == s) { { execution } return true; } } - - CONSOLE_COMMANDS_NORMAL(); - #undef CONSOLE_COMMAND - - return false; -} - -bool ConsoleCommand_macro_movement(string s, int argc) -{ - if(camera_active) - { - #define CONSOLE_COMMAND(name,execution) \ - { if (name == s) { { execution } return true; } } - - CONSOLE_COMMANDS_MOVEMENT(); - #undef CONSOLE_COMMAND - } - - return false; -} - - -// ====================================================== -// Main Function Called By Engine (registered commands) -// ====================================================== -// Used to parse commands in the console that have been registered with the "registercommand" function - -bool CSQC_ConsoleCommand(string command) -{ - int argc = tokenize_console(command); - string s = strtolower(argv(0)); - // Return value should be true if CSQC handled the command, otherwise return false to have the engine handle it. - return (ConsoleCommand_macro_normal(s, argc) - || ConsoleCommand_macro_movement(s, argc) - ); -} diff --git a/qcsrc/client/command/cl_cmd.qh b/qcsrc/client/command/cl_cmd.qh deleted file mode 100644 index da34310e3..000000000 --- a/qcsrc/client/command/cl_cmd.qh +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef CL_CMD_H -#define CL_CMD_H -// ============================================== -// CSQC client commands code, written by Samual -// Last updated: December 17th, 2011 -// ============================================== - -void Cmd_HUD_SetFields(int); -void Cmd_HUD_Help(); - -// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file -void LocalCommand_macro_write_aliases(int fh); -#endif diff --git a/qcsrc/client/commands/all.qc b/qcsrc/client/commands/all.qc new file mode 100644 index 000000000..dcace6593 --- /dev/null +++ b/qcsrc/client/commands/all.qc @@ -0,0 +1,5 @@ +#include "../_all.qh" + +#include "../../common/command/all.qc" + +#include "cl_cmd.qc" diff --git a/qcsrc/client/commands/all.qh b/qcsrc/client/commands/all.qh new file mode 100644 index 000000000..eb092c12b --- /dev/null +++ b/qcsrc/client/commands/all.qh @@ -0,0 +1,8 @@ +#ifndef CLIENT_COMMANDS_ALL_H +#define CLIENT_COMMANDS_ALL_H + +#include "../../common/commands/all.qh" + +#include "cl_cmd.qh" + +#endif diff --git a/qcsrc/client/commands/cl_cmd.qc b/qcsrc/client/commands/cl_cmd.qc new file mode 100644 index 000000000..bed70f57f --- /dev/null +++ b/qcsrc/client/commands/cl_cmd.qc @@ -0,0 +1,685 @@ +// ============================================== +// CSQC client commands code, written by Samual +// Last updated: December 28th, 2011 +// ============================================== + +#include "../../common/command/command.qh" +#include "cl_cmd.qh" + +#include "../autocvars.qh" +#include "../defs.qh" +#include "../hud.qh" +#include "../hud_config.qh" +#include "../main.qh" +#include "../mapvoting.qh" +#include "../miscfunctions.qh" + +#include "../mutators/events.qh" + +#include "../../common/mapinfo.qh" + +#include "../../common/command/generic.qh" + +void DrawDebugModel(entity this) +{ + if(time - floor(time) > 0.5) + { + PolyDrawModel(self); + self.drawmask = 0; + } + else + { + self.renderflags = 0; + self.drawmask = MASK_NORMAL; + } +} + + +// ======================= +// Command Sub-Functions +// ======================= + +void LocalCommand_blurtest(int request) +{ + // Simple command to work with postprocessing temporarily... possibly completely pointless, the glsl shader is used for a real feature now... + // Anyway, to enable it, just compile the client with -DBLURTEST and then you can use the command. + + #ifdef BLURTEST + switch(request) + { + case CMD_REQUEST_COMMAND: + { + blurtest_time0 = time; + blurtest_time1 = time + stof(argv(1)); + blurtest_radius = stof(argv(2)); + blurtest_power = stof(argv(3)); + LOG_INFO("Enabled blurtest\n"); + return; + } + + default: + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd blurtest\n"); + LOG_INFO(" No arguments required.\n"); + return; + } + } + #else + if(request) + { + LOG_INFO("Blurtest is not enabled on this client.\n"); + return; + } + #endif +} + +void LocalCommand_boxparticles(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + if (argc == 9) + { + int effect = _particleeffectnum(argv(1)); + if (effect >= 0) + { + int index = stoi(argv(2)); + entity own; + if(index <= 0) + own = entitybyindex(-index); + else + own = findfloat(world, entnum, index); + vector org_from = stov(argv(3)); + vector org_to = stov(argv(4)); + vector dir_from = stov(argv(5)); + vector dir_to = stov(argv(6)); + int countmultiplier = stoi(argv(7)); + int flags = stoi(argv(8)); + boxparticles(effect, own, org_from, org_to, dir_from, dir_to, countmultiplier, flags); + return; + } + } + } + + default: + LOG_INFO("Incorrect parameters for ^2boxparticles^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 lv_cmd boxparticles effectname own org_from org_to, dir_from, dir_to, countmultiplier, flags\n"); + LOG_INFO(" 'effectname' is the name of a particle effect in effectinfo.txt\n"); + LOG_INFO(" 'own' is the entity number of the owner (negative for csqc ent, positive for svqc ent)\n"); + LOG_INFO(" 'org_from' is the starting origin of the box\n"); + LOG_INFO(" 'org_to' is the ending origin of the box\n"); + LOG_INFO(" 'dir_from' is the minimum velocity\n"); + LOG_INFO(" 'dir_to' is the maximum velocity\n"); + LOG_INFO(" 'countmultiplier' defines a multiplier for the particle count (affects count only, not countabsolute or trailspacing)\n"); + LOG_INFO(" 'flags' can contain:\n"); + LOG_INFO(" 1 to respect globals particles_alphamin, particles_alphamax (set right before via prvm_globalset client)\n"); + LOG_INFO(" 2 to respect globals particles_colormin, particles_colormax (set right before via prvm_globalset client)\n"); + LOG_INFO(" 4 to respect globals particles_fade (set right before via prvm_globalset client)\n"); + LOG_INFO(" 128 to draw a trail, not a box\n"); + return; + } + } +} + +void LocalCommand_create_scrshot_ent(int request) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + string filename = strcat(MapInfo_Map_bspname, "_scrshot_ent.txt"); + int fh = fopen(filename, FILE_WRITE); + + if(fh >= 0) + { + fputs(fh, "{\n"); + fputs(fh, strcat("\"classname\" \"info_autoscreenshot\"\n")); + fputs(fh, strcat("\"origin\" \"", strcat(ftos(view_origin.x), " ", ftos(view_origin.y), " ", ftos(view_origin.z)), "\"\n")); + fputs(fh, strcat("\"angles\" \"", strcat(ftos(view_angles.x), " ", ftos(view_angles.y), " ", ftos(view_angles.z)), "\"\n")); + fputs(fh, "}\n"); + + LOG_INFO("Completed screenshot entity dump in ^2data/data/", MapInfo_Map_bspname, "_scrshot_ent.txt^7.\n"); + + fclose(fh); + } + else + { + LOG_INFO("^1Error: ^7Could not dump to file!\n"); + } + return; + } + + default: + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd create_scrshot_ent\n"); + LOG_INFO(" No arguments required.\n"); + return; + } + } +} + +void LocalCommand_debugmodel(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + string modelname = argv(1); + entity debugmodel_entity; + + debugmodel_entity = spawn(); + precache_model(modelname); + _setmodel(debugmodel_entity, modelname); + setorigin(debugmodel_entity, view_origin); + debugmodel_entity.angles = view_angles; + debugmodel_entity.draw = DrawDebugModel; + debugmodel_entity.classname = "debugmodel"; + + return; + } + + default: + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd debugmodel model\n"); + LOG_INFO(" Where 'model' is a string of the model name to use for the debug model.\n"); + return; + } + } +} + +void LocalCommand_handlevote(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + int vote_selection; + string vote_string; + + if(InterpretBoolean(argv(1))) + { + vote_selection = 2; + vote_string = "yes"; + } + else + { + vote_selection = 1; + vote_string = "no"; + } + + if(vote_selection) + { + if(uid2name_dialog) // handled by "uid2name" option + { + vote_active = 0; + vote_prev = 0; + vote_change = -9999; + localcmd(strcat("setreport cl_allow_uid2name ", ftos(vote_selection - 1), "\n")); + uid2name_dialog = 0; + } + else { localcmd(strcat("cmd vote ", vote_string, "\n")); } + + return; + } + } + + default: + LOG_INFO("Incorrect parameters for ^2handlevote^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd handlevote vote\n"); + LOG_INFO(" Where 'vote' is the selection for either the current poll or uid2name.\n"); + return; + } + } +} + +bool QuickMenu_IsOpened(); +void QuickMenu_Close(); +bool QuickMenu_Open(string mode, string submenu); + +bool HUD_MinigameMenu_IsOpened(); +void HUD_MinigameMenu_Close(); +void HUD_MinigameMenu_Open(); + +void HUD_Radar_Show_Maximized(bool doshow, bool clickable); + +void LocalCommand_hud(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + switch(argv(1)) + { + case "configure": + { + cvar_set("_hud_configure", ftos(!autocvar__hud_configure)); + return; + } + + case "quickmenu": + { + if(QuickMenu_IsOpened()) + QuickMenu_Close(); + else + QuickMenu_Open(argv(2), argv(3)); // mode, submenu + return; + } + + case "minigame": + { + if(HUD_MinigameMenu_IsOpened()) + HUD_MinigameMenu_Close(); + else + HUD_MinigameMenu_Open(); + return; + } + + case "save": + { + if(argv(2)) + { + HUD_Panel_ExportCfg(argv(2)); + return; + } + else + { + break; // go to usage, we're missing the paramater needed here. + } + } + + case "scoreboard_columns_set": + { + Cmd_HUD_SetFields(argc); + return; + } + + case "scoreboard_columns_help": + { + Cmd_HUD_Help(); + return; + } + + case "radar": + { + if(argv(2)) + HUD_Radar_Show_Maximized(InterpretBoolean(argv(2)),0); + else + HUD_Radar_Show_Maximized(!hud_panel_radar_maximized,0); + return; + } + + case "clickradar": + { + HUD_Radar_Show_Maximized(!hud_panel_radar_mouse,1); + return; + } + } + } + + default: + LOG_INFO("Incorrect parameters for ^2hud^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd hud action [configname | radartoggle | layout]\n"); + LOG_INFO(" Where 'action' is the command to complete,\n"); + LOG_INFO(" 'configname' is the name to save to for \"save\" action,\n"); + LOG_INFO(" 'radartoggle' is to control hud_panel_radar_maximized for \"radar\" action,\n"); + LOG_INFO(" and 'layout' is how to organize the scoreboard columns for the set action.\n"); + LOG_INFO(" quickmenu [[default | file | \"\"] submenu]\n"); + LOG_INFO(" Called without options (or with "") loads either the default quickmenu or a quickmenu file if hud_panel_quickmenu_file is set to a valid filename.\n"); + LOG_INFO(" Submenu option allows to open quickmenu directly in a submenu, it requires to specify 'default', 'file' or '\"\"' option.\n"); + LOG_INFO(" Full list of commands here: \"configure, minigame, save, scoreboard_columns_help, scoreboard_columns_set, radar.\"\n"); + return; + } + } +} + +void LocalCommand_localprint(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + if(argv(1)) + { + centerprint_hud(argv(1)); + return; + } + } + + default: + LOG_INFO("Incorrect parameters for ^2localprint^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd localprint \"message\"\n"); + LOG_INFO(" 'message' is the centerprint message to send to yourself.\n"); + return; + } + } +} + +void LocalCommand_mv_download(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + if(argv(1)) + { + Cmd_MapVote_MapDownload(argc); + return; + } + } + + default: + LOG_INFO("Incorrect parameters for ^2mv_download^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd mv_download mapid\n"); + LOG_INFO(" Where 'mapid' is the id number of the map to request an image of on the map vote selection menu.\n"); + return; + } + } +} + +void LocalCommand_find(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + entity client; + + for(client = world; (client = find(client, classname, argv(1))); ) + LOG_INFO(etos(client), "\n"); + + return; + } + + default: + LOG_INFO("Incorrect parameters for ^2find^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd find classname\n"); + LOG_INFO(" Where 'classname' is the classname to search for.\n"); + return; + } + } +} + +void LocalCommand_sendcvar(int request, int argc) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + if(argv(1)) + { + // W_FixWeaponOrder will trash argv, so save what we need. + string thiscvar = strzone(argv(1)); + string s = cvar_string(thiscvar); + + if(thiscvar == "cl_weaponpriority") + s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1); + else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18) + s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0); + + localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n"); + strunzone(thiscvar); + return; + } + } + + default: + LOG_INFO("Incorrect parameters for ^2sendcvar^7\n"); + case CMD_REQUEST_USAGE: + { + LOG_INFO("\nUsage:^3 cl_cmd sendcvar \n"); + LOG_INFO(" Where 'cvar' is the cvar plus arguments to send to the server.\n"); + return; + } + } +} + +/* use this when creating a new command, making sure to place it in alphabetical order... also, +** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION! +void LocalCommand_(int request) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + + return; + } + + default: + case CMD_REQUEST_USAGE: + { + print("\nUsage:^3 cl_cmd \n"); + print(" No arguments required.\n"); + return; + } + } +} +*/ + + +// ================================== +// Macro system for client commands +// ================================== + +// Normally do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;) +#define CLIENT_COMMANDS(request,arguments) \ + CLIENT_COMMAND("blurtest", LocalCommand_blurtest(request), "Feature for testing blur postprocessing") \ + CLIENT_COMMAND("boxparticles", LocalCommand_boxparticles(request, arguments), "Spawn particles manually") \ + CLIENT_COMMAND("create_scrshot_ent", LocalCommand_create_scrshot_ent(request), "Create an entity at this location for automatic screenshots") \ + CLIENT_COMMAND("debugmodel", LocalCommand_debugmodel(request, arguments), "Spawn a debug model manually") \ + CLIENT_COMMAND("handlevote", LocalCommand_handlevote(request, arguments), "System to handle selecting a vote or option") \ + CLIENT_COMMAND("hud", LocalCommand_hud(request, arguments), "Commands regarding/controlling the HUD system") \ + CLIENT_COMMAND("localprint", LocalCommand_localprint(request, arguments), "Create your own centerprint sent to yourself") \ + CLIENT_COMMAND("find", LocalCommand_find(request, arguments), "Search through entities for matching classname") \ + CLIENT_COMMAND("mv_download", LocalCommand_mv_download(request, arguments), "Retrieve mapshot picture from the server") \ + CLIENT_COMMAND("sendcvar", LocalCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \ + /* nothing */ + +void LocalCommand_macro_help() +{ + #define CLIENT_COMMAND(name,function,description) \ + { if(strtolower(description) != "") { LOG_INFO(" ^2", name, "^7: ", description, "\n"); } } + + CLIENT_COMMANDS(0, 0); + #undef CLIENT_COMMAND + + return; +} + +bool LocalCommand_macro_command(int argc) +{ + #define CLIENT_COMMAND(name,function,description) \ + { if(name == strtolower(argv(0))) { function; return true; } } + + CLIENT_COMMANDS(CMD_REQUEST_COMMAND, argc); + #undef CLIENT_COMMAND + + return false; +} + +bool LocalCommand_macro_usage(int argc) +{ + #define CLIENT_COMMAND(name,function,description) \ + { if(name == strtolower(argv(1))) { function; return true; } } + + CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc); + #undef CLIENT_COMMAND + + return false; +} + +void LocalCommand_macro_write_aliases(int fh) +{ + #define CLIENT_COMMAND(name,function,description) \ + { if(strtolower(description) != "") { CMD_Write_Alias("qc_cmd_cl", name, description); } } + + CLIENT_COMMANDS(0, 0); + #undef CLIENT_COMMAND + + return; +} + + +// ========================================= +// Main Function Called By Engine (cl_cmd) +// ========================================= +// If this function exists, client code handles gamecommand instead of the engine code. + +void GameCommand(string command) +{ + int argc = tokenize_console(command); + + // Guide for working with argc arguments by example: + // argc: 1 - 2 - 3 - 4 + // argv: 0 - 1 - 2 - 3 + // cmd vote - master - login - password + string s = strtolower(argv(0)); + if (s == "help") + { + if(argc == 1) + { + LOG_INFO("\nClient console commands:\n"); + LocalCommand_macro_help(); + + LOG_INFO("\nGeneric commands shared by all programs:\n"); + GenericCommand_macro_help(); + + LOG_INFO("\nUsage:^3 cl_cmd COMMAND...^7, where possible commands are listed above.\n"); + LOG_INFO("For help about a specific command, type cl_cmd help COMMAND\n"); + + return; + } + else if(GenericCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it + { + return; + } + else if(LocalCommand_macro_usage(argc)) // now try for normal commands too + { + return; + } + } + // continue as usual and scan for normal commands + if (GenericCommand(command)// handled by common/command/generic.qc + || LocalCommand_macro_command(argc) // handled by one of the above LocalCommand_* functions + || MUTATOR_CALLHOOK(CSQC_ConsoleCommand, s, argc, command) // handled by a mutator + ) return; + + // nothing above caught the command, must be invalid + LOG_INFO(((command != "") ? strcat("Unknown client command \"", command, "\"") : "No command provided"), ". For a list of supported commands, try cl_cmd help.\n"); + + return; +} + + +// =================================== +// Macro system for console commands +// =================================== + +// These functions are here specifically to add special + - commands to the game, and are not really normal commands. +// Please add client commands to the function above this, as this is only for special reasons. +#define CONSOLE_COMMANDS_NORMAL() \ + CONSOLE_COMMAND("+showscores", { scoreboard_showscores = true; }) \ + CONSOLE_COMMAND("-showscores", { scoreboard_showscores = false; }) \ + CONSOLE_COMMAND("+showaccuracy", { scoreboard_showaccuracy = true; }) \ + CONSOLE_COMMAND("-showaccuracy", { scoreboard_showaccuracy = false; }) \ + /* nothing */ + +#define CONSOLE_COMMANDS_MOVEMENT() \ + CONSOLE_COMMAND("+forward", { ++camera_direction.x; }) \ + CONSOLE_COMMAND("-forward", { --camera_direction.x; }) \ + CONSOLE_COMMAND("+back", { --camera_direction.x; }) \ + CONSOLE_COMMAND("-back", { ++camera_direction.x; }) \ + CONSOLE_COMMAND("+moveup", { ++camera_direction.z; }) \ + CONSOLE_COMMAND("-moveup", { --camera_direction.z; }) \ + CONSOLE_COMMAND("+movedown", { --camera_direction.z; }) \ + CONSOLE_COMMAND("-movedown", { ++camera_direction.z; }) \ + CONSOLE_COMMAND("+moveright", { --camera_direction.y; }) \ + CONSOLE_COMMAND("-moveright", { ++camera_direction.y; }) \ + CONSOLE_COMMAND("+moveleft", { ++camera_direction.y; }) \ + CONSOLE_COMMAND("-moveleft", { --camera_direction.y; }) \ + CONSOLE_COMMAND("+roll_right", { ++camera_roll; }) \ + CONSOLE_COMMAND("-roll_right", { --camera_roll; }) \ + CONSOLE_COMMAND("+roll_left", { --camera_roll; }) \ + CONSOLE_COMMAND("-roll_left", { ++camera_roll; }) \ + /* nothing */ + +void ConsoleCommand_macro_init() +{ + // first init normal commands + #define CONSOLE_COMMAND(name,execution) \ + { registercommand(name); } + + CONSOLE_COMMANDS_NORMAL(); + #undef CONSOLE_COMMAND + + // then init movement commands + #ifndef CAMERATEST + if(isdemo()) + { + #endif + #define CONSOLE_COMMAND(name,execution) \ + { registercommand(name); } + + CONSOLE_COMMANDS_MOVEMENT(); + #undef CONSOLE_COMMAND + #ifndef CAMERATEST + } + #endif +} + +bool ConsoleCommand_macro_normal(string s, int argc) +{ + #define CONSOLE_COMMAND(name,execution) \ + { if (name == s) { { execution } return true; } } + + CONSOLE_COMMANDS_NORMAL(); + #undef CONSOLE_COMMAND + + return false; +} + +bool ConsoleCommand_macro_movement(string s, int argc) +{ + if(camera_active) + { + #define CONSOLE_COMMAND(name,execution) \ + { if (name == s) { { execution } return true; } } + + CONSOLE_COMMANDS_MOVEMENT(); + #undef CONSOLE_COMMAND + } + + return false; +} + + +// ====================================================== +// Main Function Called By Engine (registered commands) +// ====================================================== +// Used to parse commands in the console that have been registered with the "registercommand" function + +bool CSQC_ConsoleCommand(string command) +{ + int argc = tokenize_console(command); + string s = strtolower(argv(0)); + // Return value should be true if CSQC handled the command, otherwise return false to have the engine handle it. + return (ConsoleCommand_macro_normal(s, argc) + || ConsoleCommand_macro_movement(s, argc) + ); +} diff --git a/qcsrc/client/commands/cl_cmd.qh b/qcsrc/client/commands/cl_cmd.qh new file mode 100644 index 000000000..ba3151c43 --- /dev/null +++ b/qcsrc/client/commands/cl_cmd.qh @@ -0,0 +1,13 @@ +#ifndef CLIENT_COMMANDS_CL_CMD_H +#define CLIENT_COMMANDS_CL_CMD_H +// ============================================== +// CSQC client commands code, written by Samual +// Last updated: December 17th, 2011 +// ============================================== + +void Cmd_HUD_SetFields(int); +void Cmd_HUD_Help(); + +// used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file +void LocalCommand_macro_write_aliases(int fh); +#endif diff --git a/qcsrc/client/controlpoint.qc b/qcsrc/client/controlpoint.qc index 34301d806..575bce513 100644 --- a/qcsrc/client/controlpoint.qc +++ b/qcsrc/client/controlpoint.qc @@ -1,8 +1,9 @@ #include "controlpoint.qh" -#include "gibs.qh" + #include "teamradar.qh" #include "../common/movetypes/movetypes.qh" +.vector colormod; .float alpha; .int count; .float pain_finished; diff --git a/qcsrc/client/controlpoint.qh b/qcsrc/client/controlpoint.qh index 31485519d..5f2e89b4d 100644 --- a/qcsrc/client/controlpoint.qh +++ b/qcsrc/client/controlpoint.qh @@ -1,5 +1,5 @@ -#ifndef CONTROLPOINT_H -#define CONTROLPOINT_H +#ifndef CLIENT_CONTROLPOINT_H +#define CLIENT_CONTROLPOINT_H const vector CPICON_MIN = '-32 -32 -9'; const vector CPICON_MAX = '32 32 25'; diff --git a/qcsrc/client/csqc_constants.qh b/qcsrc/client/csqc_constants.qh index 09d217bc2..1df447283 100644 --- a/qcsrc/client/csqc_constants.qh +++ b/qcsrc/client/csqc_constants.qh @@ -1,5 +1,5 @@ -#ifndef CSQC_CONSTANTS -#define CSQC_CONSTANTS +#ifndef CLIENT_CSQC_CONSTANTS +#define CLIENT_CSQC_CONSTANTS // MenuQC redefines world, change define it here to be safe #define world world diff --git a/qcsrc/client/csqcmodel_hooks.qc b/qcsrc/client/csqcmodel_hooks.qc index 8d1f7e76f..708e305fa 100644 --- a/qcsrc/client/csqcmodel_hooks.qc +++ b/qcsrc/client/csqcmodel_hooks.qc @@ -1,24 +1,13 @@ -#include "_all.qh" - -#include "gibs.qh" +#include "mutators/events.qh" #include "player_skeleton.qh" - #include "weapons/projectile.qh" - #include "../common/animdecide.qh" -#include "../common/csqcmodel_settings.qh" -#include "../common/effects/effects.qh" -#include "../common/teams.qh" -#include "../common/triggers/trigger/viewloc.qh" +#include "../common/movetypes/movetypes.qh" #include "../common/viewloc.qh" - -#include "mutators/events.qh" - #include "../csqcmodellib/cl_model.qh" #include "../csqcmodellib/cl_player.qh" #include "../csqcmodellib/interpolate.qh" - .float death_time; .int modelflags; diff --git a/qcsrc/client/damage.qc b/qcsrc/client/damage.qc index 7ef7f996b..48612ba48 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/client/damage.qc @@ -1,16 +1,9 @@ #include "damage.qh" -#include "_all.qh" #include "gibs.qh" - -#include "../common/vehicles/all.qh" - -#include "../common/constants.qh" #include "../common/deathtypes.qh" -#include "../common/effects/effects.qh" #include "../common/movetypes/movetypes.qh" -#include "../common/util.qh" - +#include "../common/vehicles/all.qh" #include "../common/weapons/all.qh" .entity tag_entity; diff --git a/qcsrc/client/damage.qh b/qcsrc/client/damage.qh index 0de69a02d..3f11b9a49 100644 --- a/qcsrc/client/damage.qh +++ b/qcsrc/client/damage.qh @@ -1,5 +1,5 @@ -#ifndef DAMAGE_H -#define DAMAGE_H +#ifndef CLIENT_DAMAGE_H +#define CLIENT_DAMAGE_H .float total_damages; // number of effects which currently are attached to a player diff --git a/qcsrc/client/effects.qc b/qcsrc/client/effects.qc index c0c378fd1..21fa1ce03 100644 --- a/qcsrc/client/effects.qc +++ b/qcsrc/client/effects.qc @@ -1,5 +1,4 @@ #include "effects.qh" -#include "_all.qh" /* .vector fx_start; diff --git a/qcsrc/client/effects.qh b/qcsrc/client/effects.qh index 0bebdb95d..2d93f41d7 100644 --- a/qcsrc/client/effects.qh +++ b/qcsrc/client/effects.qh @@ -1,5 +1,5 @@ -#ifndef EFFECTS_H -#define EFFECTS_H +#ifndef CLIENT_EFFECTS_H +#define CLIENT_EFFECTS_H void Net_ReadArc(); diff --git a/qcsrc/client/generator.qc b/qcsrc/client/generator.qc index eed682785..d7114d1bf 100644 --- a/qcsrc/client/generator.qc +++ b/qcsrc/client/generator.qc @@ -1,5 +1,10 @@ #include "generator.qh" +#include "teamradar.qh" +#include "../common/movetypes/movetypes.qh" + +.float alpha; +.float scale; .int count; .float max_health; diff --git a/qcsrc/client/generator.qh b/qcsrc/client/generator.qh index 744bc5589..c60aff400 100644 --- a/qcsrc/client/generator.qh +++ b/qcsrc/client/generator.qh @@ -1,5 +1,5 @@ -#ifndef GENERATOR_H -#define GENERATOR_H +#ifndef CLIENT_GENERATOR_H +#define CLIENT_GENERATOR_H const vector GENERATOR_MIN = '-52 -52 -14'; const vector GENERATOR_MAX = '52 52 75'; diff --git a/qcsrc/client/gibs.qc b/qcsrc/client/gibs.qc index 360f7b5c3..4afa5eb88 100644 --- a/qcsrc/client/gibs.qc +++ b/qcsrc/client/gibs.qc @@ -1,11 +1,7 @@ #include "gibs.qh" -#include "_all.qh" #include "rubble.qh" - -#include "../common/constants.qh" #include "../common/movetypes/movetypes.qh" -#include "../common/util.qh" .float scale; .float alpha; diff --git a/qcsrc/client/gibs.qh b/qcsrc/client/gibs.qh index f4b60948a..eb63aa1fe 100644 --- a/qcsrc/client/gibs.qh +++ b/qcsrc/client/gibs.qh @@ -1,5 +1,5 @@ -#ifndef GIBS_H -#define GIBS_H +#ifndef CLIENT_GIBS_H +#define CLIENT_GIBS_H .vector colormod; diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index 07123f06b..6143874e6 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -1,12 +1,6 @@ #include "hook.qh" -#include "_all.qh" - -#include "hud.qh" - -#include "../common/teams.qh" #include "../csqcmodellib/interpolate.qh" - #include "../warpzonelib/common.qh" entityclass(Hook); diff --git a/qcsrc/client/hook.qh b/qcsrc/client/hook.qh index e513ed6af..9e6ee548c 100644 --- a/qcsrc/client/hook.qh +++ b/qcsrc/client/hook.qh @@ -1,5 +1,5 @@ -#ifndef HOOK_H -#define HOOK_H +#ifndef CLIENT_HOOK_H +#define CLIENT_HOOK_H void Draw_CylindricLine(vector from, vector to, float thickness, string texture, float aspect, float shift, vector rgb, float theAlpha, float drawflag, vector vieworg); diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 81fa57552..4e83ac31e 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1,25 +1,19 @@ #include "hud.qh" -#include "_all.qh" #include "hud_config.qh" #include "mapvoting.qh" #include "scoreboard.qh" #include "teamradar.qh" #include "t_items.qh" - #include "../common/buffs/all.qh" -#include "../common/constants.qh" #include "../common/deathtypes.qh" #include "../common/items/all.qc" #include "../common/mapinfo.qh" -#include "../common/nades/all.qh" - #include "../common/mutators/mutator/waypoints/all.qh" -#include "../server/mutators/gamemode_ctf.qh" - +#include "../common/nades/all.qh" #include "../common/stats.qh" - #include "../csqcmodellib/cl_player.qh" +#include "../server/mutators/gamemode_ctf.qh" /* @@ -204,12 +198,6 @@ HUD panels ================== */ -// draw the background/borders -#define HUD_Panel_DrawBg(theAlpha) do { \ - if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \ - draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\ -} while(0) - //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag) { diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index 224b3fbe0..517fd8c07 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -1,8 +1,11 @@ -#ifndef HUD_H -#define HUD_H +#ifndef CLIENT_HUD_H +#define CLIENT_HUD_H #include "../common/weapons/all.qh" +bool HUD_Radar_Clickable(); +void HUD_Radar_Mouse(); + REGISTRY(hud_panels, 24) REGISTER_REGISTRY(Registerhud_panels) @@ -17,6 +20,12 @@ REGISTER_REGISTRY(Registerhud_panels) #define HUD_PANEL(NAME) HUD_PANEL_##NAME +// draw the background/borders +#define HUD_Panel_DrawBg(theAlpha) do { \ + if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \ + draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\ +} while(0) + int panel_order[hud_panels_MAX]; string hud_panelorder_prev; @@ -28,6 +37,7 @@ bool hud_panel_radar_temp_hidden; bool chat_panel_modified; bool radar_panel_modified; +float HUD_Radar_InputEvent(float bInputType, float nPrimary, float nSecondary); void HUD_Radar_Hide_Maximized(); void HUD_Reset (void); diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 55c6c061e..148c0ec8e 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -1,11 +1,7 @@ #include "hud_config.qh" -#include "_all.qh" #include "hud.qh" -#include "../common/constants.qh" - - #define HUD_Write(s) fputs(fh, s) // q: quoted, n: not quoted #define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n")) diff --git a/qcsrc/client/hud_config.qh b/qcsrc/client/hud_config.qh index bac199750..05792286d 100644 --- a/qcsrc/client/hud_config.qh +++ b/qcsrc/client/hud_config.qh @@ -1,5 +1,5 @@ -#ifndef HUD_CONFIG_H -#define HUD_CONFIG_H +#ifndef CLIENT_HUD_CONFIG_H +#define CLIENT_HUD_CONFIG_H const int S_MOUSE1 = 1; const int S_MOUSE2 = 2; diff --git a/qcsrc/client/laser.qc b/qcsrc/client/laser.qc index 93c4103a9..4d52c8eee 100644 --- a/qcsrc/client/laser.qc +++ b/qcsrc/client/laser.qc @@ -1,11 +1,5 @@ #include "laser.qh" -#include "_all.qh" -#include "hook.qh" - -#include "../common/buffs/all.qh" - -#include "../csqcmodellib/cl_model.qh" #include "../csqcmodellib/interpolate.qh" // a laser goes from origin in direction angles diff --git a/qcsrc/client/laser.qh b/qcsrc/client/laser.qh index 86210eee1..32c6cd81e 100644 --- a/qcsrc/client/laser.qh +++ b/qcsrc/client/laser.qh @@ -1,5 +1,5 @@ -#ifndef LASER_H -#define LASER_H +#ifndef CLIENT_LASER_H +#define CLIENT_LASER_H void Ent_Laser(); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index ff9fe0f7f..8571d43a3 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1,5 +1,4 @@ #include "main.qh" -#include "_all.qh" #include "controlpoint.qh" #include "damage.qh" @@ -12,43 +11,26 @@ #include "laser.qh" #include "mapvoting.qh" #include "modeleffects.qh" +#include "mutators/events.qh" #include "particles.qh" +#include "quickmenu.qh" #include "scoreboard.qh" #include "shownames.qh" #include "tuba.qh" #include "t_items.qh" #include "wall.qh" - -#include "../common/vehicles/all.qh" - -#include "mutators/events.qh" - #include "weapons/projectile.qh" - -#include "../common/buffs/all.qh" #include "../common/deathtypes.qh" -#include "../common/effects/effects.qh" +#include "../common/items/all.qh" #include "../common/mapinfo.qh" -#include "../common/monsters/all.qh" -#include "../common/nades/all.qh" +#include "../common/minigames/cl_minigames.qh" +#include "../common/minigames/cl_minigames_hud.qh" #include "../common/net_notice.qh" -#include "../common/notifications.qh" -#include "../common/stats.qh" -#include "../common/teams.qh" - -#include "../common/items/all.qh" - -#include "../common/mutators/base.qh" - -#include "../common/weapons/all.qh" - -#include "../csqcmodellib/cl_model.qh" -#include "../csqcmodellib/interpolate.qh" - #include "../common/triggers/include.qh" - #include "../common/turrets/cl_turrets.qh" - +#include "../common/vehicles/all.qh" +#include "../csqcmodellib/cl_model.qh" +#include "../csqcmodellib/interpolate.qh" #include "../warpzonelib/client.qh" // -------------------------------------------------------------------------- @@ -148,7 +130,6 @@ void CSQC_Init(void) // needs to be done so early because of the constants they create static_init(); - CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); // precaches diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index d403984d3..acd0bcb1e 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -1,5 +1,5 @@ -#ifndef MAIN_H -#define MAIN_H +#ifndef CLIENT_MAIN_H +#define CLIENT_MAIN_H #include "../common/constants.qh" diff --git a/qcsrc/client/mapvoting.qc b/qcsrc/client/mapvoting.qc index 010f424f1..21bb421a9 100644 --- a/qcsrc/client/mapvoting.qc +++ b/qcsrc/client/mapvoting.qc @@ -1,11 +1,9 @@ #include "mapvoting.qh" -#include "_all.qh" #include "hud.qh" #include "scoreboard.qh" #include "../common/mapinfo.qh" -#include "../common/util.qh" int mv_num_maps; diff --git a/qcsrc/client/mapvoting.qh b/qcsrc/client/mapvoting.qh index 7a9a511a2..c1c27ad5b 100644 --- a/qcsrc/client/mapvoting.qh +++ b/qcsrc/client/mapvoting.qh @@ -1,5 +1,5 @@ -#ifndef MAPVOTING_H -#define MAPVOTING_H +#ifndef CLIENT_MAPVOTING_H +#define CLIENT_MAPVOTING_H #include "../common/constants.qh" void MapVote_Draw(); diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 9bf0a855f..8a5b70704 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -1,12 +1,10 @@ #include "miscfunctions.qh" -#include "_all.qh" #include "hud.qh" #include "../common/command/generic.qh" #include "../common/teams.qh" -#include "../common/util.qh" #include "../csqcmodellib/cl_model.qh" diff --git a/qcsrc/client/miscfunctions.qh b/qcsrc/client/miscfunctions.qh index 9ac46340d..b223d88b9 100644 --- a/qcsrc/client/miscfunctions.qh +++ b/qcsrc/client/miscfunctions.qh @@ -1,5 +1,5 @@ -#ifndef MISCFUNCTIONS_H -#define MISCFUNCTIONS_H +#ifndef CLIENT_MISCFUNCTIONS_H +#define CLIENT_MISCFUNCTIONS_H entity players; entity teams; diff --git a/qcsrc/client/modeleffects.qc b/qcsrc/client/modeleffects.qc index a10062a9f..d870d81e9 100644 --- a/qcsrc/client/modeleffects.qc +++ b/qcsrc/client/modeleffects.qc @@ -1,5 +1,4 @@ #include "modeleffects.qh" -#include "_all.qh" .float cnt; .float scale; diff --git a/qcsrc/client/modeleffects.qh b/qcsrc/client/modeleffects.qh index d4b98e0a5..32641f394 100644 --- a/qcsrc/client/modeleffects.qh +++ b/qcsrc/client/modeleffects.qh @@ -1,5 +1,5 @@ -#ifndef MODELEFFECTS_H -#define MODELEFFECTS_H +#ifndef CLIENT_MODELEFFECTS_H +#define CLIENT_MODELEFFECTS_H entityclass(ModelEffect); class(ModelEffect) .float frame1time; diff --git a/qcsrc/client/particles.qc b/qcsrc/client/particles.qc index 6d73e24b0..75f293feb 100644 --- a/qcsrc/client/particles.qc +++ b/qcsrc/client/particles.qc @@ -1,8 +1,6 @@ #include "particles.qh" -#include "_all.qh" #include "../common/stats.qh" -#include "../common/util.qh" #include "../warpzonelib/common.qh" diff --git a/qcsrc/client/particles.qh b/qcsrc/client/particles.qh index 06cd72523..3735641af 100644 --- a/qcsrc/client/particles.qh +++ b/qcsrc/client/particles.qh @@ -1,5 +1,5 @@ -#ifndef PARTICLES_H -#define PARTICLES_H +#ifndef CLIENT_PARTICLES_H +#define CLIENT_PARTICLES_H .int dphitcontentsmask; entityclass(PointParticles); diff --git a/qcsrc/client/player_skeleton.qc b/qcsrc/client/player_skeleton.qc index 584a19780..cdb1fdf74 100644 --- a/qcsrc/client/player_skeleton.qc +++ b/qcsrc/client/player_skeleton.qc @@ -1,9 +1,11 @@ #include "player_skeleton.qh" -#include "../common/csqcmodel_settings.qh" - +#include "mutators/events.qh" +#include "../csqcmodellib/cl_player.qh" #include "../warpzonelib/anglestransform.qh" +.vector v_angle; + class(Skeleton) .float skeleton_info_modelindex; class(Skeleton) .float skeleton_info_skin; const int BONETYPE_LOWER = 0; diff --git a/qcsrc/client/player_skeleton.qh b/qcsrc/client/player_skeleton.qh index 4a37df5e4..48a3111d3 100644 --- a/qcsrc/client/player_skeleton.qh +++ b/qcsrc/client/player_skeleton.qh @@ -1,7 +1,5 @@ -#ifndef PLAYER_SKELETON -#define PLAYER_SKELETON - -#include "../common/util.qh" +#ifndef CLIENT_PLAYER_SKELETON +#define CLIENT_PLAYER_SKELETON void free_skeleton_from_frames(entity e); void skeleton_from_frames(entity e, float is_dead); diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index e1e96ef13..367e5ffd5 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -1,4 +1,5 @@ #include "../lib/_all.inc" +#include "_all.qh" #include "announcer.qc" #include "bgmscript.qc" @@ -27,12 +28,11 @@ #include "view.qc" #include "wall.qc" -#include "command/all.qc" +#include "commands/all.qc" #include "weapons/projectile.qc" // TODO #include "../common/animdecide.qc" -#include "../common/effects/effects.qc" #include "../common/effects/effectinfo.qc" #include "../common/mapinfo.qc" #include "../common/movetypes/include.qc" @@ -48,6 +48,7 @@ #include "../common/minigames/cl_minigames.qc" #include "../common/buffs/all.qc" +#include "../common/effects/all.qc" #include "../common/items/all.qc" #include "../common/monsters/all.qc" #include "../common/mutators/all.qc" diff --git a/qcsrc/client/quickmenu.qc b/qcsrc/client/quickmenu.qc index dd2ba0315..1f7be0c50 100644 --- a/qcsrc/client/quickmenu.qc +++ b/qcsrc/client/quickmenu.qc @@ -1,6 +1,8 @@ -#include "_all.qh" +#include "quickmenu.qh" +#include "hud.qh" #include "hud_config.qh" +#include "mapvoting.qh" // QUICKMENU_MAXLINES must be <= 10 const int QUICKMENU_MAXLINES = 10; diff --git a/qcsrc/client/quickmenu.qh b/qcsrc/client/quickmenu.qh new file mode 100644 index 000000000..cf5f66649 --- /dev/null +++ b/qcsrc/client/quickmenu.qh @@ -0,0 +1,8 @@ +#ifndef CLIENT_QUICKMENU_H +#define CLIENT_QUICKMENU_H + +bool QuickMenu_InputEvent(float bInputType, float nPrimary, float nSecondary); +bool QuickMenu_IsOpened(); +void QuickMenu_Mouse(); + +#endif diff --git a/qcsrc/client/rubble.qh b/qcsrc/client/rubble.qh index b19406c77..944116802 100644 --- a/qcsrc/client/rubble.qh +++ b/qcsrc/client/rubble.qh @@ -1,5 +1,5 @@ -#ifndef RUBBLE_H -#define RUBBLE_H +#ifndef CLIENT_RUBBLE_H +#define CLIENT_RUBBLE_H entityclass(Rubble); class(Rubble) .float creationtime; void RubbleLimit(string cname, float limit, void() deleteproc); diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index a1d9a50dc..adbac93c8 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -1,6 +1,6 @@ #include "scoreboard.qh" -#include "_all.qh" +#include "quickmenu.qh" #include "hud.qh" #include "../common/constants.qh" @@ -8,7 +8,6 @@ #include "../common/minigames/cl_minigames.qh" #include "../common/stats.qh" #include "../common/teams.qh" -#include "../common/util.qh" float scoreboard_alpha_bg; float scoreboard_alpha_fg; diff --git a/qcsrc/client/scoreboard.qh b/qcsrc/client/scoreboard.qh index e1c5addb4..5b5f812a0 100644 --- a/qcsrc/client/scoreboard.qh +++ b/qcsrc/client/scoreboard.qh @@ -1,5 +1,5 @@ -#ifndef SCOREBOARD_H -#define SCOREBOARD_H +#ifndef CLIENT_SCOREBOARD_H +#define CLIENT_SCOREBOARD_H float xmin, xmax, ymin, ymax, sbwidth; diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index fc4649537..994a1ae30 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -1,12 +1,10 @@ #include "shownames.qh" -#include "_all.qh" #include "hud.qh" #include "../common/constants.qh" #include "../common/mapinfo.qh" #include "../common/teams.qh" -#include "../common/util.qh" #include "../csqcmodellib/cl_model.qh" diff --git a/qcsrc/client/shownames.qh b/qcsrc/client/shownames.qh index 63fd92e04..1304c5370 100644 --- a/qcsrc/client/shownames.qh +++ b/qcsrc/client/shownames.qh @@ -1,5 +1,5 @@ -#ifndef SHOWNAMES_H -#define SHOWNAMES_H +#ifndef CLIENT_SHOWNAMES_H +#define CLIENT_SHOWNAMES_H entityclass(ShowNames); class(ShowNames) .float healthvalue; diff --git a/qcsrc/client/t_items.qc b/qcsrc/client/t_items.qc index 4e43a9662..9bb99f41d 100644 --- a/qcsrc/client/t_items.qc +++ b/qcsrc/client/t_items.qc @@ -1,8 +1,6 @@ -#include "_all.qh" #include "../common/buffs/all.qh" #include "../common/movetypes/movetypes.qh" -#include "../common/util.qh" #include "../common/weapons/all.qh" #include "../csqcmodellib/cl_model.qh" #include "../csqcmodellib/common.qh" diff --git a/qcsrc/client/teamradar.qc b/qcsrc/client/teamradar.qc index 7623e9df8..d429d2005 100644 --- a/qcsrc/client/teamradar.qc +++ b/qcsrc/client/teamradar.qc @@ -1,9 +1,8 @@ #include "teamradar.qh" -#include "_all.qh" #include "hud.qh" -#include "../common/util.qh" +#include "../common/mutators/mutator/waypoints/all.qh" #include "../csqcmodellib/interpolate.qh" diff --git a/qcsrc/client/teamradar.qh b/qcsrc/client/teamradar.qh index 78ef5ee71..b882f39fb 100644 --- a/qcsrc/client/teamradar.qh +++ b/qcsrc/client/teamradar.qh @@ -1,5 +1,5 @@ -#ifndef TEAMRADAR_H -#define TEAMRADAR_H +#ifndef CLIENT_TEAMRADAR_H +#define CLIENT_TEAMRADAR_H const int MAX_TEAMRADAR_TIMES = 32; diff --git a/qcsrc/client/tuba.qc b/qcsrc/client/tuba.qc index 91ccbba5c..ed2964936 100644 --- a/qcsrc/client/tuba.qc +++ b/qcsrc/client/tuba.qc @@ -1,8 +1,6 @@ #include "tuba.qh" -#include "_all.qh" #include "../common/constants.qh" -#include "../common/util.qh" #define TUBA_STARTNOTE(i, n) W_Sound(strcat("tuba", (i ? ftos(i) : ""), "_loopnote", ftos(n))) diff --git a/qcsrc/client/tuba.qh b/qcsrc/client/tuba.qh index 6fe103f70..e936dcd6e 100644 --- a/qcsrc/client/tuba.qh +++ b/qcsrc/client/tuba.qh @@ -1,5 +1,5 @@ -#ifndef TUBA_H -#define TUBA_H +#ifndef CLIENT_TUBA_H +#define CLIENT_TUBA_H void Ent_TubaNote(bool isNew); void Tuba_Precache(); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 3bb5585f3..6fcc79b24 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1,4 +1,3 @@ -#include "_all.qh" #include "announcer.qh" #include "hook.qh" @@ -7,6 +6,7 @@ #include "mapvoting.qh" #include "scoreboard.qh" #include "shownames.qh" +#include "quickmenu.qh" #include "mutators/events.qh" @@ -16,9 +16,12 @@ #include "../common/stats.qh" #include "../common/triggers/target/music.qh" #include "../common/teams.qh" -#include "../common/util.qh" +#include "../common/vehicles/all.qh" #include "../common/weapons/all.qh" +#include "../common/viewloc.qh" +#include "../common/minigames/cl_minigames.qh" +#include "../common/minigames/cl_minigames_hud.qh" #include "../csqcmodellib/cl_player.qh" diff --git a/qcsrc/client/wall.qc b/qcsrc/client/wall.qc index f17b54a5c..b97f757a7 100644 --- a/qcsrc/client/wall.qc +++ b/qcsrc/client/wall.qc @@ -1,9 +1,7 @@ #include "wall.qh" -#include "_all.qh" #include "bgmscript.qh" -#include "../common/util.qh" #include "../csqcmodellib/interpolate.qh" diff --git a/qcsrc/client/wall.qh b/qcsrc/client/wall.qh index f44355fc2..e05bb615e 100644 --- a/qcsrc/client/wall.qh +++ b/qcsrc/client/wall.qh @@ -1,5 +1,5 @@ -#ifndef WALL_H -#define WALL_H +#ifndef CLIENT_WALL_H +#define CLIENT_WALL_H entityclass(Wall); class(Wall) .float lip; diff --git a/qcsrc/client/weapons/projectile.qc b/qcsrc/client/weapons/projectile.qc index 22443043d..b52a3fac1 100644 --- a/qcsrc/client/weapons/projectile.qc +++ b/qcsrc/client/weapons/projectile.qc @@ -3,11 +3,11 @@ #include "../autocvars.qh" #include "../defs.qh" #include "../main.qh" +#include "../mutators/events.qh" #include "../../common/constants.qh" #include "../../common/nades/all.qh" #include "../../common/movetypes/movetypes.qh" -#include "../../common/util.qh" #include "../../csqcmodellib/interpolate.qh" diff --git a/qcsrc/client/weapons/projectile.qh b/qcsrc/client/weapons/projectile.qh index dd289817e..5a0deb499 100644 --- a/qcsrc/client/weapons/projectile.qh +++ b/qcsrc/client/weapons/projectile.qh @@ -1,5 +1,5 @@ -#ifndef PROJECTILE_H -#define PROJECTILE_H +#ifndef CLIENT_WEAPONS_PROJECTILE_H +#define CLIENT_WEAPONS_PROJECTILE_H entityclass(Projectile); class(Projectile) .int traileffect; diff --git a/qcsrc/common/animdecide.qc b/qcsrc/common/animdecide.qc index e2bda23a0..23f43b9e9 100644 --- a/qcsrc/common/animdecide.qc +++ b/qcsrc/common/animdecide.qc @@ -1,4 +1,7 @@ #include "animdecide.qh" + +#include "monsters/all.qh" + #if defined(SVQC) #include "util.qh" #include "../server/defs.qh" diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index 6649950dd..5412c22b4 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -10,7 +10,7 @@ #endif #ifdef CSQC - #include "../../client/command/cl_cmd.qh" + #include "../../client/commands/cl_cmd.qh" #endif #ifdef SVQC diff --git a/qcsrc/common/effects/all.inc b/qcsrc/common/effects/all.inc new file mode 100644 index 000000000..d53ded907 --- /dev/null +++ b/qcsrc/common/effects/all.inc @@ -0,0 +1,295 @@ +// Global list of effects, networked to CSQC by ID to save bandwidth and to use client particle numbers (allows mismatching effectinfos to some degree) +// Not too concerned about the order of this list, just keep the weapon effects together! + +#include "../teams.qh" + +// EFFECT(istrail, EFFECT_NAME, "effectinfo_string") +EFFECT(0, EXPLOSION_SMALL, "explosion_small") +EFFECT(0, EXPLOSION_MEDIUM, "explosion_medium") +EFFECT(0, EXPLOSION_BIG, "explosion_big") + +EFFECT(0, SMOKE_SMALL, "smoke_small") +EFFECT(0, SMOKE_LARGE, "smoke_large") + + + +EFFECT(0, BLASTER_IMPACT, "laser_impact") +EFFECT(0, BLASTER_MUZZLEFLASH, "laser_muzzleflash") + +EFFECT(0, SHOTGUN_IMPACT, "shotgun_impact") +EFFECT(0, SHOTGUN_MUZZLEFLASH, "shotgun_muzzleflash") + +EFFECT(0, ARC_BEAM, "arc_beam") +EFFECT(0, ARC_BEAM_HEAL, "arc_beam_heal") +EFFECT(0, ARC_BEAM_HEAL_IMPACT, "arc_beam_healimpact") +EFFECT(0, ARC_BEAM_HEAL_IMPACT2, "healray_impact") +EFFECT(0, ARC_LIGHTNING, "arc_lightning") +EFFECT(0, ARC_LIGHTNING2, "electro_lightning") + +EFFECT(0, MACHINEGUN_IMPACT, "machinegun_impact") +EFFECT(0, MACHINEGUN_MUZZLEFLASH, "uzi_muzzleflash") + +EFFECT(0, GRENADE_EXPLODE, "grenade_explode") +EFFECT(0, GRENADE_MUZZLEFLASH, "grenadelauncher_muzzleflash") + +EFFECT(0, ELECTRO_BALLEXPLODE, "electro_ballexplode") +EFFECT(0, ELECTRO_COMBO, "electro_combo") +EFFECT(0, ELECTRO_IMPACT, "electro_impact") +EFFECT(0, ELECTRO_MUZZLEFLASH, "electro_muzzleflash") + +EFFECT(0, CRYLINK_IMPACT, "crylink_impactbig") +EFFECT(0, CRYLINK_IMPACT2, "crylink_impact") +EFFECT(0, CRYLINK_JOINEXPLODE, "crylink_joinexplode") +EFFECT(0, CRYLINK_MUZZLEFLASH, "crylink_muzzleflash") + +EFFECT(0, VORTEX_BEAM, "nex_beam") +EFFECT(0, VORTEX_BEAM_OLD, "TE_TEI_G3") +EFFECT(0, VORTEX_IMPACT, "nex_impact") +EFFECT(0, VORTEX_MUZZLEFLASH, "nex_muzzleflash") + +EFFECT(1, VAPORIZER_RED, "TE_TEI_G3RED") +EFFECT(1, VAPORIZER_HIT_RED, "TE_TEI_G3RED_HIT") +EFFECT(1, VAPORIZER_BLUE, "TE_TEI_G3BLUE") +EFFECT(1, VAPORIZER_HIT_BLUE, "TE_TEI_G3BLUE_HIT") +EFFECT(1, VAPORIZER_YELLOW, "TE_TEI_G3YELLOW") +EFFECT(1, VAPORIZER_HIT_YELLOW, "TE_TEI_G3YELLOW_HIT") +EFFECT(1, VAPORIZER_PINK, "TE_TEI_G3PINK") +EFFECT(1, VAPORIZER_HIT_PINK, "TE_TEI_G3PINK_HIT") +EFFECT(1, VAPORIZER_NEUTRAL, "TE_TEI_G3") +EFFECT(1, VAPORIZER_HIT_NEUTRAL, "TE_TEI_G3_HIT") +entity EFFECT_VAPORIZER(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_VAPORIZER_RED; + case NUM_TEAM_2: return EFFECT_VAPORIZER_BLUE; + case NUM_TEAM_3: return EFFECT_VAPORIZER_YELLOW; + case NUM_TEAM_4: return EFFECT_VAPORIZER_PINK; + default: return EFFECT_VAPORIZER_NEUTRAL; + } +} +entity EFFECT_VAPORIZER_HIT(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_VAPORIZER_HIT_RED; + case NUM_TEAM_2: return EFFECT_VAPORIZER_HIT_BLUE; + case NUM_TEAM_3: return EFFECT_VAPORIZER_HIT_YELLOW; + case NUM_TEAM_4: return EFFECT_VAPORIZER_HIT_PINK; + default: return EFFECT_VAPORIZER_HIT_NEUTRAL; + } +} + +EFFECT(0, RIFLE_IMPACT, "machinegun_impact") +EFFECT(0, RIFLE_MUZZLEFLASH, "rifle_muzzleflash") +EFFECT(1, RIFLE, "tr_rifle") +EFFECT(1, RIFLE_WEAK, "tr_rifle_weak") + +EFFECT(0, HAGAR_BOUNCE, "hagar_bounce") +EFFECT(0, HAGAR_EXPLODE, "hagar_explode") +EFFECT(0, HAGAR_MUZZLEFLASH, "hagar_muzzleflash") +EFFECT(1, HAGAR_ROCKET, "tr_hagar") + +EFFECT(0, ROCKET_EXPLODE, "rocket_explode") +EFFECT(0, ROCKET_GUIDE, "rocket_guide") +EFFECT(0, ROCKET_MUZZLEFLASH, "rocketlauncher_muzzleflash") + +EFFECT(0, HOOK_EXPLODE, "hookbomb_explode") +EFFECT(0, HOOK_IMPACT, "grapple_impact") +EFFECT(0, HOOK_MUZZLEFLASH, "grapple_muzzleflash") + +EFFECT(0, SEEKER_MUZZLEFLASH, "seeker_muzzleflash") + +EFFECT(0, FLAK_BOUNCE, "flak_bounce") + +EFFECT(1, FIREBALL, "fireball") +EFFECT(0, FIREBALL_BFGDAMAGE, "fireball_bfgdamage") +EFFECT(0, FIREBALL_EXPLODE, "fireball_explode") +EFFECT(0, FIREBALL_LASER, "fireball_laser") +EFFECT(0, FIREBALL_MUZZLEFLASH, "fireball_muzzleflash") +EFFECT(0, FIREBALL_PRE_MUZZLEFLASH, "fireball_preattack_muzzleflash") + + + +EFFECT(0, RAPTOR_CANNON_IMPACT, "raptor_cannon_impact") +EFFECT(0, RAPTOR_BOMB_IMPACT, "raptor_bomb_impact") +EFFECT(0, RAPTOR_BOMB_SPREAD, "raptor_bomb_spread") +EFFECT(0, RAPTOR_MUZZLEFLASH, "raptor_cannon_muzzleflash") + +EFFECT(0, RACER_BOOSTER, "wakizashi_booster_smoke") +EFFECT(0, RACER_IMPACT, "wakizashi_gun_impact") +EFFECT(0, RACER_MUZZLEFLASH, "wakizashi_gun_muzzleflash") +EFFECT(0, RACER_ROCKETLAUNCH, "wakizashi_rocket_launch") +EFFECT(0, RACER_ROCKET_EXPLODE, "wakizashi_rocket_launch") +EFFECT(1, RACER_ROCKET_TRAIL, "wakizashi_rocket_thrust") + +EFFECT(0, SPIDERBOT_ROCKETLAUNCH, "spiderbot_rocket_launch") +EFFECT(1, SPIDERBOT_ROCKET_TRAIL, "spiderbot_rocket_thrust") +EFFECT(0, SPIDERBOT_ROCKET_EXPLODE, "spiderbot_rocket_explode") +EFFECT(0, SPIDERBOT_MINIGUN_IMPACT, "spiderbot_minigun_impact") +EFFECT(0, SPIDERBOT_MINIGUN_MUZZLEFLASH, "spiderbot_minigun_muzzleflash") + +EFFECT(0, BUMBLEBEE_HEAL_MUZZLEFLASH, "healray_muzzleflash") +EFFECT(0, BUMBLEBEE_HEAL_IMPACT, "healray_impact") + +EFFECT(0, BIGPLASMA_IMPACT, "bigplasma_impact") +EFFECT(0, BIGPLASMA_MUZZLEFLASH, "bigplasma_muzzleflash") + +EFFECT(0, TELEPORT, "teleport") + +EFFECT(0, SPAWNPOINT_RED, "spawn_point_red") +EFFECT(0, SPAWN_RED, "spawn_event_red") +EFFECT(0, SPAWNPOINT_BLUE, "spawn_point_blue") +EFFECT(0, SPAWN_BLUE, "spawn_event_blue") +EFFECT(0, SPAWNPOINT_YELLOW, "spawn_point_yellow") +EFFECT(0, SPAWN_YELLOW, "spawn_event_yellow") +EFFECT(0, SPAWNPOINT_PINK, "spawn_point_pink") +EFFECT(0, SPAWN_PINK, "spawn_event_pink") +EFFECT(0, SPAWNPOINT_NEUTRAL, "spawn_point_neutral") +EFFECT(0, SPAWN_NEUTRAL, "spawn_event_neutral") + +EFFECT(0, NADE_EXPLODE_RED, "nade_red_explode") +EFFECT(0, NADE_EXPLODE_BLUE, "nade_blue_explode") +EFFECT(0, NADE_EXPLODE_YELLOW, "nade_yellow_explode") +EFFECT(0, NADE_EXPLODE_PINK, "nade_pink_explode") +EFFECT(0, NADE_EXPLODE_NEUTRAL, "nade_neutral_explode") +entity EFFECT_NADE_EXPLODE(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_NADE_EXPLODE_RED; + case NUM_TEAM_2: return EFFECT_NADE_EXPLODE_BLUE; + case NUM_TEAM_3: return EFFECT_NADE_EXPLODE_YELLOW; + case NUM_TEAM_4: return EFFECT_NADE_EXPLODE_PINK; + default: return EFFECT_NADE_EXPLODE_NEUTRAL; + } +} + +EFFECT(1, NADE_TRAIL_RED, "nade_red") +EFFECT(1, NADE_TRAIL_BLUE, "nade_blue") +EFFECT(1, NADE_TRAIL_YELLOW, "nade_yellow") +EFFECT(1, NADE_TRAIL_PINK, "nade_pink") +EFFECT(1, NADE_TRAIL_NEUTRAL, "nade_neutral") +entity EFFECT_NADE_TRAIL(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_NADE_TRAIL_RED; + case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BLUE; + case NUM_TEAM_3: return EFFECT_NADE_TRAIL_YELLOW; + case NUM_TEAM_4: return EFFECT_NADE_TRAIL_PINK; + default: return EFFECT_NADE_TRAIL_NEUTRAL; + } +} + +EFFECT(1, NADE_TRAIL_BURN_RED, "nade_red_burn") +EFFECT(1, NADE_TRAIL_BURN_BLUE, "nade_blue_burn") +EFFECT(1, NADE_TRAIL_BURN_YELLOW, "nade_yellow_burn") +EFFECT(1, NADE_TRAIL_BURN_PINK, "nade_pink_burn") +EFFECT(1, NADE_TRAIL_BURN_NEUTRAL, "nade_neutral_burn") +entity EFFECT_NADE_TRAIL_BURN(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_NADE_TRAIL_BURN_RED; + case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BURN_BLUE; + case NUM_TEAM_3: return EFFECT_NADE_TRAIL_BURN_YELLOW; + case NUM_TEAM_4: return EFFECT_NADE_TRAIL_BURN_PINK; + default: return EFFECT_NADE_TRAIL_BURN_NEUTRAL; + } +} + +EFFECT(0, ICEORGLASS, "iceorglass") +EFFECT(0, ICEFIELD, "icefield") +EFFECT(0, FIREFIELD, "firefield") +EFFECT(0, HEALING, "healing_fx") +EFFECT(1, LASER_BEAM_FAST, "nex242_misc_laser_beam_fast") +EFFECT(0, RESPAWN_GHOST, "respawn_ghost") + +EFFECT(0, FLAG_TOUCH_RED, "redflag_touch") +EFFECT(0, FLAG_TOUCH_BLUE, "blueflag_touch") +EFFECT(0, FLAG_TOUCH_YELLOW, "yellowflag_touch") +EFFECT(0, FLAG_TOUCH_PINK, "pinkflag_touch") +EFFECT(0, FLAG_TOUCH_NEUTRAL, "neutralflag_touch") +entity EFFECT_FLAG_TOUCH(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_FLAG_TOUCH_RED; + case NUM_TEAM_2: return EFFECT_FLAG_TOUCH_BLUE; + case NUM_TEAM_3: return EFFECT_FLAG_TOUCH_YELLOW; + case NUM_TEAM_4: return EFFECT_FLAG_TOUCH_PINK; + default: return EFFECT_FLAG_TOUCH_NEUTRAL; + } +} + +EFFECT(1, PASS_RED, "red_pass") +EFFECT(1, PASS_BLUE, "blue_pass") +EFFECT(1, PASS_YELLOW, "yellow_pass") +EFFECT(1, PASS_PINK, "pink_pass") +EFFECT(1, PASS_NEUTRAL, "neutral_pass") + +EFFECT(0, CAP_RED, "red_cap") +EFFECT(0, CAP_BLUE, "blue_cap") +EFFECT(0, CAP_YELLOW, "yellow_cap") +EFFECT(0, CAP_PINK, "pink_cap") +EFFECT(0, CAP_NEUTRAL, "neutral_cap") +entity EFFECT_CAP(int teamid) +{ + switch (teamid) { + case NUM_TEAM_1: return EFFECT_CAP_RED; + case NUM_TEAM_2: return EFFECT_CAP_BLUE; + case NUM_TEAM_3: return EFFECT_CAP_YELLOW; + case NUM_TEAM_4: return EFFECT_CAP_PINK; + default: return EFFECT_CAP_NEUTRAL; + } +} + +EFFECT(0, ITEM_PICKUP, "item_pickup") +EFFECT(0, ITEM_RESPAWN, "item_respawn") + +EFFECT(0, ONS_GENERATOR_DAMAGED, "torch_small") +EFFECT(0, ONS_GENERATOR_GIB, "onslaught_generator_gib_explode") +EFFECT(0, ONS_GENERATOR_EXPLODE, "onslaught_generator_smallexplosion") +EFFECT(0, ONS_GENERATOR_EXPLODE2, "onslaught_generator_finalexplosion") + + + +EFFECT(0, LASER_DEADLY, "laser_deadly") +EFFECT(1, FLAC_TRAIL, "TR_SEEKER") +EFFECT(1, SEEKER_TRAIL, "TR_SEEKER") +EFFECT(1, FIREMINE, "firemine") +EFFECT(0, BALL_SPARKS, "kaball_sparks") +EFFECT(0, ELECTRIC_SPARKS, "electricity_sparks") +EFFECT(0, SPARKS, "sparks") +EFFECT(0, RAGE, "rage") +EFFECT(0, SMOKING, "smoking") +EFFECT(0, SMOKE_RING, "smoke_ring") +EFFECT(0, JUMPPAD, "jumppad_activate") +EFFECT(1, BULLET, "tr_bullet") +EFFECT(0, EF_FLAME, "EF_FLAME") +EFFECT(0, EF_STARDUST, "EF_STARDUST") +EFFECT(0, TE_EXPLOSION, "TE_EXPLOSION") +EFFECT(1, TR_NEXUIZPLASMA, "TR_NEXUIZPLASMA") +EFFECT(1, TR_CRYLINKPLASMA, "TR_CRYLINKPLASMA") +EFFECT(1, TR_ROCKET, "TR_ROCKET") +EFFECT(1, TR_GRENADE, "TR_GRENADE") +EFFECT(1, TR_BLOOD, "TR_BLOOD") +EFFECT(1, TR_WIZSPIKE, "TR_WIZSPIKE") +EFFECT(1, TR_SLIGHTBLOOD, "TR_SLIGHTBLOOD") +EFFECT(1, TR_KNIGHTSPIKE, "TR_KNIGHTSPIKE") +EFFECT(1, TR_VORESPIKE, "TR_VORESPIKE") +EFFECT(0, TE_SPARK, "TE_SPARK") + +EFFECT(1, ROCKETMINSTA_LASER_RED, "rocketminsta_laser_red") +EFFECT(1, ROCKETMINSTA_LASER_BLUE, "rocketminsta_laser_blue") +EFFECT(1, ROCKETMINSTA_LASER_YELLOW, "rocketminsta_laser_yellow") +EFFECT(1, ROCKETMINSTA_LASER_PINK, "rocketminsta_laser_pink") +EFFECT(1, ROCKETMINSTA_LASER_NEUTRAL, "rocketminsta_laser_neutral") +entity EFFECT_ROCKETMINSTA_LASER(int teamid) +{ + entity e; + switch (teamid) { + case NUM_TEAM_1: e = EFFECT_ROCKETMINSTA_LASER_RED; break; + case NUM_TEAM_2: e = EFFECT_ROCKETMINSTA_LASER_BLUE; break; + case NUM_TEAM_3: e = EFFECT_ROCKETMINSTA_LASER_YELLOW; break; + case NUM_TEAM_4: e = EFFECT_ROCKETMINSTA_LASER_PINK; break; + default: e = EFFECT_ROCKETMINSTA_LASER_NEUTRAL; break; + } + if (particleeffectnum(e) < 0 || Team_TeamToNumber(teamid) == -1) { e = EFFECT_TR_NEXUIZPLASMA; } + return e; +} diff --git a/qcsrc/common/effects/all.qc b/qcsrc/common/effects/all.qc new file mode 100644 index 000000000..e90f3c615 --- /dev/null +++ b/qcsrc/common/effects/all.qc @@ -0,0 +1,93 @@ +#include "all.qh" + +#ifdef CSQC +void Read_Effect(bool is_new) +{ + int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte(); + + entity eff = Effects[net_name]; + + vector v, vel = '0 0 0'; + int eff_cnt = 1; + bool eff_trail = eff.eent_eff_trail; + v_x = ReadCoord(); + v_y = ReadCoord(); + v_z = ReadCoord(); + + bool use_vel = ReadByte(); + if(use_vel) + { + vel_x = ReadCoord(); + vel_y = ReadCoord(); + vel_z = ReadCoord(); + } + + if(!eff_trail) + eff_cnt = ReadByte(); + + if(is_new) + { + if(eff_trail) + WarpZone_TrailParticles(world, particleeffectnum(eff), v, vel); + else + pointparticles(particleeffectnum(eff), v, vel, eff_cnt); + } +} +#endif + +#ifdef SVQC +bool Net_Write_Effect(entity this, entity client, int sf) +{ + WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT); + (Effects_COUNT >= 255) + ? WriteShort(MSG_ENTITY, self.m_id) + : WriteByte(MSG_ENTITY, self.m_id); + WriteCoord(MSG_ENTITY, self.eent_net_location_x); + WriteCoord(MSG_ENTITY, self.eent_net_location_y); + WriteCoord(MSG_ENTITY, self.eent_net_location_z); + + // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set + if(self.eent_net_velocity) + { + WriteByte(MSG_ENTITY, true); + WriteCoord(MSG_ENTITY, self.eent_net_velocity_x); + WriteCoord(MSG_ENTITY, self.eent_net_velocity_y); + WriteCoord(MSG_ENTITY, self.eent_net_velocity_z); + } + else { WriteByte(MSG_ENTITY, false); } + + if(!self.eent_eff_trail) { WriteByte(MSG_ENTITY, self.eent_net_count); } + return true; +} + +void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt) +{ + if(!eff) { return; } + if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count! + entity net_eff = spawn(); + net_eff.owner = eff; + net_eff.classname = "net_effect"; + //net_eff.eent_broadcast = broadcast; + net_eff.m_id = eff.m_id; + net_eff.eent_net_velocity = eff_vel; + net_eff.eent_net_location = eff_loc; + net_eff.eent_net_count = eff_cnt; + net_eff.eent_eff_trail = eff.eent_eff_trail; + + net_eff.think = SUB_Remove; + net_eff.nextthink = time + 0.2; // don't need to keep this long + + Net_LinkEntity(net_eff, false, 0, Net_Write_Effect); +} + +void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt) +{ + // problem with this is, we might not have all the available effects for it + FOREACH(Effects, it.eent_eff_name == eff_name, LAMBDA( + Send_Effect(it, eff_loc, eff_vel, eff_cnt); + return; + )); + // revert to engine handling + pointparticles(_particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt); +} +#endif diff --git a/qcsrc/common/effects/all.qh b/qcsrc/common/effects/all.qh new file mode 100644 index 000000000..7046af11b --- /dev/null +++ b/qcsrc/common/effects/all.qh @@ -0,0 +1,41 @@ +#ifndef EFFECTS_ALL_H +#define EFFECTS_ALL_H + +#include "effect.qh" + +#ifdef CSQC +void Read_Effect(bool is_new); +#elif defined(SVQC) +void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt); +void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt); +#endif + +REGISTRY(Effects, BIT(8)) +REGISTER_REGISTRY(RegisterEffects) +#define EFFECT(istrail, name, realname) \ + REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail)); + +void RegisterEffects_First() +{ + #ifdef SVQC + #define dedi (server_is_dedicated ? "a dedicated " : "") + #else + #define dedi "" + #endif + + LOG_TRACEF("Beginning effect initialization on %s%s program...\n", dedi, PROGNAME); + #undef dedi +} + +void RegisterEffects_Done() +{ + LOG_TRACE("Effects initialization successful!\n"); +} + +// NOW we actually activate the declarations +ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_First) +EFFECT(0, Null, string_null) +#include "all.inc" +ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_Done) + +#endif diff --git a/qcsrc/common/effects/effect.qh b/qcsrc/common/effects/effect.qh new file mode 100644 index 000000000..bd9cd99e5 --- /dev/null +++ b/qcsrc/common/effects/effect.qh @@ -0,0 +1,22 @@ +#ifndef EFFECT_H +#define EFFECT_H + +#define particleeffectnum(e) _particleeffectnum(e.eent_eff_name) + +.int m_id; +.string eent_eff_name; +.int eent_eff_trail; + +.vector eent_net_location; +.vector eent_net_velocity; +.int eent_net_count; + +entity Create_Effect_Entity(string eff_name, bool eff_trail) +{ + entity this = new(effect_entity); + this.eent_eff_name = eff_name; + this.eent_eff_trail = eff_trail; + return this; +} + +#endif diff --git a/qcsrc/common/effects/effects.inc b/qcsrc/common/effects/effects.inc deleted file mode 100644 index 4d82087e0..000000000 --- a/qcsrc/common/effects/effects.inc +++ /dev/null @@ -1,293 +0,0 @@ -// Global list of effects, networked to CSQC by ID to save bandwidth and to use client particle numbers (allows mismatching effectinfos to some degree) -// Not too concerned about the order of this list, just keep the weapon effects together! - -// EFFECT(istrail, EFFECT_NAME, "effectinfo_string") -EFFECT(0, EXPLOSION_SMALL, "explosion_small") -EFFECT(0, EXPLOSION_MEDIUM, "explosion_medium") -EFFECT(0, EXPLOSION_BIG, "explosion_big") - -EFFECT(0, SMOKE_SMALL, "smoke_small") -EFFECT(0, SMOKE_LARGE, "smoke_large") - - - -EFFECT(0, BLASTER_IMPACT, "laser_impact") -EFFECT(0, BLASTER_MUZZLEFLASH, "laser_muzzleflash") - -EFFECT(0, SHOTGUN_IMPACT, "shotgun_impact") -EFFECT(0, SHOTGUN_MUZZLEFLASH, "shotgun_muzzleflash") - -EFFECT(0, ARC_BEAM, "arc_beam") -EFFECT(0, ARC_BEAM_HEAL, "arc_beam_heal") -EFFECT(0, ARC_BEAM_HEAL_IMPACT, "arc_beam_healimpact") -EFFECT(0, ARC_BEAM_HEAL_IMPACT2, "healray_impact") -EFFECT(0, ARC_LIGHTNING, "arc_lightning") -EFFECT(0, ARC_LIGHTNING2, "electro_lightning") - -EFFECT(0, MACHINEGUN_IMPACT, "machinegun_impact") -EFFECT(0, MACHINEGUN_MUZZLEFLASH, "uzi_muzzleflash") - -EFFECT(0, GRENADE_EXPLODE, "grenade_explode") -EFFECT(0, GRENADE_MUZZLEFLASH, "grenadelauncher_muzzleflash") - -EFFECT(0, ELECTRO_BALLEXPLODE, "electro_ballexplode") -EFFECT(0, ELECTRO_COMBO, "electro_combo") -EFFECT(0, ELECTRO_IMPACT, "electro_impact") -EFFECT(0, ELECTRO_MUZZLEFLASH, "electro_muzzleflash") - -EFFECT(0, CRYLINK_IMPACT, "crylink_impactbig") -EFFECT(0, CRYLINK_IMPACT2, "crylink_impact") -EFFECT(0, CRYLINK_JOINEXPLODE, "crylink_joinexplode") -EFFECT(0, CRYLINK_MUZZLEFLASH, "crylink_muzzleflash") - -EFFECT(0, VORTEX_BEAM, "nex_beam") -EFFECT(0, VORTEX_BEAM_OLD, "TE_TEI_G3") -EFFECT(0, VORTEX_IMPACT, "nex_impact") -EFFECT(0, VORTEX_MUZZLEFLASH, "nex_muzzleflash") - -EFFECT(1, VAPORIZER_RED, "TE_TEI_G3RED") -EFFECT(1, VAPORIZER_HIT_RED, "TE_TEI_G3RED_HIT") -EFFECT(1, VAPORIZER_BLUE, "TE_TEI_G3BLUE") -EFFECT(1, VAPORIZER_HIT_BLUE, "TE_TEI_G3BLUE_HIT") -EFFECT(1, VAPORIZER_YELLOW, "TE_TEI_G3YELLOW") -EFFECT(1, VAPORIZER_HIT_YELLOW, "TE_TEI_G3YELLOW_HIT") -EFFECT(1, VAPORIZER_PINK, "TE_TEI_G3PINK") -EFFECT(1, VAPORIZER_HIT_PINK, "TE_TEI_G3PINK_HIT") -EFFECT(1, VAPORIZER_NEUTRAL, "TE_TEI_G3") -EFFECT(1, VAPORIZER_HIT_NEUTRAL, "TE_TEI_G3_HIT") -entity EFFECT_VAPORIZER(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_VAPORIZER_RED; - case NUM_TEAM_2: return EFFECT_VAPORIZER_BLUE; - case NUM_TEAM_3: return EFFECT_VAPORIZER_YELLOW; - case NUM_TEAM_4: return EFFECT_VAPORIZER_PINK; - default: return EFFECT_VAPORIZER_NEUTRAL; - } -} -entity EFFECT_VAPORIZER_HIT(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_VAPORIZER_HIT_RED; - case NUM_TEAM_2: return EFFECT_VAPORIZER_HIT_BLUE; - case NUM_TEAM_3: return EFFECT_VAPORIZER_HIT_YELLOW; - case NUM_TEAM_4: return EFFECT_VAPORIZER_HIT_PINK; - default: return EFFECT_VAPORIZER_HIT_NEUTRAL; - } -} - -EFFECT(0, RIFLE_IMPACT, "machinegun_impact") -EFFECT(0, RIFLE_MUZZLEFLASH, "rifle_muzzleflash") -EFFECT(1, RIFLE, "tr_rifle") -EFFECT(1, RIFLE_WEAK, "tr_rifle_weak") - -EFFECT(0, HAGAR_BOUNCE, "hagar_bounce") -EFFECT(0, HAGAR_EXPLODE, "hagar_explode") -EFFECT(0, HAGAR_MUZZLEFLASH, "hagar_muzzleflash") -EFFECT(1, HAGAR_ROCKET, "tr_hagar") - -EFFECT(0, ROCKET_EXPLODE, "rocket_explode") -EFFECT(0, ROCKET_GUIDE, "rocket_guide") -EFFECT(0, ROCKET_MUZZLEFLASH, "rocketlauncher_muzzleflash") - -EFFECT(0, HOOK_EXPLODE, "hookbomb_explode") -EFFECT(0, HOOK_IMPACT, "grapple_impact") -EFFECT(0, HOOK_MUZZLEFLASH, "grapple_muzzleflash") - -EFFECT(0, SEEKER_MUZZLEFLASH, "seeker_muzzleflash") - -EFFECT(0, FLAK_BOUNCE, "flak_bounce") - -EFFECT(1, FIREBALL, "fireball") -EFFECT(0, FIREBALL_BFGDAMAGE, "fireball_bfgdamage") -EFFECT(0, FIREBALL_EXPLODE, "fireball_explode") -EFFECT(0, FIREBALL_LASER, "fireball_laser") -EFFECT(0, FIREBALL_MUZZLEFLASH, "fireball_muzzleflash") -EFFECT(0, FIREBALL_PRE_MUZZLEFLASH, "fireball_preattack_muzzleflash") - - - -EFFECT(0, RAPTOR_CANNON_IMPACT, "raptor_cannon_impact") -EFFECT(0, RAPTOR_BOMB_IMPACT, "raptor_bomb_impact") -EFFECT(0, RAPTOR_BOMB_SPREAD, "raptor_bomb_spread") -EFFECT(0, RAPTOR_MUZZLEFLASH, "raptor_cannon_muzzleflash") - -EFFECT(0, RACER_BOOSTER, "wakizashi_booster_smoke") -EFFECT(0, RACER_IMPACT, "wakizashi_gun_impact") -EFFECT(0, RACER_MUZZLEFLASH, "wakizashi_gun_muzzleflash") -EFFECT(0, RACER_ROCKETLAUNCH, "wakizashi_rocket_launch") -EFFECT(0, RACER_ROCKET_EXPLODE, "wakizashi_rocket_launch") -EFFECT(1, RACER_ROCKET_TRAIL, "wakizashi_rocket_thrust") - -EFFECT(0, SPIDERBOT_ROCKETLAUNCH, "spiderbot_rocket_launch") -EFFECT(1, SPIDERBOT_ROCKET_TRAIL, "spiderbot_rocket_thrust") -EFFECT(0, SPIDERBOT_ROCKET_EXPLODE, "spiderbot_rocket_explode") -EFFECT(0, SPIDERBOT_MINIGUN_IMPACT, "spiderbot_minigun_impact") -EFFECT(0, SPIDERBOT_MINIGUN_MUZZLEFLASH, "spiderbot_minigun_muzzleflash") - -EFFECT(0, BUMBLEBEE_HEAL_MUZZLEFLASH, "healray_muzzleflash") -EFFECT(0, BUMBLEBEE_HEAL_IMPACT, "healray_impact") - -EFFECT(0, BIGPLASMA_IMPACT, "bigplasma_impact") -EFFECT(0, BIGPLASMA_MUZZLEFLASH, "bigplasma_muzzleflash") - -EFFECT(0, TELEPORT, "teleport") - -EFFECT(0, SPAWNPOINT_RED, "spawn_point_red") -EFFECT(0, SPAWN_RED, "spawn_event_red") -EFFECT(0, SPAWNPOINT_BLUE, "spawn_point_blue") -EFFECT(0, SPAWN_BLUE, "spawn_event_blue") -EFFECT(0, SPAWNPOINT_YELLOW, "spawn_point_yellow") -EFFECT(0, SPAWN_YELLOW, "spawn_event_yellow") -EFFECT(0, SPAWNPOINT_PINK, "spawn_point_pink") -EFFECT(0, SPAWN_PINK, "spawn_event_pink") -EFFECT(0, SPAWNPOINT_NEUTRAL, "spawn_point_neutral") -EFFECT(0, SPAWN_NEUTRAL, "spawn_event_neutral") - -EFFECT(0, NADE_EXPLODE_RED, "nade_red_explode") -EFFECT(0, NADE_EXPLODE_BLUE, "nade_blue_explode") -EFFECT(0, NADE_EXPLODE_YELLOW, "nade_yellow_explode") -EFFECT(0, NADE_EXPLODE_PINK, "nade_pink_explode") -EFFECT(0, NADE_EXPLODE_NEUTRAL, "nade_neutral_explode") -entity EFFECT_NADE_EXPLODE(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_NADE_EXPLODE_RED; - case NUM_TEAM_2: return EFFECT_NADE_EXPLODE_BLUE; - case NUM_TEAM_3: return EFFECT_NADE_EXPLODE_YELLOW; - case NUM_TEAM_4: return EFFECT_NADE_EXPLODE_PINK; - default: return EFFECT_NADE_EXPLODE_NEUTRAL; - } -} - -EFFECT(1, NADE_TRAIL_RED, "nade_red") -EFFECT(1, NADE_TRAIL_BLUE, "nade_blue") -EFFECT(1, NADE_TRAIL_YELLOW, "nade_yellow") -EFFECT(1, NADE_TRAIL_PINK, "nade_pink") -EFFECT(1, NADE_TRAIL_NEUTRAL, "nade_neutral") -entity EFFECT_NADE_TRAIL(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_NADE_TRAIL_RED; - case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BLUE; - case NUM_TEAM_3: return EFFECT_NADE_TRAIL_YELLOW; - case NUM_TEAM_4: return EFFECT_NADE_TRAIL_PINK; - default: return EFFECT_NADE_TRAIL_NEUTRAL; - } -} - -EFFECT(1, NADE_TRAIL_BURN_RED, "nade_red_burn") -EFFECT(1, NADE_TRAIL_BURN_BLUE, "nade_blue_burn") -EFFECT(1, NADE_TRAIL_BURN_YELLOW, "nade_yellow_burn") -EFFECT(1, NADE_TRAIL_BURN_PINK, "nade_pink_burn") -EFFECT(1, NADE_TRAIL_BURN_NEUTRAL, "nade_neutral_burn") -entity EFFECT_NADE_TRAIL_BURN(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_NADE_TRAIL_BURN_RED; - case NUM_TEAM_2: return EFFECT_NADE_TRAIL_BURN_BLUE; - case NUM_TEAM_3: return EFFECT_NADE_TRAIL_BURN_YELLOW; - case NUM_TEAM_4: return EFFECT_NADE_TRAIL_BURN_PINK; - default: return EFFECT_NADE_TRAIL_BURN_NEUTRAL; - } -} - -EFFECT(0, ICEORGLASS, "iceorglass") -EFFECT(0, ICEFIELD, "icefield") -EFFECT(0, FIREFIELD, "firefield") -EFFECT(0, HEALING, "healing_fx") -EFFECT(1, LASER_BEAM_FAST, "nex242_misc_laser_beam_fast") -EFFECT(0, RESPAWN_GHOST, "respawn_ghost") - -EFFECT(0, FLAG_TOUCH_RED, "redflag_touch") -EFFECT(0, FLAG_TOUCH_BLUE, "blueflag_touch") -EFFECT(0, FLAG_TOUCH_YELLOW, "yellowflag_touch") -EFFECT(0, FLAG_TOUCH_PINK, "pinkflag_touch") -EFFECT(0, FLAG_TOUCH_NEUTRAL, "neutralflag_touch") -entity EFFECT_FLAG_TOUCH(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_FLAG_TOUCH_RED; - case NUM_TEAM_2: return EFFECT_FLAG_TOUCH_BLUE; - case NUM_TEAM_3: return EFFECT_FLAG_TOUCH_YELLOW; - case NUM_TEAM_4: return EFFECT_FLAG_TOUCH_PINK; - default: return EFFECT_FLAG_TOUCH_NEUTRAL; - } -} - -EFFECT(1, PASS_RED, "red_pass") -EFFECT(1, PASS_BLUE, "blue_pass") -EFFECT(1, PASS_YELLOW, "yellow_pass") -EFFECT(1, PASS_PINK, "pink_pass") -EFFECT(1, PASS_NEUTRAL, "neutral_pass") - -EFFECT(0, CAP_RED, "red_cap") -EFFECT(0, CAP_BLUE, "blue_cap") -EFFECT(0, CAP_YELLOW, "yellow_cap") -EFFECT(0, CAP_PINK, "pink_cap") -EFFECT(0, CAP_NEUTRAL, "neutral_cap") -entity EFFECT_CAP(int teamid) -{ - switch (teamid) { - case NUM_TEAM_1: return EFFECT_CAP_RED; - case NUM_TEAM_2: return EFFECT_CAP_BLUE; - case NUM_TEAM_3: return EFFECT_CAP_YELLOW; - case NUM_TEAM_4: return EFFECT_CAP_PINK; - default: return EFFECT_CAP_NEUTRAL; - } -} - -EFFECT(0, ITEM_PICKUP, "item_pickup") -EFFECT(0, ITEM_RESPAWN, "item_respawn") - -EFFECT(0, ONS_GENERATOR_DAMAGED, "torch_small") -EFFECT(0, ONS_GENERATOR_GIB, "onslaught_generator_gib_explode") -EFFECT(0, ONS_GENERATOR_EXPLODE, "onslaught_generator_smallexplosion") -EFFECT(0, ONS_GENERATOR_EXPLODE2, "onslaught_generator_finalexplosion") - - - -EFFECT(0, LASER_DEADLY, "laser_deadly") -EFFECT(1, FLAC_TRAIL, "TR_SEEKER") -EFFECT(1, SEEKER_TRAIL, "TR_SEEKER") -EFFECT(1, FIREMINE, "firemine") -EFFECT(0, BALL_SPARKS, "kaball_sparks") -EFFECT(0, ELECTRIC_SPARKS, "electricity_sparks") -EFFECT(0, SPARKS, "sparks") -EFFECT(0, RAGE, "rage") -EFFECT(0, SMOKING, "smoking") -EFFECT(0, SMOKE_RING, "smoke_ring") -EFFECT(0, JUMPPAD, "jumppad_activate") -EFFECT(1, BULLET, "tr_bullet") -EFFECT(0, EF_FLAME, "EF_FLAME") -EFFECT(0, EF_STARDUST, "EF_STARDUST") -EFFECT(0, TE_EXPLOSION, "TE_EXPLOSION") -EFFECT(1, TR_NEXUIZPLASMA, "TR_NEXUIZPLASMA") -EFFECT(1, TR_CRYLINKPLASMA, "TR_CRYLINKPLASMA") -EFFECT(1, TR_ROCKET, "TR_ROCKET") -EFFECT(1, TR_GRENADE, "TR_GRENADE") -EFFECT(1, TR_BLOOD, "TR_BLOOD") -EFFECT(1, TR_WIZSPIKE, "TR_WIZSPIKE") -EFFECT(1, TR_SLIGHTBLOOD, "TR_SLIGHTBLOOD") -EFFECT(1, TR_KNIGHTSPIKE, "TR_KNIGHTSPIKE") -EFFECT(1, TR_VORESPIKE, "TR_VORESPIKE") -EFFECT(0, TE_SPARK, "TE_SPARK") - -EFFECT(1, ROCKETMINSTA_LASER_RED, "rocketminsta_laser_red") -EFFECT(1, ROCKETMINSTA_LASER_BLUE, "rocketminsta_laser_blue") -EFFECT(1, ROCKETMINSTA_LASER_YELLOW, "rocketminsta_laser_yellow") -EFFECT(1, ROCKETMINSTA_LASER_PINK, "rocketminsta_laser_pink") -EFFECT(1, ROCKETMINSTA_LASER_NEUTRAL, "rocketminsta_laser_neutral") -entity EFFECT_ROCKETMINSTA_LASER(int teamid) -{ - entity e; - switch (teamid) { - case NUM_TEAM_1: e = EFFECT_ROCKETMINSTA_LASER_RED; break; - case NUM_TEAM_2: e = EFFECT_ROCKETMINSTA_LASER_BLUE; break; - case NUM_TEAM_3: e = EFFECT_ROCKETMINSTA_LASER_YELLOW; break; - case NUM_TEAM_4: e = EFFECT_ROCKETMINSTA_LASER_PINK; break; - default: e = EFFECT_ROCKETMINSTA_LASER_NEUTRAL; break; - } - if (particleeffectnum(e) < 0 || Team_TeamToNumber(teamid) == -1) { e = EFFECT_TR_NEXUIZPLASMA; } - return e; -} diff --git a/qcsrc/common/effects/effects.qc b/qcsrc/common/effects/effects.qc deleted file mode 100644 index 78bb6755a..000000000 --- a/qcsrc/common/effects/effects.qc +++ /dev/null @@ -1,91 +0,0 @@ -#ifdef CSQC -void Read_Effect(bool is_new) -{ - int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte(); - - entity eff = Effects[net_name]; - - vector v, vel = '0 0 0'; - int eff_cnt = 1; - bool eff_trail = eff.eent_eff_trail; - v_x = ReadCoord(); - v_y = ReadCoord(); - v_z = ReadCoord(); - - bool use_vel = ReadByte(); - if(use_vel) - { - vel_x = ReadCoord(); - vel_y = ReadCoord(); - vel_z = ReadCoord(); - } - - if(!eff_trail) - eff_cnt = ReadByte(); - - if(is_new) - { - if(eff_trail) - WarpZone_TrailParticles(world, particleeffectnum(eff), v, vel); - else - pointparticles(particleeffectnum(eff), v, vel, eff_cnt); - } -} -#endif - -#ifdef SVQC -bool Net_Write_Effect(entity this, entity client, int sf) -{ - WriteByte(MSG_ENTITY, ENT_CLIENT_EFFECT); - (Effects_COUNT >= 255) - ? WriteShort(MSG_ENTITY, self.m_id) - : WriteByte(MSG_ENTITY, self.m_id); - WriteCoord(MSG_ENTITY, self.eent_net_location_x); - WriteCoord(MSG_ENTITY, self.eent_net_location_y); - WriteCoord(MSG_ENTITY, self.eent_net_location_z); - - // attempt to save a tiny bit more bandwidth by not sending velocity if it isn't set - if(self.eent_net_velocity) - { - WriteByte(MSG_ENTITY, true); - WriteCoord(MSG_ENTITY, self.eent_net_velocity_x); - WriteCoord(MSG_ENTITY, self.eent_net_velocity_y); - WriteCoord(MSG_ENTITY, self.eent_net_velocity_z); - } - else { WriteByte(MSG_ENTITY, false); } - - if(!self.eent_eff_trail) { WriteByte(MSG_ENTITY, self.eent_net_count); } - return true; -} - -void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt) -{ - if(!eff) { return; } - if(!eff.eent_eff_trail && !eff_cnt) { return; } // effect has no count! - entity net_eff = spawn(); - net_eff.owner = eff; - net_eff.classname = "net_effect"; - //net_eff.eent_broadcast = broadcast; - net_eff.m_id = eff.m_id; - net_eff.eent_net_velocity = eff_vel; - net_eff.eent_net_location = eff_loc; - net_eff.eent_net_count = eff_cnt; - net_eff.eent_eff_trail = eff.eent_eff_trail; - - net_eff.think = SUB_Remove; - net_eff.nextthink = time + 0.2; // don't need to keep this long - - Net_LinkEntity(net_eff, false, 0, Net_Write_Effect); -} - -void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt) -{ - // problem with this is, we might not have all the available effects for it - FOREACH(Effects, it.eent_eff_name == eff_name, LAMBDA( - Send_Effect(it, eff_loc, eff_vel, eff_cnt); - return; - )); - // revert to engine handling - pointparticles(_particleeffectnum(eff_name), eff_loc, eff_vel, eff_cnt); -} -#endif diff --git a/qcsrc/common/effects/effects.qh b/qcsrc/common/effects/effects.qh deleted file mode 100644 index 21821758c..000000000 --- a/qcsrc/common/effects/effects.qh +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef P_EFFECTS_H -#define P_EFFECTS_H - -#ifdef CSQC -void Read_Effect(bool is_new); -#elif defined(SVQC) -void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt); -void Send_Effect_(string eff_name, vector eff_loc, vector eff_vel, int eff_cnt); -#endif - -#define particleeffectnum(e) _particleeffectnum(e.eent_eff_name) - -REGISTRY(Effects, BIT(8)) -REGISTER_REGISTRY(RegisterEffects) -#define EFFECT(istrail, name, realname) \ - REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail)); - -.int m_id; -.string eent_eff_name; -.int eent_eff_trail; - -.vector eent_net_location; -.vector eent_net_velocity; -.int eent_net_count; - -entity Create_Effect_Entity(string eff_name, bool eff_trail) -{ - entity this = new(effect_entity); - this.eent_eff_name = eff_name; - this.eent_eff_trail = eff_trail; - return this; -} - -void RegisterEffects_First() -{ - #ifdef SVQC - #define dedi (server_is_dedicated ? "a dedicated " : "") - #else - #define dedi "" - #endif - - LOG_TRACEF("Beginning effect initialization on %s%s program...\n", dedi, PROGNAME); - #undef dedi -} - -void RegisterEffects_Done() -{ - LOG_TRACE("Effects initialization successful!\n"); -} - -// NOW we actually activate the declarations -ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_First) -EFFECT(0, Null, string_null) -#include "effects.inc" -ACCUMULATE_FUNCTION(RegisterEffects, RegisterEffects_Done) - -#endif diff --git a/qcsrc/common/minigames/cl_minigames_hud.qc b/qcsrc/common/minigames/cl_minigames_hud.qc index 2a0b03620..f1ee4f675 100644 --- a/qcsrc/common/minigames/cl_minigames_hud.qc +++ b/qcsrc/common/minigames/cl_minigames_hud.qc @@ -1,5 +1,5 @@ +#include "cl_minigames_hud.qh" #include "minigames.qh" -#include "../../client/mapvoting.qh" // whether the mouse is over the given panel bool HUD_mouse_over(entity somepanel) diff --git a/qcsrc/common/minigames/cl_minigames_hud.qh b/qcsrc/common/minigames/cl_minigames_hud.qh new file mode 100644 index 000000000..f170c590d --- /dev/null +++ b/qcsrc/common/minigames/cl_minigames_hud.qh @@ -0,0 +1,7 @@ +#ifndef CL_MINIGAMES_HUD_H +#define CL_MINIGAMES_HUD_H + +float HUD_Minigame_InputEvent(float bInputType, float nPrimary, float nSecondary); +void HUD_Minigame_Mouse(); + +#endif diff --git a/qcsrc/common/minigames/minigame/pp.qc b/qcsrc/common/minigames/minigame/pp.qc index efce0e66b..3ef2124dc 100644 --- a/qcsrc/common/minigames/minigame/pp.qc +++ b/qcsrc/common/minigames/minigame/pp.qc @@ -17,6 +17,8 @@ const int PP_NUM_CNT = 7; const int PP_TILE_SIZE = 7; +.int cnt; + .int pp_team1_score; .int pp_team2_score; diff --git a/qcsrc/common/models/all.qh b/qcsrc/common/models/all.qh index 38c533449..a7ab90880 100644 --- a/qcsrc/common/models/all.qh +++ b/qcsrc/common/models/all.qh @@ -1,30 +1,11 @@ #ifndef MODELS_ALL_H #define MODELS_ALL_H -#define setmodel(e, m) _setmodel((e), (m).model_str()) +#include "model.qh" REGISTRY(Models, BIT(9)) REGISTER_REGISTRY(RegisterModels) -CLASS(Model, Object) - ATTRIB(Model, m_id, int, 0) - ATTRIB(Model, model_str, string(), func_null) - CONSTRUCTOR(Model, string() path) - { - CONSTRUCT(Model); - this.model_str = path; - } - METHOD(Model, model_precache, void(entity this)) { - string s = this.model_str(); - if (s != "" && s != "null" && !fexists(s)) { - LOG_WARNINGF("Missing model: \"%s\"\n", s); - return; - } - LOG_TRACEF("precache_model(\"%s\")\n", s); - precache_model(s); - } -ENDCLASS(Model) - #define MODEL(name, path) \ string MDL_##name##_get() { return path; } \ REGISTER(RegisterModels, MDL, Models, name, m_id, NEW(Model, MDL_##name##_get)) diff --git a/qcsrc/common/models/model.qh b/qcsrc/common/models/model.qh new file mode 100644 index 000000000..b4005b777 --- /dev/null +++ b/qcsrc/common/models/model.qh @@ -0,0 +1,25 @@ +#ifndef MODEL_H +#define MODEL_H + +#define setmodel(e, m) _setmodel((e), (m).model_str()) + +CLASS(Model, Object) + ATTRIB(Model, m_id, int, 0) + ATTRIB(Model, model_str, string(), func_null) + CONSTRUCTOR(Model, string() path) + { + CONSTRUCT(Model); + this.model_str = path; + } + METHOD(Model, model_precache, void(entity this)) { + string s = this.model_str(); + if (s != "" && s != "null" && !fexists(s)) { + LOG_WARNINGF("Missing model: \"%s\"\n", s); + return; + } + LOG_TRACEF("precache_model(\"%s\")\n", s); + precache_model(s); + } +ENDCLASS(Model) + +#endif diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 043ec38b9..6c6aa0f82 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -939,4 +939,6 @@ ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_First) #include "notifications.inc" ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotifications_Done) +STATIC_INIT(RegisterNotifications) { CALL_ACCUMULATED_FUNCTION(RegisterNotifications); } + #endif diff --git a/qcsrc/common/sounds/all.inc b/qcsrc/common/sounds/all.inc index 0e5bd7ffb..8a7dbbca3 100644 --- a/qcsrc/common/sounds/all.inc +++ b/qcsrc/common/sounds/all.inc @@ -1,6 +1,7 @@ // Global list of sounds // TODO: remove uses of _sound +#include "../teams.qh" string W_Sound(string w_snd); SOUND(ARC_FIRE, W_Sound("arc_fire")); diff --git a/qcsrc/common/sounds/all.qh b/qcsrc/common/sounds/all.qh index 90858f39d..d39c701d7 100644 --- a/qcsrc/common/sounds/all.qh +++ b/qcsrc/common/sounds/all.qh @@ -1,49 +1,18 @@ #ifndef SOUNDS_ALL_H #define SOUNDS_ALL_H -#include "../teams.qh" +#include "sound.qh" -// Play all sounds via sound7, for access to the extra channels. -// Otherwise, channels 8 to 15 would be blocked for a weird QW feature. -#ifdef SVQC - #define _sound(e, c, s, v, a) do { \ - entity __e = e; \ - if (!sound_allowed(MSG_BROADCAST, __e)) break; \ - sound7(__e, c, s, v, a, 0, 0); \ - } while (0) -#else - #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0) -#endif -#define sound(e, c, s, v, a) _sound(e, c, s.sound_str(), v, a) -// Used in places where a string is required -#define SND(id) (SND_##id.sound_str()) - -REGISTRY(Sounds, BIT(8)) +REGISTRY(Sounds, BITS(8)) REGISTER_REGISTRY(RegisterSounds) -CLASS(Sound, Object) - ATTRIB(Sound, m_id, int, 0) - ATTRIB(Sound, sound_str, string(), func_null) - CONSTRUCTOR(Sound, string() path) - { - CONSTRUCT(Sound); - this.sound_str = path; - } - METHOD(Sound, sound_precache, void(entity this)) { - string s = this.sound_str(); - if (s && s != "" && !fexists(strcat("sound/", s))) { - LOG_WARNINGF("Missing sound: \"%s\"\n", s); - return; - } - LOG_TRACEF("precache_sound(\"%s\")\n", s); - precache_sound(s); - } -ENDCLASS(Sound) - #define SOUND(name, path) \ string SND_##name##_get() { return path; } \ REGISTER(RegisterSounds, SND, Sounds, name, m_id, NEW(Sound, SND_##name##_get)) +// Used in places where a string is required +#define SND(id) (SND_##id.sound_str()) + STATIC_INIT(RegisterSounds_precache) { FOREACH(Sounds, true, LAMBDA({ it.sound_precache(it); diff --git a/qcsrc/common/sounds/sound.qh b/qcsrc/common/sounds/sound.qh new file mode 100644 index 000000000..bc393dda3 --- /dev/null +++ b/qcsrc/common/sounds/sound.qh @@ -0,0 +1,36 @@ +#ifndef SOUND_H +#define SOUND_H + +// Play all sounds via sound7, for access to the extra channels. +// Otherwise, channels 8 to 15 would be blocked for a weird QW feature. +#ifdef SVQC + #define _sound(e, c, s, v, a) do { \ + entity __e = e; \ + if (!sound_allowed(MSG_BROADCAST, __e)) break; \ + sound7(__e, c, s, v, a, 0, 0); \ + } while (0) +#else + #define _sound(e, c, s, v, a) sound7(e, c, s, v, a, 0, 0) +#endif +#define sound(e, c, s, v, a) _sound(e, c, s.sound_str(), v, a) + +CLASS(Sound, Object) + ATTRIB(Sound, m_id, int, 0) + ATTRIB(Sound, sound_str, string(), func_null) + CONSTRUCTOR(Sound, string() path) + { + CONSTRUCT(Sound); + this.sound_str = path; + } + METHOD(Sound, sound_precache, void(entity this)) { + string s = this.sound_str(); + if (s && s != "" && !fexists(strcat("sound/", s))) { + LOG_WARNINGF("Missing sound: \"%s\"\n", s); + return; + } + LOG_TRACEF("precache_sound(\"%s\")\n", s); + precache_sound(s); + } +ENDCLASS(Sound) + +#endif diff --git a/qcsrc/common/triggers/subs.qh b/qcsrc/common/triggers/subs.qh index 98491820f..95cc59904 100644 --- a/qcsrc/common/triggers/subs.qh +++ b/qcsrc/common/triggers/subs.qh @@ -26,6 +26,8 @@ #define SUB_LTIME move_ltime #define SUB_FLAGS move_flags +.vector move_origin; + void SUB_SETORIGIN(entity s, vector v) {SELFPARAM(); s.move_origin = v; diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 9c794c0eb..b687086ba 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -174,40 +174,6 @@ string ftos_decimals(float number, float decimals) return sprintf("%.*f", decimals, number); } -vector colormapPaletteColor(float c, bool isPants) -{ - switch (c) - { - case 0: return '1.000000 1.000000 1.000000'; - case 1: return '1.000000 0.333333 0.000000'; - case 2: return '0.000000 1.000000 0.501961'; - case 3: return '0.000000 1.000000 0.000000'; - case 4: return '1.000000 0.000000 0.000000'; - case 5: return '0.000000 0.666667 1.000000'; - case 6: return '0.000000 1.000000 1.000000'; - case 7: return '0.501961 1.000000 0.000000'; - case 8: return '0.501961 0.000000 1.000000'; - case 9: return '1.000000 0.000000 1.000000'; - case 10: return '1.000000 0.000000 0.501961'; - case 11: return '0.000000 0.000000 1.000000'; - case 12: return '1.000000 1.000000 0.000000'; - case 13: return '0.000000 0.333333 1.000000'; - case 14: return '1.000000 0.666667 0.000000'; - case 15: - if (isPants) - return - '1 0 0' * (0.502 + 0.498 * sin(time / 2.7182818285 + 0.0000000000)) - + '0 1 0' * (0.502 + 0.498 * sin(time / 2.7182818285 + 2.0943951024)) - + '0 0 1' * (0.502 + 0.498 * sin(time / 2.7182818285 + 4.1887902048)); - else - return - '1 0 0' * (0.502 + 0.498 * sin(time / 3.1415926536 + 5.2359877560)) - + '0 1 0' * (0.502 + 0.498 * sin(time / 3.1415926536 + 3.1415926536)) - + '0 0 1' * (0.502 + 0.498 * sin(time / 3.1415926536 + 1.0471975512)); - default: return '0.000 0.000 0.000'; - } -} - // Databases (hash tables) const float DB_BUCKETS = 8192; void db_save(float db, string pFilename) diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index a2774aa50..8bedccf0a 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -28,8 +28,6 @@ string ftos_decimals(float number, float decimals); bool fexists(string f); -vector colormapPaletteColor(float c, float isPants); - // unzone the string, and return it as tempstring. Safe to be called on string_null string fstrunzone(string s); diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 7108e8077..500bc60c8 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -1,5 +1,4 @@ #include "sv_vehicles.qh" -#include "../effects/effects.qh" #if 0 bool vehicle_send(entity to, int sf) diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 2b5950a25..7bc45c0d5 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -27,7 +27,6 @@ REGISTER_VEHICLE(RACER, NEW(Racer)); #include "racer_weapon.qc" #ifdef SVQC -#include "../../effects/effects.qh" #include "../../triggers/trigger/impulse.qh" bool autocvar_g_vehicle_racer; diff --git a/qcsrc/lib/_all.inc b/qcsrc/lib/_all.inc index 5addff39f..66a79c83c 100644 --- a/qcsrc/lib/_all.inc +++ b/qcsrc/lib/_all.inc @@ -30,6 +30,7 @@ #include "accumulate.qh" #include "bits.qh" #include "bool.qh" +#include "color.qh" #include "counting.qh" #include "cvar.qh" #include "defer.qh" diff --git a/qcsrc/lib/color.qh b/qcsrc/lib/color.qh new file mode 100644 index 000000000..d21dab84e --- /dev/null +++ b/qcsrc/lib/color.qh @@ -0,0 +1,38 @@ +#ifndef COLOR_H +#define COLOR_H + +#define colormapPaletteColor(c, isPants) colormapPaletteColor_(c, isPants, time) +vector colormapPaletteColor_(int c, bool isPants, float t) +{ + switch (c) { + case 0: return '1.000000 1.000000 1.000000'; + case 1: return '1.000000 0.333333 0.000000'; + case 2: return '0.000000 1.000000 0.501961'; + case 3: return '0.000000 1.000000 0.000000'; + case 4: return '1.000000 0.000000 0.000000'; + case 5: return '0.000000 0.666667 1.000000'; + case 6: return '0.000000 1.000000 1.000000'; + case 7: return '0.501961 1.000000 0.000000'; + case 8: return '0.501961 0.000000 1.000000'; + case 9: return '1.000000 0.000000 1.000000'; + case 10: return '1.000000 0.000000 0.501961'; + case 11: return '0.000000 0.000000 1.000000'; + case 12: return '1.000000 1.000000 0.000000'; + case 13: return '0.000000 0.333333 1.000000'; + case 14: return '1.000000 0.666667 0.000000'; + case 15: + if (isPants) + return + '1 0 0' * (0.502 + 0.498 * sin(t / 2.7182818285 + 0.0000000000)) + + '0 1 0' * (0.502 + 0.498 * sin(t / 2.7182818285 + 2.0943951024)) + + '0 0 1' * (0.502 + 0.498 * sin(t / 2.7182818285 + 4.1887902048)); + else + return + '1 0 0' * (0.502 + 0.498 * sin(t / 3.1415926536 + 5.2359877560)) + + '0 1 0' * (0.502 + 0.498 * sin(t / 3.1415926536 + 3.1415926536)) + + '0 0 1' * (0.502 + 0.498 * sin(t / 3.1415926536 + 1.0471975512)); + default: return '0.000 0.000 0.000'; + } +} + +#endif diff --git a/qcsrc/server/_all.qh b/qcsrc/server/_all.qh index dd3b1aaaf..eeb06e7a6 100644 --- a/qcsrc/server/_all.qh +++ b/qcsrc/server/_all.qh @@ -7,6 +7,7 @@ #include "miscfunctions.qh" +#include "../common/effects/all.qh" #include "../common/models/all.qh" #include "../common/sounds/all.qh" diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 9912174dd..aa87763ca 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -11,7 +11,6 @@ #include "../common/constants.qh" #include "../common/deathtypes.qh" -#include "../common/effects/effects.qh" #include "../common/util.qh" #include "../common/monsters/all.qh" diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index a0f9a3f13..75c61d2ee 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -22,7 +22,6 @@ #include "../common/buffs/all.qh" #include "../common/constants.qh" #include "../common/deathtypes.qh" -#include "../common/effects/effects.qh" #include "../common/mapinfo.qh" #include "../common/monsters/all.qh" #include "../common/monsters/sv_monsters.qh" @@ -557,7 +556,6 @@ spawnfunc(__init_dedicated_server) // needs to be done so early because of the constants they create static_init(); - CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); MapInfo_Enumerate(); @@ -603,7 +601,6 @@ spawnfunc(worldspawn) // needs to be done so early because of the constants they create static_init(); - CALL_ACCUMULATED_FUNCTION(RegisterNotifications); CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes); ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid)); diff --git a/qcsrc/server/progs.inc b/qcsrc/server/progs.inc index d8eda4986..ee891aa4d 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -1,4 +1,5 @@ #include "../lib/_all.inc" +#include "_all.qh" #include "anticheat.qc" #include "antilag.qc" @@ -61,7 +62,6 @@ #include "../common/animdecide.qc" #include "../common/campaign_file.qc" #include "../common/campaign_setup.qc" -#include "../common/effects/effects.qc" #include "../common/effects/effectinfo.qc" #include "../common/mapinfo.qc" #include "../common/monsters/spawn.qc" @@ -78,6 +78,7 @@ #include "../common/util.qc" #include "../common/buffs/all.qc" +#include "../common/effects/all.qc" #include "../common/items/all.qc" #include "../common/monsters/all.qc" #include "../common/mutators/all.qc" diff --git a/qcsrc/test/compilationunit.sh b/qcsrc/test/compilationunit.sh index e31476f52..66cf5c576 100755 --- a/qcsrc/test/compilationunit.sh +++ b/qcsrc/test/compilationunit.sh @@ -26,7 +26,7 @@ declare -a QCC_FLAGS=( function check() { declare -l base="${1}" - declare -la predefs=("-D${2}" "lib/_all.inc") + declare -la predefs=("-D${2}" "lib/_all.inc" "${base}/_all.qh") find "$base" -type f -name '*.qc' -print0 | sort -z | while read -r -d '' file; do echo "$file" ${QCC} "${QCC_FLAGS[@]}" "${NOWARN[@]}" "${FEATURES[@]}" "${predefs[@]}" "$file" >/dev/null