From 7ab817d42038445f392bb97c9dc41a22b6ea77c1 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 8 Mar 2025 00:58:32 +0000 Subject: [PATCH] More string migration FossilOrigin-Name: 245efe8045462b8ece957f5bed9f5543ec761f4506353d571186a7efb469b878 --- src/client.mm | 29 ++++++++++++----------------- src/clients2c.mm | 16 ++++++++++------ src/weapon.mm | 10 ++++------ 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/client.mm b/src/client.mm index 0c2c26d..3f87531 100644 --- a/src/client.mm +++ b/src/client.mm @@ -164,14 +164,12 @@ trydisconnect() disconnect(0, !disconnecting); } -string ctext; +static OFString *ctext; void toserver(OFString *text) { - @autoreleasepool { - conoutf(@"%s:\f %@", player1->name, text); - strn0cpy(ctext, text.UTF8String, 80); - } + conoutf(@"%s:\f %@", player1->name, text); + ctext = text; } void @@ -238,13 +236,11 @@ OFString *toservermap; bool senditemstoserver = false; // after a map change, since server doesn't have map data -string clientpassword; +OFString *clientpassword; void password(OFString *p) { - @autoreleasepool { - strcpy_s(clientpassword, p.UTF8String); - } + clientpassword = p; } COMMAND(password, ARG_1STR) @@ -253,14 +249,14 @@ netmapstart() { senditemstoserver = true; return clienthost != NULL; -}; +} void initclientnet() { - ctext[0] = 0; + ctext = @""; toservermap = @""; - clientpassword[0] = 0; + clientpassword = @""; newname(@"unnamed"); newteam(@"red"); } @@ -329,13 +325,12 @@ c2sinfo(dynent *d) // send update to the server senditemstoserver = false; serveriteminitdone = true; } - if (ctext[0]) // player chat, not flood protected for - // now - { + // 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[0] = 0; + sendstring(ctext, p); + ctext = @""; } if (!c2sinit) // tell other clients who I am { diff --git a/src/clients2c.mm b/src/clients2c.mm index 4636550..35d05d2 100644 --- a/src/clients2c.mm +++ b/src/clients2c.mm @@ -5,7 +5,7 @@ extern int clientnum; extern bool c2sinit, senditemstoserver; extern OFString *toservermap; -extern string clientpassword; +extern OFString *clientpassword; void neterr(OFString *s) @@ -89,11 +89,15 @@ localservertoclient( // map toservermap = getclientmap(); sgetstr(); - if (text[0] && strcmp(text, clientpassword)) { - conoutf(@"you need to set the correct password " - @"to join this server!"); - disconnect(); - return; + @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.."); diff --git a/src/weapon.mm b/src/weapon.mm index 7d673eb..1b10247 100644 --- a/src/weapon.mm +++ b/src/weapon.mm @@ -121,13 +121,11 @@ playerincrosshair() dynent *o = players[i]; if (!o) continue; - if (intersect(o, player1->o, worldpos)) { - @autoreleasepool { - return @(o->name); - } - } + if (intersect(o, player1->o, worldpos)) + return @(o->name); } - return NULL; + + return nil; } const int MAXPROJ = 100;