Differences From Artifact [4ad5c2248e]:
- File
src/sound.m
— part of check-in
[6b85eefc85]
at
2025-03-23 02:47:40
on branch trunk
— Remove loop[ijkl]
They confused clang-format a lot. (user: js, size: 4228) [annotate] [blame] [check-ins using]
To Artifact [24cd809ba3]:
- File src/sound.m — part of check-in [d7661be1b1] at 2025-03-23 19:40:00 on branch trunk — Clean up identifiers, use blocks for commands (user: js, size: 4222) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 9 | #include "cube.h" #import "DynamicEntity.h" #include <SDL_mixer.h> VARP(soundvol, 0, 255, 255); VARP(musicvol, 0, 128, 255); bool nosound = false; | > | 1 2 3 4 5 6 7 8 9 10 | #include "cube.h" #import "Command.h" #import "DynamicEntity.h" #include <SDL_mixer.h> VARP(soundvol, 0, 255, 255); VARP(musicvol, 0, 128, 255); bool nosound = false; |
︙ | ︙ | |||
43 44 45 46 47 48 49 | conoutf(@"sound init failed (SDL_mixer): %s", (size_t)Mix_GetError()); nosound = true; } Mix_AllocateChannels(MAXCHAN); } | < | < | < < | < | < | 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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | conoutf(@"sound init failed (SDL_mixer): %s", (size_t)Mix_GetError()); nosound = true; } Mix_AllocateChannels(MAXCHAN); } COMMAND(music, ARG_1STR, (^(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); } } })) static OFMutableData *samples; static OFMutableArray<OFString *> *snames; COMMAND(registersound, ARG_1EST, ^int(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; }) void cleansound() { if (nosound) return; stopsound(); |
︙ | ︙ | |||
212 213 214 215 216 217 218 | if (loc) newsoundloc(chan, loc); updatechanvol(chan, loc); } | < | < | < | 207 208 209 210 211 212 213 214 215 216 | if (loc) newsoundloc(chan, loc); updatechanvol(chan, loc); } COMMAND(sound, ARG_1INT, ^(int n) { playsound(n, NULL); }) |