Overview
Comment: | Clean up variables |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
5e43ae9916e0f61b00913c7f5c72f934 |
User & Date: | js on 2025-03-07 21:16:47 |
Other Links: | manifest | tags |
Context
2025-03-07
| ||
22:30 | Migrate strings for all commands check-in: 11889bf242 user: js tags: trunk | |
21:16 | Clean up variables check-in: 5e43ae9916 user: js tags: trunk | |
21:02 | Clean up identifiers check-in: d35fd65699 user: js tags: trunk | |
Changes
Modified src/Variable.h from [c2a873c551] to [d1b2d68346].
1 2 3 4 5 6 7 | #import "Identifier.h" OF_ASSUME_NONNULL_BEGIN @interface Variable : Identifier @property (readonly, nonatomic) int min, max; @property (readonly, nonatomic) int *storage; | | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #import "Identifier.h" OF_ASSUME_NONNULL_BEGIN @interface Variable : Identifier @property (readonly, nonatomic) int min, max; @property (readonly, nonatomic) int *storage; @property (readonly, nonatomic) void (*__cdecl function)(); @property (readonly, nonatomic) bool persisted; - (instancetype)initWithName:(OFString *)name OF_UNAVAILABLE; - (instancetype)initWithName:(OFString *)name min:(int)min max:(int)max storage:(int *)storage function:(void (*__cdecl)())function persisted:(bool)persisted; - (void)printValue; - (void)setValue:(int)value; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/Variable.m [f42a4c7759] to src/Variable.mm [a7099f1853].
1 2 3 4 5 6 7 | #import "Variable.h" @implementation Variable - (instancetype)initWithName:(OFString *)name min:(int)min max:(int)max storage:(int *)storage | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | #import "Variable.h" #include "cube.h" @implementation Variable - (instancetype)initWithName:(OFString *)name min:(int)min max:(int)max storage:(int *)storage function:(void (*__cdecl)())function persisted:(bool)persisted { self = [super initWithName:name]; _min = min; _max = max; _storage = storage; _function = function; _persisted = persisted; return self; } - (void)printValue { conoutf(@"%@ = %d", self.name, *_storage); } - (void)setValue:(int)value { bool outOfRange = false; if (_min > _max) { conoutf(@"variable is read-only"); return; } if (value < _min) { value = _min; outOfRange = true; } if (value > _max) { value = _max; outOfRange = true; } if (outOfRange) conoutf(@"valid range for %@ is %d..%d", self.name, _min, _max); *_storage = value; if (_function != NULL) // call trigger function if available _function(); } @end |
Modified src/commands.mm from [e0ed2b9cbb] to [645f04d656].
︙ | ︙ | |||
239 240 241 242 243 244 245 | isDown:isdown]; } else if ([identifier isKindOfClass:[Variable class]]) { // game defined variables if (isdown) { if (!w[1][0]) | < < < < < < < < | < < < < < | < < < | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | isDown:isdown]; } else if ([identifier isKindOfClass:[Variable class]]) { // game defined variables if (isdown) { if (!w[1][0]) [identifier printValue]; else [identifier setValue:ATOI( w[1])]; } } else if ([identifier isKindOfClass:[Alias class]]) { // alias, also used as functions and // (global) variables for (int i = 1; i < numargs; i++) { @autoreleasepool { |
︙ | ︙ |
Modified src/meson.build from [4579a2b4bb] to [b573376159].
1 2 3 4 5 6 7 8 9 10 11 | executable('client', [ 'Alias.m', 'Command.mm', 'Cube.mm', 'Identifier.m', 'KeyMapping.m', 'MD2.mm', 'MapModelInfo.m', 'Menu.m', 'MenuItem.m', | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | executable('client', [ 'Alias.m', 'Command.mm', 'Cube.mm', 'Identifier.m', 'KeyMapping.m', 'MD2.mm', 'MapModelInfo.m', 'Menu.m', 'MenuItem.m', 'Variable.mm', 'client.mm', 'clientextras.mm', 'clientgame.mm', 'clients2c.mm', 'commands.mm', 'console.mm', 'editing.mm', |
︙ | ︙ |