Cube  Check-in [5ef6284dcf]

Overview
Comment:Migrate more strings
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5ef6284dcf38a9367998d964d81cf7cf8340d76c87d58efaa350c9d930ccb416
User & Date: js on 2025-03-07 19:55:34
Other Links: manifest | tags
Context
2025-03-07
21:02
Clean up identifiers check-in: d35fd65699 user: js tags: trunk
19:55
Migrate more strings check-in: 5ef6284dcf user: js tags: trunk
2025-03-06
01:56
Migrate more strings check-in: 142095b08f user: js tags: trunk
Changes

Modified src/client.mm from [ea465722d3] to [434fc9c95a].

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
	}
	conoutf(@"attempting to disconnect...");
	disconnect(0, !disconnecting);
}

string ctext;
void
toserver(char *text)
{
	conoutf(@"%s:\f %s", player1->name, text);
	strn0cpy(ctext, text, 80);
}

void
echo(char *text)







|







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
	}
	conoutf(@"attempting to disconnect...");
	disconnect(0, !disconnecting);
}

string ctext;
void
toserver(const char *text)
{
	conoutf(@"%s:\f %s", player1->name, text);
	strn0cpy(ctext, text, 80);
}

void
echo(char *text)

Modified src/command.mm from [2baac4db66] to [b47ac34d19].

507
508
509
510
511
512
513
514
515




516
517
518
519
520
521

522
523

524
525
526
527

528
529
530
531

532
533
534
535
536

537

538
539

540
541
542
543
544
545
546
void
resetcomplete()
{
	completesize = 0;
}

void
complete(char *s)
{




	if (*s != '/') {
		string t;
		strcpy_s(t, s);
		strcpy_s(s, "/");
		strcat_s(s, t);
	}

	if (!s[1])
		return;

	if (!completesize) {
		completesize = (int)strlen(s) - 1;
		completeidx = 0;
	}

	__block int idx = 0;
	[idents enumerateKeysAndObjectsUsingBlock:^(
	    OFString *name, Ident *ident, bool *stop) {
		if (strncmp(ident.name.UTF8String, s + 1, completesize) == 0 &&

		    idx++ == completeidx) {
			strcpy_s(s, "/");
			strcat_s(s, ident.name.UTF8String);
		}
	}];

	completeidx++;

	if (completeidx >= idx)
		completeidx = 0;

}

bool
execfile(OFString *cfgfile)
{
	@autoreleasepool {
		OFMutableData *data;







|

>
>
>
>
|
|
|
|
|
|
>
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
|
>
|
>
|
|
>







507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
void
resetcomplete()
{
	completesize = 0;
}

void
complete(OFString *s_)
{
	@autoreleasepool {
		std::unique_ptr<char> copy(strdup(s_.UTF8String));
		char *s = copy.get();

		if (*s != '/') {
			string t;
			strcpy_s(t, s);
			strcpy_s(s, "/");
			strcat_s(s, t);
		}

		if (!s[1])
			return;

		if (!completesize) {
			completesize = strlen(s) - 1;
			completeidx = 0;
		}

		__block int idx = 0;
		[idents enumerateKeysAndObjectsUsingBlock:^(
		    OFString *name, Ident *ident, bool *stop) {
			if (strncmp(ident.name.UTF8String, s + 1,
			        completesize) == 0 &&
			    idx++ == completeidx) {
				strcpy_s(s, "/");
				strcat_s(s, ident.name.UTF8String);
			}
		}];

		completeidx++;

		if (completeidx >= idx)
			completeidx = 0;
	}
}

bool
execfile(OFString *cfgfile)
{
	@autoreleasepool {
		OFMutableData *data;

Modified src/console.mm from [979d6ed7fb] to [635cf832c8].

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
vector<cline> conlines;

const int ndraw = 5;
const int WORDWRAP = 80;
int conskip = 0;

bool saycommandon = false;
string commandbuf;

void
setconskip(int n)
{
	conskip += n;
	if (conskip < 0)
		conskip = 0;







|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
vector<cline> conlines;

const int ndraw = 5;
const int WORDWRAP = 80;
int conskip = 0;

bool saycommandon = false;
static OFMutableString *commandbuf;

void
setconskip(int n)
{
	conskip += n;
	if (conskip < 0)
		conskip = 0;
124
125
126
127
128
129
130
131
132
133
134
135
136
137

138
139

140
141
142

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

158
159

160
161
162
163
164
165
166
167
168
169
170
	}

	conoutf(@"unknown key \"%@\"", key);
}
COMMANDN(bind, bindkey, ARG_2STR)

void
saycommand(char *init) // turns input to the command line on or off
{
	saycommandon = (init != NULL);
	if (saycommandon)
		SDL_StartTextInput();
	else
		SDL_StopTextInput();

	if (!editmode)
		Cube.sharedInstance.repeatsKeys = saycommandon;

	if (!init)
		init = "";
	strcpy_s(commandbuf, init);

}
COMMAND(saycommand, ARG_VARI)

void
mapmsg(OFString *s)
{
	@autoreleasepool {
		strn0cpy(hdr.maptitle, s.UTF8String, 128);
	}
}
COMMAND(mapmsg, ARG_1STR)

void
pasteconsole()
{

	char *cb = SDL_GetClipboardText();
	strcat_s(commandbuf, cb);

}

static OFMutableArray<OFString *> *vhistory;
int histpos = 0;

void
history(int n)
{
	static bool rec = false;

	if (!rec && n >= 0 && n < vhistory.count) {







|






>


>


|
>















>
|
<
>



|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171
172
173
174
	}

	conoutf(@"unknown key \"%@\"", key);
}
COMMANDN(bind, bindkey, ARG_2STR)

void
saycommand(const char *init) // turns input to the command line on or off
{
	saycommandon = (init != NULL);
	if (saycommandon)
		SDL_StartTextInput();
	else
		SDL_StopTextInput();

	if (!editmode)
		Cube.sharedInstance.repeatsKeys = saycommandon;

	if (!init)
		init = "";

	commandbuf = [[OFMutableString alloc] initWithUTF8String:init];
}
COMMAND(saycommand, ARG_VARI)

void
mapmsg(OFString *s)
{
	@autoreleasepool {
		strn0cpy(hdr.maptitle, s.UTF8String, 128);
	}
}
COMMAND(mapmsg, ARG_1STR)

void
pasteconsole()
{
	@autoreleasepool {
		[commandbuf appendString:@(SDL_GetClipboardText())];

	}
}

static OFMutableArray<OFString *> *vhistory;
static int histpos = 0;

void
history(int n)
{
	static bool rec = false;

	if (!rec && n >= 0 && n < vhistory.count) {
185
186
187
188
189
190
191
192

193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228

229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254


255
256
257



258
259
260
261
262
263
264
265
266
267
268
		if (isdown) {
			switch (code) {
			case SDLK_RETURN:
				break;

			case SDLK_BACKSPACE:
			case SDLK_LEFT: {
				for (int i = 0; commandbuf[i]; i++)

					if (!commandbuf[i + 1])
						commandbuf[i] = 0;
				resetcomplete();
				break;
			}

			case SDLK_UP:
				if (histpos) {
					@autoreleasepool {
						strcpy_s(commandbuf,
						    vhistory[--histpos]
						        .UTF8String);
					}
				}
				break;

			case SDLK_DOWN:
				if (histpos < vhistory.count) {
					@autoreleasepool {
						strcpy_s(commandbuf,
						    vhistory[histpos++]
						        .UTF8String);
					}
				}
				break;

			case SDLK_TAB:
				complete(commandbuf);
				break;

			case SDLK_v:
				if (SDL_GetModState() &
				    (KMOD_LCTRL | KMOD_RCTRL)) {
					pasteconsole();
					return;
				};


			default:
				resetcomplete();
				if (cooked) {
					char add[] = {(char)cooked, 0};
					strcat_s(commandbuf, add);
				}
			}
		} else {
			if (code == SDLK_RETURN) {
				if (commandbuf[0]) {
					@autoreleasepool {
						OFString *cmdbuf =
						    @(commandbuf);

						if (vhistory == nil)
							vhistory =
							    [[OFMutableArray
							        alloc] init];

						if (vhistory.count == 0 ||
						    ![vhistory.lastObject
						        isEqual:cmdbuf]) {
							// cap this?
							[vhistory
							    addObject:cmdbuf];


						}
					}
					histpos = vhistory.count;



					if (commandbuf[0] == '/')
						execute(commandbuf, true);
					else
						toserver(commandbuf);
				}
				saycommand(NULL);
			} else if (code == SDLK_ESCAPE) {
				saycommand(NULL);
			}
		}
	} else if (!menukey(code, isdown)) {







|
>
|
|





|
<
|
|
<
<
<



|
<
|
|
<
<
<











<
>



|
<
|
<



|

<
<
<







|


|
>
>



>
>
>
|
|
|
|







189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205

206
207



208
209
210
211

212
213



214
215
216
217
218
219
220
221
222
223
224

225
226
227
228
229

230

231
232
233
234
235



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
		if (isdown) {
			switch (code) {
			case SDLK_RETURN:
				break;

			case SDLK_BACKSPACE:
			case SDLK_LEFT: {
				[commandbuf
				    deleteCharactersInRange:
				        OFMakeRange(commandbuf.length - 1, 1)];

				resetcomplete();
				break;
			}

			case SDLK_UP:
				if (histpos)

					commandbuf =
					    [vhistory[--histpos] mutableCopy];



				break;

			case SDLK_DOWN:
				if (histpos < vhistory.count)

					commandbuf =
					    [vhistory[histpos++] mutableCopy];



				break;

			case SDLK_TAB:
				complete(commandbuf);
				break;

			case SDLK_v:
				if (SDL_GetModState() &
				    (KMOD_LCTRL | KMOD_RCTRL)) {
					pasteconsole();
					return;

				}

			default:
				resetcomplete();
				if (cooked)

					[commandbuf appendFormat:@"%c", cooked];

			}
		} else {
			if (code == SDLK_RETURN) {
				if (commandbuf.length > 0) {
					@autoreleasepool {



						if (vhistory == nil)
							vhistory =
							    [[OFMutableArray
							        alloc] init];

						if (vhistory.count == 0 ||
						    ![vhistory.lastObject
						        isEqual:commandbuf]) {
							// cap this?
							[vhistory
							    addObject:
							        [commandbuf
							            copy]];
						}
					}
					histpos = vhistory.count;
					if ([commandbuf hasPrefix:@"/"]) {
						std::unique_ptr<char> copy(
						    strdup(
						        commandbuf.UTF8String));
						execute(copy.get(), true);
					} else
						toserver(commandbuf.UTF8String);
				}
				saycommand(NULL);
			} else if (code == SDLK_ESCAPE) {
				saycommand(NULL);
			}
		}
	} else if (!menukey(code, isdown)) {
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
				execute(temp, isdown);
				return;
			}
		}
	}
}

char *
getcurcommand()
{
	return saycommandon ? commandbuf : NULL;
}

void
writebinds(OFStream *stream)
{
	for (KeyMapping *mapping in keyMappings)
		if (mapping.action.length > 0)
			[stream writeFormat:@"bind \"%@\" [%@]\n", mapping.name,
			        mapping.action];
}







|













274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
				execute(temp, isdown);
				return;
			}
		}
	}
}

OFString *
getcurcommand()
{
	return saycommandon ? commandbuf : NULL;
}

void
writebinds(OFStream *stream)
{
	for (KeyMapping *mapping in keyMappings)
		if (mapping.action.length > 0)
			[stream writeFormat:@"bind \"%@\" [%@]\n", mapping.name,
			        mapping.action];
}

Modified src/protos.h from [bd326cd759] to [6d021108a0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// protos for ALL external functions in cube...

// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
    void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(char *p, bool down = true);
extern void exec(OFString *cfgfile);
extern bool execfile(OFString *cfgfile);
extern void resetcomplete();
extern void complete(char *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();

// console
extern void keypress(int code, bool isdown, int cooked);
extern void renderconsole();
extern void conoutf(OFConstantString *format, ...);
extern char *getcurcommand();
extern void writebinds(OFStream *stream);

// init
extern void enqueueInit(void (^init)(void));
extern void processInitQueue(void);

// menus













|








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// protos for ALL external functions in cube...

// command
extern int variable(OFString *name, int min, int cur, int max, int *storage,
    void (*fun)(), bool persist);
extern void setvar(OFString *name, int i);
extern int getvar(OFString *name);
extern bool identexists(OFString *name);
extern bool addcommand(OFString *name, void (*fun)(), int narg);
extern int execute(char *p, bool down = true);
extern void exec(OFString *cfgfile);
extern bool execfile(OFString *cfgfile);
extern void resetcomplete();
extern void complete(OFString *s);
extern void alias(OFString *name, OFString *action);
extern OFString *getalias(OFString *name);
extern void writecfg();

// console
extern void keypress(int code, bool isdown, int cooked);
extern void renderconsole();
extern void conoutf(OFConstantString *format, ...);
extern OFString *getcurcommand();
extern void writebinds(OFStream *stream);

// init
extern void enqueueInit(void (^init)(void));
extern void processInitQueue(void);

// menus
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
extern void finishstrips();
extern void setarraypointers();

// client
extern void localservertoclient(uchar *buf, int len);
extern void connects(OFString *servername);
extern void disconnect(int onlyclean = 0, int async = 0);
extern void toserver(char *text);
extern void addmsg(int rel, int num, int type, ...);
extern bool multiplayer();
extern bool allowedittoggle();
extern void sendpackettoserv(void *packet);
extern void gets2c();
extern void c2sinfo(dynent *d);
extern void neterr(OFString *s);







|







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
extern void finishstrips();
extern void setarraypointers();

// client
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 addmsg(int rel, int num, int type, ...);
extern bool multiplayer();
extern bool allowedittoggle();
extern void sendpackettoserv(void *packet);
extern void gets2c();
extern void c2sinfo(dynent *d);
extern void neterr(OFString *s);

Modified src/renderextras.mm from [9a987704e6] to [a953917ec3].

362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
		if (dblend < 0)
			dblend = 0;
	}

	glEnable(GL_TEXTURE_2D);

	@autoreleasepool {
		char *command = getcurcommand();
		char *player = playerincrosshair();

		if (command)
			draw_textf(@"> %s_", 20, 1570, 2, command);
		else if (closeent[0])
			draw_text(@(closeent), 20, 1570, 2);
		else if (player)
			draw_text(@(player), 20, 1570, 2);
	}

	renderscores();







|



|







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
		if (dblend < 0)
			dblend = 0;
	}

	glEnable(GL_TEXTURE_2D);

	@autoreleasepool {
		OFString *command = getcurcommand();
		char *player = playerincrosshair();

		if (command)
			draw_textf(@"> %@_", 20, 1570, 2, command);
		else if (closeent[0])
			draw_text(@(closeent), 20, 1570, 2);
		else if (player)
			draw_text(@(player), 20, 1570, 2);
	}

	renderscores();