diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 08618893..bcb3d61c 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -360,6 +360,24 @@ void showhudextras(char hudextras, char value){ int lastspawn = 0; +void onCallVote(int type, int vcn, char *text, char *a) +{ + if(identexists("onCallVote")) + { + defformatstring(runas)("%s %d %d [%s] [%s]", "onCallVote", type, vcn, text, a); + execute(runas); + } +} + +void onChangeVote(int mod, int id) +{ + if(identexists("onChangeVote")) + { + defformatstring(runas)("%s %d %d", "onChangeVote", mod, id); + execute(runas); + } +} + VAR(voicecomsounds, 0, 1, 2); bool medals_arrived=0; medalsst a_medals[END_MDS]; @@ -1161,6 +1179,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) getstring(text, p); filtertext(text, text); v = newvotedisplayinfo(d, type, text, NULL); + break; case SA_STOPDEMO: case SA_REMBANS: @@ -1173,31 +1192,47 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) break; } displayvote(v); + onCallVote(type, vcn, text, a); if (vcn >= 0) { - loopi(n_yes) votecount(VOTE_YES); - loopi(n_no) votecount(VOTE_NO); - } + loopi(n_yes) votecount(VOTE_YES); + loopi(n_no) votecount(VOTE_NO); + } extern int vote(int); if (d == player1) vote(VOTE_YES); break; } case SV_CALLVOTESUC: - callvotesuc(); - break; + { + callvotesuc(); + onChangeVote( 0, -1); + break; + } case SV_CALLVOTEERR: - callvoteerr(getint(p)); + { + int errn = getint(p); + callvoteerr(errn); + onChangeVote( 1, errn); break; + } case SV_VOTE: - votecount(getint(p)); + { + int vote = getint(p); + votecount(vote); + onChangeVote( 2, vote); break; + } case SV_VOTERESULT: - voteresult(getint(p)); + { + int vres = getint(p); + voteresult(vres); + onChangeVote( 3, vres); break; + } case SV_WHOISINFO: { @@ -1216,7 +1251,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) else loopi(demos) { getstring(text, p); - conoutf("%d. %s", i+1, text); // i18n for this?? there's tons of other strings that NEED it, not this. (said flowtron: 2010jul13) + conoutf("%d. %s", i+1, text); } break; } @@ -1252,6 +1287,121 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) #endif } +#define DEFDEMOFILEFMT "%w_%h_%n_%Mmin_%G" +#define DEFDEMOTIMEFMT "%Y%m%d_%H%M" + +string demofilenameformat = DEFDEMOFILEFMT; +void setDemoFilenameFormat(char *fmt) +{ + if(fmt && fmt[0]!='\0') + { + copystring(demofilenameformat, fmt); + } else copystring(demofilenameformat, DEFDEMOFILEFMT); // reset to default if passed empty string - or should we output the current value in this case? +} +COMMANDN(demonameformat, setDemoFilenameFormat, ARG_1STR); + +string demotimestampformat = DEFDEMOTIMEFMT; +void setDemoTimestampFormat(char *fmt) +{ + if(fmt && fmt[0]!='\0') + { + copystring(demofilenameformat, fmt); + } else copystring(demofilenameformat, DEFDEMOTIMEFMT); // reset to default if passed empty string - or should we output the current value in this case? +} +COMMANDN(demotimeformat, setDemoTimestampFormat, ARG_1STR); + +void getdemonameformat() { result(demofilenameformat); } COMMAND(getdemonameformat, ARG_NONE); +void getdemotimeformat() { result(demotimestampformat); } COMMAND(getdemotimeformat, ARG_NONE); + +const char *getDemoFilename(int gmode, int mplay, int mdrop, int tstamp, char *srvmap) +{ + // we use the following internal mapping of formatchars: + // %g : gamemode (int) %G : gamemode (chr) %F : gamemode (full) + // %m : minutes remaining %M : minutes played + // %s : seconds remaining %S : seconds played + // %h : IP of server %H : hostname of server (%N : title of server (really???)) + // %n : mapName + // %w : timestamp "when" + static string dmofn; + int cc = 0; + int mc = strlen(demofilenameformat); + while(cc