Overview
Comment: | Migrate last strings |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b81e2948d74e606b374ad69956719d74 |
User & Date: | js on 2025-03-15 23:42:51 |
Other Links: | manifest | tags |
Context
2025-03-16
| ||
00:05 | Migrate vectors check-in: 853e760619 user: js tags: trunk | |
2025-03-15
| ||
23:42 | Migrate last strings check-in: b81e2948d7 user: js tags: trunk | |
23:10 | Run the run loop check-in: 9e7cb01dd0 user: js tags: trunk | |
Changes
Modified src/console.mm from [fbd5eecbef] to [6b830d51dc].
1 2 3 4 5 6 7 8 9 | // console.cpp: the console buffer, its display, and command line control #include "cube.h" #include <ctype.h> #import "KeyMapping.h" #import "OFString+Cube.h" | > > > | > > | > > > > > > > > | | > > | > > > > > > | | < > | > | | | > | < | | > > | > > > | | | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | // console.cpp: the console buffer, its display, and command line control #include "cube.h" #include <ctype.h> #import "KeyMapping.h" #import "OFString+Cube.h" @interface ConsoleLine: OFObject @property (readonly, copy) OFString *text; @property (readonly) int outtime; - (instancetype)initWithText:(OFString *)text outtime:(int)outtime; @end static OFMutableArray<ConsoleLine *> *conlines; @implementation ConsoleLine - (instancetype)initWithText:(OFString *)text outtime:(int)outtime { self = [super init]; _text = [text copy]; _outtime = outtime; return self; } - (OFString *)description { return _text; } @end 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; } COMMANDN(conskip, setconskip, ARG_1INT) static void conline(OFString *sf, bool highlight) // add a line to the console buffer { OFMutableString *text; // constrain the buffer size if (conlines.count > 100) { text = [conlines.lastObject.text mutableCopy]; [conlines removeLastObject]; } else text = [[OFMutableString alloc] init]; if (highlight) // show line in a different colour, for chat etc. [text appendString:@"\f"]; [text appendString:sf]; if (conlines == nil) conlines = [[OFMutableArray alloc] init]; [conlines insertObject:[[ConsoleLine alloc] initWithText:text outtime:lastmillis] atIndex:0]; puts(text.UTF8String); #ifndef OF_WINDOWS fflush(stdout); #endif } void conoutf(OFConstantString *format, ...) |
︙ | ︙ | |||
70 71 72 73 74 75 76 77 | conline([string substringToIndex:WORDWRAP], n++ != 0); string = [string substringFromIndex:WORDWRAP]; } conline(string, n != 0); } } void | > | | < | > > | | | | > > | | | | | < | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | conline([string substringToIndex:WORDWRAP], n++ != 0); string = [string substringFromIndex:WORDWRAP]; } conline(string, n != 0); } } // render buffer taking into account time & scrolling void renderconsole() { int nd = 0; OFString *refs[ndraw]; size_t i = 0; for (ConsoleLine *conline in conlines) { if (conskip ? i >= conskip - 1 || i >= conlines.count - ndraw : lastmillis - conline.outtime < 20000) { refs[nd++] = conline.text; if (nd == ndraw) break; } i++; } loopj(nd) { draw_text(refs[j], FONTH / 3, (FONTH / 4 * 5) * (nd - j - 1) + FONTH / 3, 2); } } // keymap is defined externally in keymap.cfg static OFMutableArray<KeyMapping *> *keyMappings = nil; |
︙ | ︙ |
Modified src/cube.h from [3f59a3114f] to [8cc717f782].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | // one big bad include file for the whole engine... nasty! #import <ObjFW/ObjFW.h> #define gamma gamma__ #include <SDL2/SDL.h> #undef gamma #include "tools.h" @class DynamicEntity; @interface Cube: OFObject <OFApplicationDelegate> @property (class, readonly, nonatomic) Cube *sharedInstance; @property (readonly, nonatomic) SDL_Window *window; @property (readonly, nonatomic) OFIRI *gameDataIRI, *userDataIRI; | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // one big bad include file for the whole engine... nasty! #import <ObjFW/ObjFW.h> #define gamma gamma__ #include <SDL2/SDL.h> #undef gamma #include "tools.h" #define _MAXDEFSTR 260 @class DynamicEntity; @interface Cube: OFObject <OFApplicationDelegate> @property (class, readonly, nonatomic) Cube *sharedInstance; @property (readonly, nonatomic) SDL_Window *window; @property (readonly, nonatomic) OFIRI *gameDataIRI, *userDataIRI; |
︙ | ︙ |
Modified src/savegamedemo.mm from [8ffa70a39e] to [7c09343b90].
︙ | ︙ | |||
101 102 103 104 105 106 107 | return; } gzwrite(f, (void *)"CUBESAVE", 8); gzputc(f, islittleendian); gzputi(SAVEGAMEVERSION); OFData *data = [player1 dataBySerializing]; gzputi(data.count); | | | | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | return; } gzwrite(f, (void *)"CUBESAVE", 8); gzputc(f, islittleendian); gzputi(SAVEGAMEVERSION); OFData *data = [player1 dataBySerializing]; gzputi(data.count); char map[_MAXDEFSTR] = { 0 }; memcpy(map, getclientmap().UTF8String, min(getclientmap().UTF8StringLength, _MAXDEFSTR - 1)); gzwrite(f, map, _MAXDEFSTR); gzputi(gamemode); gzputi(ents.length()); loopv(ents) gzputc(f, ents[i].spawned); gzwrite(f, data.items, data.count); OFArray<DynamicEntity *> *monsters = getmonsters(); gzputi(monsters.count); |
︙ | ︙ | |||
159 160 161 162 163 164 165 | cStringWithEncoding:OFLocale.encoding], "rb9"); if (!f) { conoutf(@"could not open %@", IRI.string); return; } | > | < | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | cStringWithEncoding:OFLocale.encoding], "rb9"); if (!f) { conoutf(@"could not open %@", IRI.string); return; } char mapname[_MAXDEFSTR] = { 0 }; char buf[8]; gzread(f, buf, 8); if (strncmp(buf, "CUBESAVE", 8)) goto out; if (gzgetc(f) != islittleendian) goto out; // not supporting save->load accross // incompatible architectures simpifies things // a LOT if (gzgeti() != SAVEGAMEVERSION || gzgeti() != DynamicEntity.serializedSize) goto out; gzread(f, mapname, _MAXDEFSTR); nextmode = gzgeti(); @autoreleasepool { // continue below once map has been loaded and client & // server have updated changemap(@(mapname)); } |
︙ | ︙ | |||
449 450 451 452 453 454 455 | DynamicEntity *target = players[democlientnum]; assert(target); int extras; // read additional client side state not present in normal // network stream | | | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | DynamicEntity *target = players[democlientnum]; assert(target); int extras; // read additional client side state not present in normal // network stream if ((extras = gzget())) { target.gunselect = gzget(); target.lastattackgun = gzget(); target.lastaction = scaletime(gzgeti()); target.gunwait = gzgeti(); target.health = gzgeti(); target.armour = gzgeti(); target.armourtype = gzget(); loopi(NUMGUNS) target.ammo[i] = gzget(); target.state = gzget(); target.lastmove = playbacktime; if ((bdamage = gzgeti())) damageblend(bdamage); if ((ddamage = gzgeti())) { gzgetv(dorig); particle_splash(3, ddamage, 1000, dorig); } // FIXME: set more client state here } // insert latest copy of player into history |
︙ | ︙ |
Modified src/serverbrowser.mm from [fe609f090e] to [fbd128e000].
︙ | ︙ | |||
36 37 38 39 40 41 42 | SDL_SemWait(resolversem); @synchronized(ResolverThread.class) { if (resolverqueries.count == 0) continue; _query = resolverqueries.lastObject; | | < | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | SDL_SemWait(resolversem); @synchronized(ResolverThread.class) { if (resolverqueries.count == 0) continue; _query = resolverqueries.lastObject; [resolverqueries removeLastObject]; _starttime = lastmillis; } ENetAddress address = { ENET_HOST_ANY, CUBE_SERVINFO_PORT }; enet_address_set_host(&address, _query.UTF8String); @synchronized(ResolverThread.class) { |
︙ | ︙ | |||
144 145 146 147 148 149 150 | resolvercheck(OFString **name, ENetAddress *address) { @synchronized(ResolverThread.class) { if (resolverresults.count > 0) { ResolverResult *rr = resolverresults.lastObject; *name = rr.query; *address = rr.address; | | < | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | resolvercheck(OFString **name, ENetAddress *address) { @synchronized(ResolverThread.class) { if (resolverresults.count > 0) { ResolverResult *rr = resolverresults.lastObject; *name = rr.query; *address = rr.address; [resolverresults removeLastObject]; return true; } for (size_t i = 0; i < resolverthreads.count; i++) { ResolverThread *rt = resolverthreads[i]; if (rt.query) { |
︙ | ︙ |
Modified src/serverutil.mm from [195e0442e7] to [26cbbdcb4f].
︙ | ︙ | |||
43 44 45 46 47 48 49 | } void sendstring(OFString *t_, uchar *&p) { @autoreleasepool { const char *t = t_.UTF8String; | | > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | } void sendstring(OFString *t_, uchar *&p) { @autoreleasepool { const char *t = t_.UTF8String; for (size_t i = 0; i < _MAXDEFSTR && *t != '\0'; i++) putint(p, *t++); putint(p, 0); } } static const OFString *modenames[] = { @"SP", @"DMSP", |
︙ | ︙ |
Modified src/tools.h from [64ce1d6c09] to [a3d0973ada].
︙ | ︙ | |||
51 52 53 54 55 56 57 | #define loopl(m) loop(l, m) #ifndef OF_WINDOWS # define __cdecl # define _vsnprintf vsnprintf #endif | < < < < < < < < < < < < < < < < < < < < < < < < < | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #define loopl(m) loop(l, m) #ifndef OF_WINDOWS # define __cdecl # define _vsnprintf vsnprintf #endif #define fast_f2nat(val) ((int)(val)) extern void endianswap(void *, int, int); template <class T> struct vector { T *buf; int alen; |
︙ | ︙ |