Migrate strings for all commands
FossilOrigin-Name: 11889bf242c1346514823c710dcf369bebc7339b24399f2c6369b146c644996c
This commit is contained in:
parent
63a6c72954
commit
039efe612d
7 changed files with 89 additions and 93 deletions
|
@ -46,48 +46,34 @@
|
|||
((void(__cdecl *)())_function)();
|
||||
break;
|
||||
case ARG_1STR:
|
||||
if (isDown) {
|
||||
@autoreleasepool {
|
||||
if (isDown)
|
||||
((void(__cdecl *)(OFString *))_function)(
|
||||
@(arguments[1]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ARG_2STR:
|
||||
if (isDown) {
|
||||
@autoreleasepool {
|
||||
((void(__cdecl *)(
|
||||
OFString *, OFString *))_function)(
|
||||
if (isDown)
|
||||
((void(__cdecl *)(OFString *, OFString *))_function)(
|
||||
@(arguments[1]), @(arguments[2]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ARG_3STR:
|
||||
if (isDown) {
|
||||
@autoreleasepool {
|
||||
((void(__cdecl *)(OFString *, OFString *,
|
||||
OFString *))_function)(@(arguments[1]),
|
||||
@(arguments[2]), @(arguments[3]));
|
||||
}
|
||||
}
|
||||
if (isDown)
|
||||
((void(__cdecl *)(
|
||||
OFString *, OFString *, OFString *))_function)(
|
||||
@(arguments[1]), @(arguments[2]), @(arguments[3]));
|
||||
break;
|
||||
case ARG_5STR:
|
||||
if (isDown) {
|
||||
@autoreleasepool {
|
||||
((void(__cdecl *)(OFString *, OFString *,
|
||||
OFString *, OFString *,
|
||||
OFString *))_function)(@(arguments[1]),
|
||||
@(arguments[2]), @(arguments[3]),
|
||||
@(arguments[4]), @(arguments[5]));
|
||||
}
|
||||
}
|
||||
if (isDown)
|
||||
((void(__cdecl *)(OFString *, OFString *, OFString *,
|
||||
OFString *, OFString *))_function)(@(arguments[1]),
|
||||
@(arguments[2]), @(arguments[3]), @(arguments[4]),
|
||||
@(arguments[5]));
|
||||
break;
|
||||
case ARG_DOWN:
|
||||
((void(__cdecl *)(bool))_function)(isDown);
|
||||
break;
|
||||
case ARG_DWN1:
|
||||
((void(__cdecl *)(bool, char *))_function)(
|
||||
isDown, arguments[1]);
|
||||
((void(__cdecl *)(bool, OFString *))_function)(
|
||||
isDown, @(arguments[1]));
|
||||
break;
|
||||
case ARG_1EXP:
|
||||
if (isDown)
|
||||
|
@ -101,13 +87,14 @@
|
|||
break;
|
||||
case ARG_1EST:
|
||||
if (isDown)
|
||||
return ((int(__cdecl *)(char *))_function)(
|
||||
arguments[1]);
|
||||
return ((int(__cdecl *)(OFString *))_function)(
|
||||
@(arguments[1]));
|
||||
break;
|
||||
case ARG_2EST:
|
||||
if (isDown)
|
||||
return ((int(__cdecl *)(char *, char *))_function)(
|
||||
arguments[1], arguments[2]);
|
||||
return (
|
||||
(int(__cdecl *)(OFString *, OFString *))_function)(
|
||||
@(arguments[1]), @(arguments[2]));
|
||||
break;
|
||||
case ARG_VARI:
|
||||
if (isDown) {
|
||||
|
@ -121,7 +108,7 @@
|
|||
break;
|
||||
strcat_s(r, " ");
|
||||
}
|
||||
((void(__cdecl *)(char *))_function)(r);
|
||||
((void(__cdecl *)(OFString *))_function)(@(r));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -166,16 +166,18 @@ trydisconnect()
|
|||
|
||||
string ctext;
|
||||
void
|
||||
toserver(const char *text)
|
||||
toserver(OFString *text)
|
||||
{
|
||||
conoutf(@"%s:\f %s", player1->name, text);
|
||||
strn0cpy(ctext, text, 80);
|
||||
@autoreleasepool {
|
||||
conoutf(@"%s:\f %@", player1->name, text);
|
||||
strn0cpy(ctext, text.UTF8String, 80);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
echo(char *text)
|
||||
echo(OFString *text)
|
||||
{
|
||||
conoutf(@"%s", text);
|
||||
conoutf(@"%@", text);
|
||||
}
|
||||
|
||||
COMMAND(echo, ARG_VARI)
|
||||
|
|
|
@ -204,9 +204,10 @@ sendmap(OFString *mapname)
|
|||
enet_packet_resize(packet, p - start);
|
||||
sendpackettoserv(packet);
|
||||
conoutf(@"sending map %@ to server...", mapname);
|
||||
sprintf_sd(msg)(
|
||||
"[map %@ uploaded to server, \"getmap\" to receive it]",
|
||||
mapname);
|
||||
OFString *msg =
|
||||
[OFString stringWithFormat:@"[map %@ uploaded to server, "
|
||||
@"\"getmap\" to receive it]",
|
||||
mapname];
|
||||
toserver(msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -463,40 +463,49 @@ whilea(OFString *cond_, OFString *body_)
|
|||
}
|
||||
|
||||
void
|
||||
onrelease(bool on, char *body)
|
||||
onrelease(bool on, OFString *body)
|
||||
{
|
||||
if (!on)
|
||||
execute(body);
|
||||
if (!on) {
|
||||
std::unique_ptr<char> copy(strdup(body.UTF8String));
|
||||
execute(copy.get());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
concat(char *s)
|
||||
concat(OFString *s)
|
||||
{
|
||||
@autoreleasepool {
|
||||
alias(@"s", @(s));
|
||||
alias(@"s", s);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
concatword(char *s)
|
||||
concatword(OFString *s)
|
||||
{
|
||||
for (char *a = s, *b = s; *a = *b; b++)
|
||||
if (*a != ' ')
|
||||
a++;
|
||||
// The original used this code which does nothing:
|
||||
// for (char *a = s, *b = s; *a = *b; b++)
|
||||
// if (*a != ' ')
|
||||
// a++;
|
||||
concat(s);
|
||||
}
|
||||
|
||||
int
|
||||
listlen(char *a)
|
||||
listlen(OFString *a_)
|
||||
{
|
||||
@autoreleasepool {
|
||||
const char *a = a_.UTF8String;
|
||||
|
||||
if (!*a)
|
||||
return 0;
|
||||
|
||||
int n = 0;
|
||||
while (*a)
|
||||
if (*a++ == ' ')
|
||||
n++;
|
||||
|
||||
return n + 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
at(OFString *s_, OFString *pos)
|
||||
|
@ -508,7 +517,7 @@ at(OFString *s_, OFString *pos)
|
|||
|
||||
loopi(n) s += strspn(s += strcspn(s, " \0"), " ");
|
||||
s[strcspn(s, " \0")] = 0;
|
||||
concat(s);
|
||||
concat(@(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,9 +588,9 @@ gt(int a, int b)
|
|||
COMMANDN(>, gt, ARG_2EXP)
|
||||
|
||||
int
|
||||
strcmpa(char *a, char *b)
|
||||
strcmpa(OFString *a, OFString *b)
|
||||
{
|
||||
return strcmp(a, b) == 0;
|
||||
return [a isEqual:b];
|
||||
}
|
||||
COMMANDN(strcmp, strcmpa, ARG_2EST)
|
||||
|
||||
|
|
|
@ -128,9 +128,9 @@ bindkey(OFString *key, OFString *action)
|
|||
COMMANDN(bind, bindkey, ARG_2STR)
|
||||
|
||||
void
|
||||
saycommand(const char *init) // turns input to the command line on or off
|
||||
saycommand(OFString *init) // turns input to the command line on or off
|
||||
{
|
||||
saycommandon = (init != NULL);
|
||||
saycommandon = (init != nil);
|
||||
if (saycommandon)
|
||||
SDL_StartTextInput();
|
||||
else
|
||||
|
@ -139,10 +139,10 @@ saycommand(const char *init) // turns input to the command line on or off
|
|||
if (!editmode)
|
||||
Cube.sharedInstance.repeatsKeys = saycommandon;
|
||||
|
||||
if (!init)
|
||||
init = "";
|
||||
if (init == nil)
|
||||
init = @"";
|
||||
|
||||
commandbuf = [[OFMutableString alloc] initWithUTF8String:init];
|
||||
commandbuf = [init mutableCopy];
|
||||
}
|
||||
COMMAND(saycommand, ARG_VARI)
|
||||
|
||||
|
@ -255,7 +255,7 @@ keypress(int code, bool isdown, int cooked)
|
|||
commandbuf.UTF8String));
|
||||
execute(copy.get(), true);
|
||||
} else
|
||||
toserver(commandbuf.UTF8String);
|
||||
toserver(commandbuf);
|
||||
}
|
||||
saycommand(NULL);
|
||||
} else if (code == SDLK_ESCAPE) {
|
||||
|
|
|
@ -71,7 +71,7 @@ extern void setarraypointers();
|
|||
extern void localservertoclient(uchar *buf, int len);
|
||||
extern void connects(OFString *servername);
|
||||
extern void disconnect(int onlyclean = 0, int async = 0);
|
||||
extern void toserver(const char *text);
|
||||
extern void toserver(OFString *text);
|
||||
extern void addmsg(int rel, int num, int type, ...);
|
||||
extern bool multiplayer();
|
||||
extern bool allowedittoggle();
|
||||
|
|
|
@ -131,11 +131,8 @@ vector<FSOUND_SAMPLE *> samples;
|
|||
static OFMutableArray<OFString *> *snames;
|
||||
|
||||
int
|
||||
registersound(char *name_)
|
||||
registersound(OFString *name)
|
||||
{
|
||||
@autoreleasepool {
|
||||
OFString *name = @(name_);
|
||||
|
||||
int i = 0;
|
||||
for (OFString *iter in snames) {
|
||||
if ([iter isEqual:name])
|
||||
|
@ -149,9 +146,9 @@ registersound(char *name_)
|
|||
|
||||
[snames addObject:name];
|
||||
samples.add(NULL);
|
||||
|
||||
return samples.length() - 1;
|
||||
}
|
||||
}
|
||||
COMMAND(registersound, ARG_1EST)
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue