Cube  Check-in [245efe8045]

Overview
Comment:More string migration
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 245efe8045462b8ece957f5bed9f5543ec761f4506353d571186a7efb469b878
User & Date: js on 2025-03-08 00:58:32
Other Links: manifest | tags
Context
2025-03-08
01:09
Remove memory pool check-in: 0097baa3a7 user: js tags: trunk
00:58
More string migration check-in: 245efe8045 user: js tags: trunk
00:48
Migrate more strings check-in: fa4b03aaca user: js tags: trunk
Changes

Modified src/client.mm from [2cc0559143] to [da4c60f968].

160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
		disconnect();
		return;
	}
	conoutf(@"attempting to disconnect...");
	disconnect(0, !disconnecting);
}

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

void
echo(OFString *text)
{
	conoutf(@"%@", text);
}







|



<
|
|
<







160
161
162
163
164
165
166
167
168
169
170

171
172

173
174
175
176
177
178
179
		disconnect();
		return;
	}
	conoutf(@"attempting to disconnect...");
	disconnect(0, !disconnecting);
}

static OFString *ctext;
void
toserver(OFString *text)
{

	conoutf(@"%s:\f %@", player1->name, text);
	ctext = text;

}

void
echo(OFString *text)
{
	conoutf(@"%@", text);
}
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
269
270
}

int lastupdate = 0, lastping = 0;
OFString *toservermap;
bool senditemstoserver =
    false; // after a map change, since server doesn't have map data

string clientpassword;
void
password(OFString *p)
{
	@autoreleasepool {
		strcpy_s(clientpassword, p.UTF8String);
	}
}
COMMAND(password, ARG_1STR)

bool
netmapstart()
{
	senditemstoserver = true;
	return clienthost != NULL;
};


void
initclientnet()
{
	ctext[0] = 0;
	toservermap = @"";
	clientpassword[0] = 0;
	newname(@"unnamed");
	newteam(@"red");
}

void
sendpackettoserv(void *packet)
{







|



<
|
<








<
>




|

|







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
}

int lastupdate = 0, lastping = 0;
OFString *toservermap;
bool senditemstoserver =
    false; // after a map change, since server doesn't have map data

OFString *clientpassword;
void
password(OFString *p)
{

	clientpassword = p;

}
COMMAND(password, ARG_1STR)

bool
netmapstart()
{
	senditemstoserver = true;
	return clienthost != NULL;

}

void
initclientnet()
{
	ctext = @"";
	toservermap = @"";
	clientpassword = @"";
	newname(@"unnamed");
	newteam(@"red");
}

void
sendpackettoserv(void *packet)
{
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
				putint(p, SV_ITEMLIST);
				if (!m_noitems)
					putitems(p);
				putint(p, -1);
				senditemstoserver = false;
				serveriteminitdone = true;
			}
			if (ctext[0]) // player chat, not flood protected for
			              // now
			{
				packet->flags = ENET_PACKET_FLAG_RELIABLE;
				putint(p, SV_TEXT);
				sendstring(@(ctext), p);
				ctext[0] = 0;
			}
			if (!c2sinit) // tell other clients who I am
			{
				packet->flags = ENET_PACKET_FLAG_RELIABLE;
				c2sinit = true;
				putint(p, SV_INITC2S);
				sendstring(@(player1->name), p);







|
|
<


|
|







321
322
323
324
325
326
327
328
329

330
331
332
333
334
335
336
337
338
339
340
				putint(p, SV_ITEMLIST);
				if (!m_noitems)
					putitems(p);
				putint(p, -1);
				senditemstoserver = false;
				serveriteminitdone = true;
			}
			// player chat, not flood protected for now
			if (ctext.length > 0) {

				packet->flags = ENET_PACKET_FLAG_RELIABLE;
				putint(p, SV_TEXT);
				sendstring(ctext, p);
				ctext = @"";
			}
			if (!c2sinit) // tell other clients who I am
			{
				packet->flags = ENET_PACKET_FLAG_RELIABLE;
				c2sinit = true;
				putint(p, SV_INITC2S);
				sendstring(@(player1->name), p);

Modified src/clients2c.mm from [a718bd08e4] to [a511b2eec3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// client processing of the incoming network stream

#include "cube.h"

extern int clientnum;
extern bool c2sinit, senditemstoserver;
extern OFString *toservermap;
extern string clientpassword;

void
neterr(OFString *s)
{
	conoutf(@"illegal network message (%@)", s);
	disconnect();
}







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// client processing of the incoming network stream

#include "cube.h"

extern int clientnum;
extern bool c2sinit, senditemstoserver;
extern OFString *toservermap;
extern OFString *clientpassword;

void
neterr(OFString *s)
{
	conoutf(@"illegal network message (%@)", s);
	disconnect();
}
85
86
87
88
89
90
91

92

93

94
95
96

97
98
99
100
101
102
103
			toservermap = @"";
			clientnum = cn; // we are now fully connected
			if (!getint(p))
				// we are the first client on this server, set
				// map
				toservermap = getclientmap();
			sgetstr();

			if (text[0] && strcmp(text, clientpassword)) {

				conoutf(@"you need to set the correct password "

				        @"to join this server!");
				disconnect();
				return;

			}
			if (getint(p) == 1)
				conoutf(@"server is FULL, disconnecting..");
			break;
		}

		case SV_POS: // position of another client







>
|
>
|
>
|
|
|
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
			toservermap = @"";
			clientnum = cn; // we are now fully connected
			if (!getint(p))
				// we are the first client on this server, set
				// map
				toservermap = getclientmap();
			sgetstr();
			@autoreleasepool {
				if (text[0] &&
				    strcmp(text, clientpassword.UTF8String)) {
					conoutf(@"you need to set the correct "
					        @"password "
					        @"to join this server!");
					disconnect();
					return;
				}
			}
			if (getint(p) == 1)
				conoutf(@"server is FULL, disconnecting..");
			break;
		}

		case SV_POS: // position of another client

Modified src/weapon.mm from [f70bf0b290] to [a7650f3ece].

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
	if (demoplayback)
		return NULL;
	loopv(players)
	{
		dynent *o = players[i];
		if (!o)
			continue;
		if (intersect(o, player1->o, worldpos)) {
			@autoreleasepool {
				return @(o->name);
			}
		}
	}
	return NULL;
}

const int MAXPROJ = 100;
struct projectile {
	OFVector3D o, to;
	float speed;
	dynent *owner;







|
<
|
|
|
<
|







117
118
119
120
121
122
123
124

125
126
127

128
129
130
131
132
133
134
135
	if (demoplayback)
		return NULL;
	loopv(players)
	{
		dynent *o = players[i];
		if (!o)
			continue;
		if (intersect(o, player1->o, worldpos))

			return @(o->name);
	}


	return nil;
}

const int MAXPROJ = 100;
struct projectile {
	OFVector3D o, to;
	float speed;
	dynent *owner;