Fixing lss nade spawn, some HUDEXTRAS stuff, and temporarily reverting the cursor related functions to 1.0.4 ones

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5076 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-05-27 02:21:37 +00:00
parent 6e34f34590
commit d174d82e1d
9 changed files with 198 additions and 87 deletions
+1 -1
View File
@@ -46,7 +46,6 @@ menuitemtextinput "Nickname: " "" "name $arg1"
menuitemtextinput "Resolution (Width): " "$scr_w" "scr_w $arg1"
menuitemtextinput "Resolution (Height): " "$scr_h" "scr_h $arg1"
menuitemtextinput "Mouse sensitivity " "$sensitivity" "sensitivity $arg1"
menuitemtextinput "Smooth Mouse (0 to 3) " "$mfilter" "mfilter $arg1"
menuitemslider "Graphics detail: " 1 6 "$gfxqualityalias" 1 [ Horrible Low Medium Good "High (Performs slow)" "INSANE! (Performs really slow)"] "new_gfx_quality $arg1"
menuitemslider "Sound detail: " 1 3 "$soundqualityalias" 1 "Low Medium High" "new_sound_quality $arg1"
menuitem "" -1
@@ -393,6 +392,7 @@ menuitemcheckbox " Damage direction indicator " "(= $hidedamageindicator 0)" "
menuitemcheckbox " Damage screen flash " "$damagescreen" "damagescreen $arg1"
menuitemcheckbox " Crosshair team-sign " "$crosshairteamsign" "crosshairteamsign $arg1"
menuitemcheckbox " CTF icons" "(= $hidectfhud 0)" "hidectfhud (= $arg1 0)"
menuitemslider " " 0 2 [ $hudextras ] 1 [ "No extra messages" "Show extra messages in console" "Pop up extra messages!" ] [ hudextras $arg1 ]
menuitem "" -1
menuitemslider "Crosshair size: " 0 50 "$crosshairsize" 5 "" "crosshairsize $arg1"
menuitem "Change crosshair... " "showmenu Crosshairs"
+4 -4
View File
@@ -231,14 +231,14 @@ void showhudextras(char hudextras, char value){
void (*outf)(const char *s, ...) = (hudextras == 2 ? hudoutf : conoutf);
switch(value)
{
case 0:
case HE_COMBO:
outf("\f2COMBO"); break;
case 1:
case HE_FLAGDEFENDED:
outf("\f2FLAG DEFENDED"); break;
case 2:
case HE_FLAGCOVERED:
outf("\f2FLAG COVERED"); break;
default:
outf("\f2new message"); break;
outf("\f2Update your client, NOOB!"); break;
}
}
+16 -1
View File
@@ -112,6 +112,20 @@ void conoutf(const char *s, ...)
con.addline(sf);
}
/** This is the 1.0.4 function
It will substituted by rendercommand_wip
I am putting this temporarily here because it is very difficult to chat in game with the current cursor behavior,
and chatting in this test period is extremelly important : Brahma */
int rendercommand(int x, int y, int w)
{
defformatstring(s)("> %s", cmdline.buf);
int width, height;
text_bounds(s, width, height, w);
y -= height - FONTH;
draw_text(s, x, y, 0xFF, 0xFF, 0xFF, 0xFF, cmdline.pos>=0 ? cmdline.pos+2 : (int)strlen(s), w);
return height;
}
const char *getCONprefix(int n)
{
const char* CONpreSTR[] = {
@@ -128,7 +142,8 @@ int getCONlength(int n)
return strlen(CURpreSTR);
}
int rendercommand(int x, int y, int w)
/** WIP ALERT */
int rendercommand_wip(int x, int y, int w)
{
int width, height;
if( strlen(cmdline.buf) > 0 )
+166 -68
View File
@@ -21,7 +21,7 @@ template<class LINE> struct consolebuffer
maxlines = numlines;
while(conlines.length() > maxlines) delete[] conlines.pop().line;
}
virtual ~consolebuffer()
{
while(conlines.length()) delete[] conlines.pop().line;
@@ -30,9 +30,13 @@ template<class LINE> struct consolebuffer
virtual void render() = 0;
};
/** This is the 1.0.4 structure
It will substituted by textinputbuffer_wip
I am putting this temporarily here to fix the weird cursor behavior
Please, read the comments in rendercommand::console.cpp : Brahma */
struct textinputbuffer
{
string buf;
string buf;
int pos, max;
textinputbuffer() : pos(-1), max(0)
@@ -58,100 +62,194 @@ struct textinputbuffer
case SDLK_DELETE:
{
if(pos < 0) break;
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
std::string::iterator first = s.begin();
std::string::iterator second = s.begin();
utf8::advance(first, pos, s.end());
utf8::advance(second, pos + 1, s.end());
s.erase(first, second);
strcpy(buf, s.c_str());
int len = (int)strlen(buf);
if(pos<0) break;
memmove(&buf[pos], &buf[pos+1], len - pos);
if(pos>=len-1) pos = -1;
return true;
}
case SDLK_BACKSPACE:
{
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
int i = pos>=0 ? pos : len;
if(i<1) break;
std::string::iterator first = s.begin();
std::string::iterator second = s.begin();
utf8::advance(first, i - 1, s.end());
utf8::advance(second, i, s.end());
s.erase(first, second);
strcpy(buf, s.c_str());
if(pos > 0) pos--;
else if(!pos && len <=1 ) pos = -1;
int len = (int)strlen(buf), i = pos>=0 ? pos : len;
if(i<1) break;
memmove(&buf[i-1], &buf[i], len - i + 1);
if(pos>0) pos--;
else if(!pos && len<=1) pos = -1;
return true;
}
case SDLK_LEFT:
{
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
if(pos > 0) pos--;
else if(pos < 0) pos = len-1;
else if(pos < 0) pos = (int)strlen(buf)-1;
break;
}
case SDLK_RIGHT:
{
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
if(pos>=0 && ++pos >= len) pos = -1;
if(pos>=0 && ++pos>=(int)strlen(buf)) pos = -1;
break;
}
case SDLK_v:
extern void pasteconsole(char *dst);
#ifdef __APPLE__
#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA)
#else
#define MOD_KEYS (KMOD_LCTRL|KMOD_RCTRL)
#endif
#ifdef __APPLE__
#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA)
#else
#define MOD_KEYS (KMOD_LCTRL|KMOD_RCTRL)
#endif
if(SDL_GetModState()&MOD_KEYS)
{
pasteconsole(buf);
return true;
}
// fall through
default:
{
if(unicode)
{
std::string s(buf);
char tmp[5] = { 0, 0, 0, 0, 0 };
utf8::append(unicode, tmp);
std::string newchar(tmp);
int len = utf8::distance(s.begin(), s.end());
if(max && (int)len>=max) break;
if(s.length() + newchar.length() < sizeof(buf))
{
if(pos < 0)
{
s.append(newchar);
}
else
{
std::string::iterator first = s.begin();
utf8::advance(first, pos + 1, s.end());
s.insert(first, newchar.begin(), newchar.end());
pos++;
}
strcpy(buf, s.c_str());
return true;
}
size_t len = strlen(buf);
if(max && (int)len>=max) break;
if(len+1 < sizeof(buf))
{
if(pos < 0) buf[len] = unicode;
else
{
memmove(&buf[pos+1], &buf[pos], len - pos);
buf[pos++] = unicode;
}
buf[len+1] = '\0';
return true;
}
}
break;
}
}
return false;
}
};
/** WIP ALERT */
struct textinputbuffer_wip
{
string buf;
int pos, max;
textinputbuffer_wip() : pos(-1), max(0)
{
buf[0] = '\0';
}
bool key(int code, bool isdown, int unicode)
{
switch(code)
{
case SDLK_RETURN:
case SDLK_KP_ENTER:
break;
case SDLK_HOME:
if(strlen(buf)) pos = 0;
break;
case SDLK_END:
pos = -1;
break;
case SDLK_DELETE:
{
if(pos < 0) break;
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
std::string::iterator first = s.begin();
std::string::iterator second = s.begin();
utf8::advance(first, pos, s.end());
utf8::advance(second, pos + 1, s.end());
s.erase(first, second);
strcpy(buf, s.c_str());
if(pos>=len-1) pos = -1;
return true;
}
case SDLK_BACKSPACE:
{
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
int i = pos>=0 ? pos : len;
if(i<1) break;
std::string::iterator first = s.begin();
std::string::iterator second = s.begin();
utf8::advance(first, i - 1, s.end());
utf8::advance(second, i, s.end());
s.erase(first, second);
strcpy(buf, s.c_str());
if(pos > 0) pos--;
else if(!pos && len <=1 ) pos = -1;
return true;
}
case SDLK_LEFT:
{
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
if(pos > 0) pos--;
else if(pos < 0) pos = len-1;
break;
}
case SDLK_RIGHT:
{
std::string s(buf);
int len = utf8::distance(s.begin(), s.end());
if(pos>=0 && ++pos >= len) pos = -1;
break;
}
case SDLK_v:
extern void pasteconsole(char *dst);
#ifdef __APPLE__
#define MOD_KEYS (KMOD_LMETA|KMOD_RMETA)
#else
#define MOD_KEYS (KMOD_LCTRL|KMOD_RCTRL)
#endif
if(SDL_GetModState()&MOD_KEYS)
{
pasteconsole(buf);
return true;
}
// fall through
default:
{
if(unicode)
{
std::string s(buf);
char tmp[5] = { 0, 0, 0, 0, 0 };
utf8::append(unicode, tmp);
std::string newchar(tmp);
int len = utf8::distance(s.begin(), s.end());
if(max && (int)len>=max) break;
if(s.length() + newchar.length() < sizeof(buf))
{
if(pos < 0)
{
s.append(newchar);
}
else
{
std::string::iterator first = s.begin();
utf8::advance(first, pos + 1, s.end());
s.insert(first, newchar.begin(), newchar.end());
pos++;
}
strcpy(buf, s.c_str());
return true;
}
}
break;
}
+1
View File
@@ -12,6 +12,7 @@
#include "world.h"
#include "i18n.h"
#include "command.h"
#include "extras.h"
#ifndef STANDALONE
#include "vote.h"
+1
View File
@@ -308,6 +308,7 @@ void setspawn(int i, bool on) {
if(ents.inrange(i)) {
ents[i].twice = (ents[i].type == I_GRENADE && ents[i].spawned && on ? true : false);
ents[i].spawned = on;
if (on) ents[i].lastmillis = lastmillis; // to control trypickup spam
}
}
+6 -11
View File
@@ -989,12 +989,12 @@ void distributespawns()
}
}
bool items_blocked = false; // FIXME
bool free_items(int n) // FIXME
bool items_blocked = false;
bool free_items(int n)
{
client *c = clients[n];
int waitspawn = min(c->ping,200) + c->state.lastrespawn;
return !items_blocked && (arenaroundstartmillis + waitspawn < gamemillis) ;
int waitspawn = min(c->ping,200) + c->state.spawn;
return !items_blocked && (waitspawn < gamemillis);
}
void arenacheck()
@@ -1011,7 +1011,7 @@ void arenacheck()
if(clients[i]->isonrightmap && team_isactive(clients[i]->team))
sendspawn(clients[i]);
}
items_blocked = false; // FIXME
items_blocked = false;
return;
}
@@ -2417,11 +2417,6 @@ void process(ENetPacket *packet, int sender, int chan)
pickup.type = GE_PICKUP;
pickup.pickup.ent = n;
}
else
{ // no nade pickup during last two seconds of lss intermission
if(sents.inrange(n) && sents[n].spawned)
sendf(sender, 1, "ri2", SV_ITEMSPAWN, n);
}
break;
}
@@ -2504,7 +2499,7 @@ void process(ENetPacket *packet, int sender, int chan)
int ls = getint(p), gunselect = getint(p);
if((cl->state.state!=CS_ALIVE && cl->state.state!=CS_DEAD) || ls!=cl->state.lifesequence || cl->state.lastspawn<0 || gunselect<0 || gunselect>=NUMGUNS) break;
cl->state.lastspawn = -1;
cl->state.lastrespawn = gamemillis;
cl->state.spawn = gamemillis;
cl->state.state = CS_ALIVE;
cl->state.gunselect = gunselect;
QUEUE_BUF(
+2 -2
View File
@@ -118,7 +118,7 @@ struct clientstate : playerstate
{
vec o;
int state;
int lastdeath, lastspawn, lastrespawn, lifesequence;
int lastdeath, lastspawn, spawn, lifesequence;
int lastshot;
projectilestate<8> grenades;
int akimbomillis;
@@ -156,7 +156,7 @@ struct clientstate : playerstate
o = vec(-1e10f, -1e10f, -1e10f);
lastdeath = 0;
lastspawn = -1;
lastrespawn = 0;
spawn = 0;
lastshot = 0;
akimbomillis = 0;
scoped = false;
+1
View File
@@ -1,3 +1,4 @@
float pow2(float x)
{
return x*x;