Skip to content

Commit

Permalink
svn r6410
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Nov 28, 2020
1 parent 84d7fe4 commit 75de54a
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 14 deletions.
66 changes: 66 additions & 0 deletions src/engine/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,31 @@ void substr(char *s, int *start, int *count, int *numargs)
}
COMMAND(substr, "siiN");

void chopstr(char *s, int *lim, char *ellipsis)
{
int len = strlen(s), maxlen = abs(*lim);
if(len > maxlen)
{
int elen = strlen(ellipsis);
maxlen = max(maxlen, elen);
char *chopped = newstring(maxlen);
if(*lim < 0)
{
memcpy(chopped, ellipsis, elen);
memcpy(&chopped[elen], &s[len - (maxlen - elen)], maxlen - elen);
}
else
{
memcpy(chopped, s, maxlen - elen);
memcpy(&chopped[maxlen - elen], ellipsis, elen);
}
chopped[maxlen] = '\0';
commandret->setstr(chopped);
}
else result(s);
}
COMMAND(chopstr, "sis");

void sublist(const char *s, int *skip, int *count, int *numargs)
{
int offset = max(*skip, 0), len = *numargs >= 3 ? max(*count, 0) : -1;
Expand Down Expand Up @@ -2709,6 +2734,21 @@ void looplist(ident *id, const char *list, const uint *body)
}
COMMAND(looplist, "rse");

void loopsublist(ident *id, const char *list, int *skip, int *count, const uint *body)
{
if(id->type!=ID_ALIAS) return;
identstack stack;
int n = 0, offset = max(*skip, 0), len = *count < 0 ? INT_MAX : offset + *count;
for(const char *s = list, *start, *end; parselist(s, start, end) && n < len; n++) if(n >= offset)
{
char *val = newstring(start, end-start);
setiter(*id, val, stack);
execute(body);
}
if(n) poparg(*id);
}
COMMAND(loopsublist, "rsiie");

void looplistconc(ident *id, const char *list, const uint *body, bool space)
{
if(id->type!=ID_ALIAS) return;
Expand Down Expand Up @@ -3136,6 +3176,32 @@ ICOMMAND(codestr, "i", (int *i), { char *s = newstring(1); s[0] = char(*i); s[1]
ICOMMAND(struni, "si", (char *s, int *i), intret(*i > 0 ? (memchr(s, 0, *i) ? 0 : cube2uni(s[*i])) : cube2uni(s[0])));
ICOMMAND(unistr, "i", (int *i), { char *s = newstring(1); s[0] = uni2cube(*i); s[1] = '\0'; stringret(s); });

int naturalsort(const char *a, const char *b)
{
for(;;)
{
int ac = *a, bc = *b;
if(!ac) return bc ? -1 : 0;
else if(!bc) return 1;
else if(isdigit(ac) && isdigit(bc))
{
while(*a == '0') a++;
while(*b == '0') b++;
const char *a0 = a, *b0 = b;
while(isdigit(*a)) a++;
while(isdigit(*b)) b++;
int alen = a - a0, blen = b - b0;
if(alen != blen) return alen - blen;
int n = memcmp(a0, b0, alen);
if(n < 0) return -1;
else if(n > 0) return 1;
}
else if(ac != bc) return ac - bc;
else { ++a; ++b; }
}
}
ICOMMAND(naturalsort, "ss", (char *a, char *b), intret(naturalsort(a,b)<=0));

#define STRMAPCOMMAND(name, map) \
ICOMMAND(name, "s", (char *s), \
{ \
Expand Down
4 changes: 2 additions & 2 deletions src/engine/octaedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ struct undolist
};

undolist undos, redos;
VARP(undomegs, 0, 5, 100); // bounded by n megs
VARP(undomegs, 0, 8, 100); // bounded by n megs
int totalundos = 0;

void pruneundos(int maxremain) // bound memory
Expand Down Expand Up @@ -2754,7 +2754,7 @@ COMMAND(editmat, "ss");

extern int menudistance, menuautoclose;

VARP(texguiwidth, 1, 15, 1000);
VARP(texguiwidth, 1, 16, 1000);
VARP(texguiheight, 1, 8, 1000);
VARP(texguitime, 0, 15, 1000);

Expand Down
2 changes: 1 addition & 1 deletion src/fpsgame/capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ struct captureclientmode : clientmode
defformatstring(alias, "base_%d", e->attr2);
const char *name = getalias(alias);
copystring(b.name, name);
b.tag = e->attr2 || name[0] ? e->attr2 : bases.length();
b.tag = e->attr2>0 ? e->attr2 : bases.length();
b.light = e->light;
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/fpsgame/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ namespace game
g.spring();
g.poplist();

g.space(.5);
g.space(.75f);

int numgroups = groupplayers();
loopk(numgroups)
Expand Down Expand Up @@ -338,18 +338,20 @@ namespace game
else
{
g.poplist(); // horizontal
if(k+1<numgroups) g.space(.5);
if(k+1<numgroups) g.space(.75f);
}
}

if(showspectators && spectators.length())
{
g.space(.75f);

if(showclientnum || player1->privilege>=PRIV_MASTER)
{
g.pushlist();

g.pushlist();
g.text("spectator", COL_GRAY, " ");
g.text("spectator", COL_GRAY);
g.strut(12);
loopv(spectators)
{
Expand Down Expand Up @@ -391,7 +393,7 @@ namespace game
}
else
{
g.textf("%d spectator%s", COL_GRAY, " ", spectators.length(), spectators.length()!=1 ? "s" : "");
g.textf("%d spectator%s", COL_GRAY, NULL, spectators.length(), spectators.length()!=1 ? "s" : "");
loopv(spectators)
{
if((i%3)==0)
Expand Down
15 changes: 10 additions & 5 deletions src/fpsgame/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ namespace server
VAR(maxdemos, 0, 5, 25);
VAR(maxdemosize, 0, 16, 31);
VAR(restrictdemos, 0, 1, 1);
VAR(autorecorddemo, 0, 0, 1);
VARF(autorecorddemo, 0, 0, 1, demonextmatch = autorecorddemo!=0);

VAR(restrictpausegame, 0, 1, 1);
VAR(restrictgamespeed, 0, 1, 1);
Expand Down Expand Up @@ -982,10 +982,15 @@ namespace server
loopi(sizeof(team)/sizeof(team[0]))
{
addteaminfo(teamnames[i]);
if(!persistteams) loopvj(team[i])
loopvj(team[i])
{
clientinfo *ci = team[i][j];
if(!strcmp(ci->team, teamnames[i])) continue;
if(persistteams && ci->team[0] && (!smode || smode->canchangeteam(ci, teamnames[i], ci->team)))
{
addteaminfo(ci->team);
continue;
}
copystring(ci->team, teamnames[i], MAXTEAMLEN+1);
sendf(-1, 1, "riisi", N_SETTEAM, ci->clientnum, teamnames[i], -1);
}
Expand Down Expand Up @@ -2048,14 +2053,14 @@ namespace server

sendf(-1, 1, "risii", N_MAPCHANGE, smapname, gamemode, 1);

clearteaminfo();
if(m_teammode) autoteam();

if(m_capture) smode = &capturemode;
else if(m_ctf) smode = &ctfmode;
else if(m_collect) smode = &collectmode;
else smode = NULL;

clearteaminfo();
if(m_teammode) autoteam();

if(m_timed && smapname[0]) sendf(-1, 1, "ri2", N_TIMEUP, gamemillis < gamelimit && !interm ? max((gamelimit - gamemillis)/1000, 1) : 0);
loopv(clients)
{
Expand Down
4 changes: 2 additions & 2 deletions src/xcode/macbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ while [ -n "$1" ]; do
clean)
xcodebuild -project sauerbraten.xcodeproj clean -configuration Release
;;
all)
build)
xcodebuild -project sauerbraten.xcodeproj -configuration Release -alltargets
;;
install)
cp -v build/Release/sauerbraten.app/Contents/MacOS/sauerbraten ../../sauerbraten.app/Contents/MacOS/sauerbraten_universal
chmod +x ../sauerbraten.app/Contents/MacOS/sauerbraten_universal
chmod +x ../../sauerbraten.app/Contents/MacOS/sauerbraten_universal
;;
package)
exec ./package.sh
Expand Down

0 comments on commit 75de54a

Please sign in to comment.