Cube  Diff

Differences From Artifact [ee786c999c]:

To Artifact [b06342c3fd]:


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
108
109
music(OFString *name)
{
	if (nosound)
		return;
	stopsound();
	if (soundvol && musicvol) {
		@autoreleasepool {
			string sn;
			strcpy_s(sn, "packages/");


			strcat_s(sn, name.UTF8String);
#ifdef USE_MIXER
			if (mod = Mix_LoadMUS(path(sn))) {

				Mix_PlayMusic(mod, -1);
				Mix_VolumeMusic((musicvol * MAXVOL) / 255);
			}
#else
			if (mod = FMUSIC_LoadSong(path(sn))) {

				FMUSIC_PlaySong(mod);
				FMUSIC_SetMasterVolume(mod, musicvol);
			} else if (stream = FSOUND_Stream_Open(

			               path(sn), FSOUND_LOOP_NORMAL, 0, 0)) {
				int chan =
				    FSOUND_Stream_Play(FSOUND_FREE, stream);
				if (chan >= 0) {
					FSOUND_SetVolume(
					    chan, (musicvol * MAXVOL) / 255);
					FSOUND_SetPaused(chan, false);
				}







|
|
>
>
|

|
>




|
>



>
|







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
108
109
110
111
112
113
114
music(OFString *name)
{
	if (nosound)
		return;
	stopsound();
	if (soundvol && musicvol) {
		@autoreleasepool {
			OFString *path =
			    [OFString stringWithFormat:@"packages/%@", name];
			OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
			    IRIByAppendingPathComponent:path];

#ifdef USE_MIXER
			if (mod = Mix_LoadMUS(
			        IRI.fileSystemRepresentation.UTF8String)) {
				Mix_PlayMusic(mod, -1);
				Mix_VolumeMusic((musicvol * MAXVOL) / 255);
			}
#else
			if (mod = FMUSIC_LoadSong(
			        IRI.fileSystemRepresentation.UTF8String)) {
				FMUSIC_PlaySong(mod);
				FMUSIC_SetMasterVolume(mod, musicvol);
			} else if (stream = FSOUND_Stream_Open(
			               IRI.fileSystemRepresentation.UTF8String,
			               FSOUND_LOOP_NORMAL, 0, 0)) {
				int chan =
				    FSOUND_Stream_Play(FSOUND_FREE, stream);
				if (chan >= 0) {
					FSOUND_SetVolume(
					    chan, (musicvol * MAXVOL) / 255);
					FSOUND_SetPaused(chan, false);
				}
226
227
228
229
230
231
232
233
234

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
	lastsoundmillis = lastmillis;
	if (soundsatonce > 5)
		return; // avoid bursts of sounds with heavy packetloss
		        // and in sp
	if (n < 0 || n >= samples.length()) {
		conoutf(@"unregistered sound: %d", n);
		return;
	};


	if (!samples[n]) {

		sprintf_sd(buf)("packages/sounds/%s.wav", snames[n]);



#ifdef USE_MIXER
		samples[n] = Mix_LoadWAV(path(buf));

#else
		samples[n] =
		    FSOUND_Sample_Load(n, path(buf), FSOUND_LOOP_OFF, 0, 0);

#endif

		if (!samples[n]) {
			conoutf(@"failed to load sample: %s", buf);

			return;
		};
	};



#ifdef USE_MIXER
	int chan = Mix_PlayChannel(-1, samples[n], 0);
#else
	int chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[n], NULL, true);
#endif
	if (chan < 0)
		return;
	if (loc)
		newsoundloc(chan, loc);
	updatechanvol(chan, loc);
#ifndef USE_MIXER
	FSOUND_SetPaused(chan, false);
#endif
};


void
sound(int n)
{
	playsound(n, NULL);
}
COMMAND(sound, ARG_1INT)







<
|
>

>
|
>
>


|
>

|
|
>



|
>

<
<
>
>














<
>







231
232
233
234
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
	lastsoundmillis = lastmillis;
	if (soundsatonce > 5)
		return; // avoid bursts of sounds with heavy packetloss
		        // and in sp
	if (n < 0 || n >= samples.length()) {
		conoutf(@"unregistered sound: %d", n);
		return;

	}

	if (!samples[n]) {
		OFString *path = [OFString
		    stringWithFormat:@"packages/sounds/%s.wav", snames[n]];
		OFIRI *IRI = [Cube.sharedInstance.gameDataIRI
		    IRIByAppendingPathComponent:path];

#ifdef USE_MIXER
		samples[n] =
		    Mix_LoadWAV(IRI.fileSystemRepresentation.UTF8String);
#else
		samples[n] = FSOUND_Sample_Load(n,
		    IRI.fileSystemRepresentation.UTF8String, FSOUND_LOOP_OFF, 0,
		    0);
#endif

		if (!samples[n]) {
			conoutf(@"failed to load sample: %s",
			    IRI.string.UTF8String);
			return;


		}
	}

#ifdef USE_MIXER
	int chan = Mix_PlayChannel(-1, samples[n], 0);
#else
	int chan = FSOUND_PlaySoundEx(FSOUND_FREE, samples[n], NULL, true);
#endif
	if (chan < 0)
		return;
	if (loc)
		newsoundloc(chan, loc);
	updatechanvol(chan, loc);
#ifndef USE_MIXER
	FSOUND_SetPaused(chan, false);
#endif

}

void
sound(int n)
{
	playsound(n, NULL);
}
COMMAND(sound, ARG_1INT)