X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=inline;f=qcsrc%2Fserver%2Fcommand%2Fgetreplies.qc;h=3f82484abe7d9e9e07fd4de62d2dadfddab206a9;hb=75e86e2696af2742dd3399b95c42fea9741db044;hp=3e75b5b6f140f9dc7df7176d959c5ed2b5af952d;hpb=19c09c8cfc6a4cb71c07e63bf739b7720ec6b0a0;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/command/getreplies.qc b/qcsrc/server/command/getreplies.qc index 3e75b5b6f..3f82484ab 100644 --- a/qcsrc/server/command/getreplies.qc +++ b/qcsrc/server/command/getreplies.qc @@ -1,33 +1,38 @@ #include "getreplies.qh" -#include -#include - #include -#include "getreplies.qh" - -#include "../race.qh" - #include #include +#include #include +#include +#include +#include #include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // ========================================================= // Reply messages for common commands, re-worked by Samual // Last updated: December 30th, 2011 // ========================================================= -// These strings are set usually during init in g_world.qc, +// These strings are set usually during init in world.qc, // or also by some game modes or other functions manually, // and their purpose is to output information to clients // without using any extra processing time. // See common.qc for their proper commands -string getrecords(int page) // 50 records per page +string getrecords(int page) { string s = ""; @@ -35,9 +40,6 @@ string getrecords(int page) // 50 records per page s = M_ARGV(1, string); MapInfo_ClearTemps(); - - if (s == "" && page == 0) - return "No records are available on this server for the current game mode.\n"; return s; } @@ -297,3 +299,102 @@ string getmonsterlist() return sprintf("^7Monsters available: %s\n", monsterlist); } + +/* +============= +GetCvars +============= +Superseded by REPLICATE +Called with: + 0: sends the request + >0: receives a cvar from name=argv(f) value=argv(f+1) +*/ +void GetCvars_handleString(entity this, entity store, string thisname, float f, .string field, string name) +{ + if (f < 0) + { + strfree(store.(field)); + } + else if (f > 0) + { + if (thisname == name) + { + strcpy(store.(field), argv(f + 1)); + } + } + else + stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n")); +} +void GetCvars_handleString_Fixup(entity this, entity store, string thisname, float f, .string field, string name, string(entity, string) func) +{ + GetCvars_handleString(this, store, thisname, f, field, name); + if (f >= 0) // also initialize to the fitting value for "" when sending cvars out + if (thisname == name) + { + string s = func(this, strcat1(store.(field))); + if (s != store.(field)) + { + strcpy(store.(field), s); + } + } +} +void GetCvars_handleFloat(entity this, entity store, string thisname, float f, .float field, string name) +{ + if (f < 0) + { + } + else if (f > 0) + { + if (thisname == name) + store.(field) = stof(argv(f + 1)); + } + else + stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n")); +} +void GetCvars_handleFloatOnce(entity this, entity store, string thisname, float f, .float field, string name) +{ + if (f < 0) + { + } + else if (f > 0) + { + if (thisname == name) + { + if (!store.(field)) + { + store.(field) = stof(argv(f + 1)); + if (!store.(field)) + store.(field) = -1; + } + } + } + else + { + if (!store.(field)) + stuffcmd(this, strcat("cl_cmd sendcvar ", name, "\n")); + } +} + +/** + * @param f -1: cleanup, 0: request, 1: receive + */ +void GetCvars(entity this, entity store, int f) +{ + string s = string_null; + + if (f == 0) + LOG_INFO("Warning: requesting cvar values is deprecated. Client should send them automatically using REPLICATE.\n"); + + if (f > 0) + s = strcat1(argv(f)); + + get_cvars_f = f; + get_cvars_s = s; + MUTATOR_CALLHOOK(GetCvars); + + Notification_GetCvars(this, store); + + ReplicateVars(this, store, s, f); + if (f > 0) + ReplicateVars_ApplyChange(this, store, s, f); +}