X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fplayerdemo.qc;h=9e335a331f8166fc37b48d2ef10e0160d35c9b05;hb=68d68e5cbc145772438bfdd775302b91f442f029;hp=631c10dcbb67fb36bacf638882abe4710f70a76f;hpb=0e7ed909bffb4ff21f0c68d163edfc17487e380a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/playerdemo.qc b/qcsrc/server/playerdemo.qc index 631c10dcb..9e335a331 100644 --- a/qcsrc/server/playerdemo.qc +++ b/qcsrc/server/playerdemo.qc @@ -1,25 +1,33 @@ +#include "playerdemo.qh" +#if defined(CSQC) +#elif defined(MENUQC) +#elif defined(SVQC) + #include "defs.qh" + #include "playerdemo.qh" +#endif + .float playerdemo_fh; .float playerdemo_mode; .float playerdemo_starttime; .float playerdemo_time; -#define PLAYERDEMO_MODE_OFF 0 -#define PLAYERDEMO_MODE_READING 1 -#define PLAYERDEMO_MODE_WRITING 2 -void playerdemo_init() +const float PLAYERDEMO_MODE_OFF = 0; +const float PLAYERDEMO_MODE_READING = 1; +const float PLAYERDEMO_MODE_WRITING = 2; +void playerdemo_init(entity this) { - self.playerdemo_mode = PLAYERDEMO_MODE_OFF; + this.playerdemo_mode = PLAYERDEMO_MODE_OFF; } void playerdemo_shutdown() -{ +{SELFPARAM(); if(self.playerdemo_mode != PLAYERDEMO_MODE_OFF) { - print("playerdemo: ", self.netname, " closed\n"); + LOG_INFO("playerdemo: ", self.netname, " closed\n"); fclose(self.playerdemo_fh); } self.playerdemo_mode = 0; } void playerdemo_open_read(string f) -{ +{SELFPARAM(); playerdemo_shutdown(); self.playerdemo_mode = PLAYERDEMO_MODE_READING; self.playerdemo_fh = fopen(f, FILE_READ); @@ -27,16 +35,16 @@ void playerdemo_open_read(string f) self.playerdemo_time = stof(fgets(self.playerdemo_fh)); self.playerdemo_time += self.playerdemo_starttime; self.movetype = MOVETYPE_NONE; - print("playerdemo: ", self.netname, " reading from ", f, "\n"); + LOG_INFO("playerdemo: ", self.netname, " reading from ", f, "\n"); } void playerdemo_open_write(string f) -{ +{SELFPARAM(); playerdemo_shutdown(); self.playerdemo_mode = PLAYERDEMO_MODE_WRITING; self.playerdemo_fh = fopen(f, FILE_WRITE); self.playerdemo_starttime = time - 1; - print("playerdemo: ", self.netname, " writing to ", f, "\n"); - print("WARNING: playerdemo file format is incomplete and not stable yet. DO NOT RELY ON IT!\n"); + LOG_INFO("playerdemo: ", self.netname, " writing to ", f, "\n"); + LOG_INFO("WARNING: playerdemo file format is incomplete and not stable yet. DO NOT RELY ON IT!\n"); } #define PLAYERDEMO_FIELD(func,t,f) func##t(f,#f); #define PLAYERDEMO_FIELDS(func) \ @@ -51,109 +59,107 @@ void playerdemo_open_write(string f) PLAYERDEMO_FIELD(func,string,playerskin) \ PLAYERDEMO_FIELD(func,float,frame) \ PLAYERDEMO_FIELD(func,float,effects) \ - PLAYERDEMO_FIELD(func,float,switchweapon) \ - PLAYERDEMO_FIELD(func,float,BUTTON_ATCK) \ - PLAYERDEMO_FIELD(func,float,BUTTON_ATCK2) \ - PLAYERDEMO_FIELD(func,float,BUTTON_CROUCH) \ - PLAYERDEMO_FIELD(func,float,BUTTON_HOOK) \ - PLAYERDEMO_FIELD(func,float,BUTTON_USE) \ + /* PLAYERDEMO_FIELD(func,float,switchweapon) */ \ + PLAYERDEMO_FIELD(func,float,button0) /* TODO: PHYS_INPUT_BUTTON_ATCK */ \ + PLAYERDEMO_FIELD(func,float,button3) /* TODO: PHYS_INPUT_BUTTON_ATCK2 */ \ + PLAYERDEMO_FIELD(func,float,button5) /* TODO: PHYS_INPUT_BUTTON_CROUCH */ \ + PLAYERDEMO_FIELD(func,float,button6) /* TODO: PHYS_INPUT_BUTTON_HOOK */ \ + PLAYERDEMO_FIELD(func,float,buttonuse) /* TODO: PHYS_INPUT_BUTTON_USE */ \ PLAYERDEMO_FIELD(func,float,flags) \ // end of list void playerdemo_write_originvector(.vector f, string name) -{ - fputs(self.playerdemo_fh, strcat(vtos(self.f), "\n")); +{SELFPARAM(); + fputs(self.playerdemo_fh, strcat(vtos(self.(f)), "\n")); } void playerdemo_write_sizevector(.vector f, string name) -{ - fputs(self.playerdemo_fh, strcat(vtos(self.f), "\n")); +{SELFPARAM(); + fputs(self.playerdemo_fh, strcat(vtos(self.(f)), "\n")); } void playerdemo_write_vector(.vector f, string name) -{ - fputs(self.playerdemo_fh, strcat(vtos(self.f), "\n")); +{SELFPARAM(); + fputs(self.playerdemo_fh, strcat(vtos(self.(f)), "\n")); } void playerdemo_write_string(.string f, string name) -{ - fputs(self.playerdemo_fh, strcat(self.f, "\n")); +{SELFPARAM(); + fputs(self.playerdemo_fh, strcat(self.(f), "\n")); } void playerdemo_write_modelstring(.string f, string name) -{ - fputs(self.playerdemo_fh, strcat(self.f, "\n")); +{SELFPARAM(); + fputs(self.playerdemo_fh, strcat(self.(f), "\n")); } void playerdemo_write_float(.float f, string name) -{ - fputs(self.playerdemo_fh, strcat(ftos(self.f), "\n")); +{SELFPARAM(); + fputs(self.playerdemo_fh, strcat(ftos(self.(f)), "\n")); } void playerdemo_write() -{ +{SELFPARAM(); if(self.playerdemo_mode != PLAYERDEMO_MODE_WRITING) return; fputs(self.playerdemo_fh, strcat(ftos(time - self.playerdemo_starttime), "\n")); PLAYERDEMO_FIELDS(playerdemo_write_) } void playerdemo_read_originvector(.vector f, string name) -{ +{SELFPARAM(); setorigin(self, stov(fgets(self.playerdemo_fh))); } void playerdemo_read_sizevector(.vector f, string name) -{ - self.f = stov(fgets(self.playerdemo_fh)); +{SELFPARAM(); + self.(f) = stov(fgets(self.playerdemo_fh)); setsize(self, self.mins, self.maxs); } void playerdemo_read_vector(.vector f, string name) -{ - self.f = stov(fgets(self.playerdemo_fh)); +{SELFPARAM(); + self.(f) = stov(fgets(self.playerdemo_fh)); } void playerdemo_read_string(.string f, string name) -{ - string s; - s = fgets(self.playerdemo_fh); - if(s != self.f) +{SELFPARAM(); + string s = fgets(self.playerdemo_fh); + if (s != self.(f)) { /* if(self.f) strunzone(self.f); */ - self.f = strzone(s); + self.(f) = strzone(s); } } void playerdemo_read_modelstring(.string f, string name) -{ - string s; - s = fgets(self.playerdemo_fh); - if(s != self.f) - setmodel(self, s); +{SELFPARAM(); + string s = fgets(self.playerdemo_fh); + if (s != self.(f)) + _setmodel(self, s); } void playerdemo_read_float(.float f, string name) -{ - self.f = stof(fgets(self.playerdemo_fh)); +{SELFPARAM(); + self.(f) = stof(fgets(self.playerdemo_fh)); } -float playerdemo_read() +float playerdemo_read(entity this) { - if(self.playerdemo_mode != PLAYERDEMO_MODE_READING) + if(this.playerdemo_mode != PLAYERDEMO_MODE_READING) return 0; - if(self.playerdemo_time < 0) + if(this.playerdemo_time < 0) return 1; float t; t = time; - while(time >= self.playerdemo_time) + while(time >= this.playerdemo_time) { PLAYERDEMO_FIELDS(playerdemo_read_) { - time = self.playerdemo_time; - PlayerPreThink(); + time = this.playerdemo_time; + WITH(entity, self, this, PlayerPreThink()); // not running physics though... this is just so we can run weapon stuff - PlayerPostThink(); + WITH(entity, self, this, PlayerPostThink()); } - self.playerdemo_time = stof(fgets(self.playerdemo_fh)); - if(self.playerdemo_time == 0) + this.playerdemo_time = stof(fgets(this.playerdemo_fh)); + if(this.playerdemo_time == 0) { - self.playerdemo_time = -1; + this.playerdemo_time = -1; return 1; } - self.playerdemo_time += self.playerdemo_starttime; + this.playerdemo_time += this.playerdemo_starttime; } - self.velocity = '0 0 0'; + this.velocity = '0 0 0'; time = t; return 1; }