Overview
Comment: | Remove last usage of vector |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
08c9d7b0fa8f592b68069fe2444e016d |
User & Date: | js on 2025-03-20 17:12:11 |
Other Links: | manifest | tags |
Context
2025-03-20
| ||
20:11 | Convert all references to pointers in protos.h check-in: c38d75087b user: js tags: trunk | |
17:12 | Remove last usage of vector check-in: 08c9d7b0fa user: js tags: trunk | |
16:39 | Remove non-functional FMOD support check-in: 7e4ba7f32a user: js tags: trunk | |
Changes
Modified src/editing.mm from [2700645c79] to [8eeba4e2ca].
︙ | ︙ | |||
235 236 237 238 239 240 241 | if (selset) { linestyle(GRIDS, 0xFF, 0x40, 0x40); box(sel, (float)selh, (float)selh, (float)selh, (float)selh); } } | | | > | | | | | > > > > > > | > | | > | 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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | if (selset) { linestyle(GRIDS, 0xFF, 0x40, 0x40); box(sel, (float)selh, (float)selh, (float)selh, (float)selh); } } static OFMutableData *undos; // unlimited undo VARP(undomegs, 0, 1, 10); // bounded by n megs void pruneundos(int maxremain) // bound memory { int t = 0; for (ssize_t i = (ssize_t)undos.count - 1; i >= 0; i--) { block *undo = *(block **)[undos itemAtIndex:i]; t += undo->xs * undo->ys * sizeof(sqr); if (t > maxremain) { OFFreeMemory(undo); [undos removeItemAtIndex:i]; } } } void makeundo() { if (undos == nil) undos = [[OFMutableData alloc] initWithItemSize:sizeof(block *)]; block *copy = blockcopy(sel); [undos addItem:©]; pruneundos(undomegs << 20); } void editundo() { EDITMP; if (undos.count == 0) { conoutf(@"nothing more to undo"); return; } block *p = *(block **)undos.lastItem; [undos removeLastItem]; blockpaste(*p); OFFreeMemory(p); } block *copybuf = NULL; void |
︙ | ︙ |
Modified src/protos.h from [79ed2ad413] to [155e863644].
︙ | ︙ | |||
111 112 113 114 115 116 117 | void showscores(bool on); extern void renderscores(); // world extern void setupworld(int factor); extern void empty_world(int factor, bool force); extern void remip(block &b, int level = 0); | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | void showscores(bool on); extern void renderscores(); // world extern void setupworld(int factor); extern void empty_world(int factor, bool force); extern void remip(block &b, int level = 0); extern void remipmore(const block &b, int level = 0); extern int closestent(); extern int findentity(int type, int index = 0); extern void trigger(int tag, int type, bool savegame); extern void resettagareas(); extern void settagareas(); extern Entity *newentity( int x, int y, int z, OFString *what, int v1, int v2, int v3, int v4); // worldlight extern void calclight(); extern void dodynlight(const OFVector3D &vold, const OFVector3D &v, int reach, int strength, DynamicEntity *owner); extern void cleardlights(); extern block *blockcopy(block &b); extern void blockpaste(const block &b); // worldrender extern void render_world(float vx, float vy, float vh, int yaw, int pitch, float widef, int w, int h); // worldocull extern void computeraytable(float vx, float vy); |
︙ | ︙ |
Modified src/rendergl.mm from [81f69c07bf] to [19962c058e].
︙ | ︙ | |||
270 271 272 273 274 275 276 | } int skyoglid; struct strip { int tex, start, num; }; | | > > > > | | > > > > | > | | | | > | | > | | < > | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | } int skyoglid; struct strip { int tex, start, num; }; static OFMutableData *strips; void renderstripssky() { glBindTexture(GL_TEXTURE_2D, skyoglid); const strip *items = (const strip *)strips.items; size_t count = strips.count; for (size_t i = 0; i < count; i++) if (items[i].tex == skyoglid) glDrawArrays( GL_TRIANGLE_STRIP, items[i].start, items[i].num); } void renderstrips() { int lasttex = -1; const strip *items = (const strip *)strips.items; size_t count = strips.count; for (size_t i = 0; i < count; i++) { if (items[i].tex == skyoglid) continue; if (items[i].tex != lasttex) { glBindTexture(GL_TEXTURE_2D, items[i].tex); lasttex = items[i].tex; } glDrawArrays(GL_TRIANGLE_STRIP, items[i].start, items[i].num); } } void overbright(float amount) { if (hasoverbright) glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT, amount); } void addstrip(int tex, int start, int n) { if (strips == nil) strips = [[OFMutableData alloc] initWithItemSize:sizeof(strip)]; strip s = { .tex = tex, .start = start, .num = n }; [strips addItem:&s]; } VARFP(gamma, 30, 100, 300, { float f = gamma / 100.0f; Uint16 ramp[256]; SDL_CalculateGammaRamp(f, ramp); |
︙ | ︙ | |||
430 431 432 433 434 435 436 | int xs, ys; skyoglid = lookuptexture(DEFAULT_SKY, &xs, &ys); resetcubes(); curvert = 0; | | | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | int xs, ys; skyoglid = lookuptexture(DEFAULT_SKY, &xs, &ys); resetcubes(); curvert = 0; [strips removeAllItems]; render_world(player1.o.x, player1.o.y, player1.o.z, (int)player1.yaw, (int)player1.pitch, (float)fov, w, h); finishstrips(); setupworld(); |
︙ | ︙ |
Modified src/sound.mm from [91b933ce07] to [f965fc3ef4].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include "cube.h" #import "DynamicEntity.h" VARP(soundvol, 0, 255, 255); VARP(musicvol, 0, 128, 255); bool nosound = false; #define MAXCHAN 32 #define SOUNDFREQ 22050 struct soundloc { OFVector3D loc; bool inuse; } soundlocs[MAXCHAN]; | > > > < < | < > | < < | 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 | #include "cube.h" #import "DynamicEntity.h" #include <SDL_mixer.h> VARP(soundvol, 0, 255, 255); VARP(musicvol, 0, 128, 255); bool nosound = false; #define MAXCHAN 32 #define SOUNDFREQ 22050 #define MAXVOL MIX_MAX_VOLUME struct soundloc { OFVector3D loc; bool inuse; } soundlocs[MAXCHAN]; static Mix_Music *mod = NULL; void stopsound() { if (nosound) return; if (mod != NULL) { Mix_HaltMusic(); Mix_FreeMusic(mod); mod = NULL; } } VAR(soundbufferlen, 128, 1024, 4096); void initsound() { |
︙ | ︙ | |||
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 | } void music(OFString *name) { if (nosound) return; stopsound(); if (soundvol && musicvol) { name = [name stringByReplacingOccurrencesOfString:@"\\" withString:@"/"]; OFString *path = [OFString stringWithFormat:@"packages/%@", name]; OFIRI *IRI = [Cube.sharedInstance.gameDataIRI IRIByAppendingPathComponent:path]; if ((mod = Mix_LoadMUS( IRI.fileSystemRepresentation.UTF8String)) != NULL) { Mix_PlayMusic(mod, -1); Mix_VolumeMusic((musicvol * MAXVOL) / 255); } } } COMMAND(music, ARG_1STR) | > > < | > > > > | | | 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | } void music(OFString *name) { if (nosound) return; stopsound(); if (soundvol && musicvol) { name = [name stringByReplacingOccurrencesOfString:@"\\" withString:@"/"]; OFString *path = [OFString stringWithFormat:@"packages/%@", name]; OFIRI *IRI = [Cube.sharedInstance.gameDataIRI IRIByAppendingPathComponent:path]; if ((mod = Mix_LoadMUS( IRI.fileSystemRepresentation.UTF8String)) != NULL) { Mix_PlayMusic(mod, -1); Mix_VolumeMusic((musicvol * MAXVOL) / 255); } } } COMMAND(music, ARG_1STR) static OFMutableData *samples; static OFMutableArray<OFString *> *snames; int registersound(OFString *name) { int i = 0; for (OFString *iter in snames) { if ([iter isEqual:name]) return i; i++; } if (snames == nil) snames = [[OFMutableArray alloc] init]; if (samples == nil) samples = [[OFMutableData alloc] initWithItemSize:sizeof(Mix_Chunk *)]; [snames addObject:[name stringByReplacingOccurrencesOfString:@"\\" withString:@"/"]]; Mix_Chunk *sample = NULL; [samples addItem:&sample]; return samples.count - 1; } COMMAND(registersound, ARG_1EST) void cleansound() { if (nosound) |
︙ | ︙ | |||
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | int soundsatonce = 0, lastsoundmillis = 0; void playsound(int n, const OFVector3D *loc) { if (nosound) return; if (!soundvol) return; if (lastmillis == lastsoundmillis) soundsatonce++; else soundsatonce = 1; lastsoundmillis = lastmillis; if (soundsatonce > 5) | > > > > | > | | > | < | | | > > | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 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 | int soundsatonce = 0, lastsoundmillis = 0; void playsound(int n, const OFVector3D *loc) { if (nosound) return; if (!soundvol) return; if (lastmillis == lastsoundmillis) soundsatonce++; else soundsatonce = 1; lastsoundmillis = lastmillis; if (soundsatonce > 5) // avoid bursts of sounds with heavy packetloss and in sp return; if (n < 0 || n >= samples.count) { conoutf(@"unregistered sound: %d", n); return; } Mix_Chunk **sample = (Mix_Chunk **)[samples mutableItemAtIndex:n]; if (*sample == NULL) { OFString *path = [OFString stringWithFormat:@"packages/sounds/%@.wav", snames[n]]; OFIRI *IRI = [Cube.sharedInstance.gameDataIRI IRIByAppendingPathComponent:path]; *sample = Mix_LoadWAV(IRI.fileSystemRepresentation.UTF8String); if (*sample == NULL) { conoutf(@"failed to load sample: %@", IRI.string); return; } } int chan = Mix_PlayChannel(-1, *sample, 0); if (chan < 0) return; if (loc) newsoundloc(chan, loc); updatechanvol(chan, loc); } void sound(int n) { playsound(n, NULL); } COMMAND(sound, ARG_1INT) |
Modified src/tools.h from [a3d0973ada] to [1aee766b5c].
︙ | ︙ | |||
15 16 17 18 19 20 21 | #include <assert.h> #include <limits.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 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 | #include <assert.h> #include <limits.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #import <ObjFW/ObjFW.h> typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) #define rnd(max) (rand() % (max)) #define rndreset() (srand(1)) #define rndtime() \ { \ loopi(lastmillis & 0xF) rnd(i + 1); \ } #define loop(v, m) for (int v = 0; v < (m); v++) #define loopi(m) loop(i, m) #define loopj(m) loop(j, m) #define loopk(m) loop(k, m) #define loopl(m) loop(l, m) #ifndef OF_WINDOWS # define __cdecl #endif #define fast_f2nat(val) ((int)(val)) extern void endianswap(void *, int, int); #endif |
Modified src/world.mm from [ffa7840406] to [742d4e7bcd].
︙ | ︙ | |||
238 239 240 241 242 243 244 | s.y /= 2; s.xs /= 2; s.ys /= 2; remip(s, level + 1); } void | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | s.y /= 2; s.xs /= 2; s.ys /= 2; remip(s, level + 1); } void remipmore(const block &b, int level) { block bb = b; if (bb.x > 1) bb.x--; if (bb.y > 1) bb.y--; if (bb.xs < ssize - 3) |
︙ | ︙ |
Modified src/worldlight.mm from [a6b73ab397] to [5df422a1d9].
︙ | ︙ | |||
258 259 260 261 262 263 264 | for (int x = s.x; x < s.xs + s.x; x++) for (int y = s.y; y < s.ys + s.y; y++) *q++ = *S(x, y); return b; } void | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | for (int x = s.x; x < s.xs + s.x; x++) for (int y = s.y; y < s.ys + s.y; y++) *q++ = *S(x, y); return b; } void blockpaste(const block &b) { sqr *q = (sqr *)((&b) + 1); for (int x = b.x; x < b.xs + b.x; x++) for (int y = b.y; y < b.ys + b.y; y++) *S(x, y) = *q++; remipmore(b); } |