Cube  Diff

Differences From Artifact [2ceb58ac38]:

To Artifact [af1eb7e101]:


48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
	};
	if (stream) {
#ifndef USE_MIXER
		FSOUND_Stream_Close(stream);
#endif
		stream = NULL;
	};
};


VAR(soundbufferlen, 128, 1024, 4096);

void
initsound()
{
	memset(soundlocs, 0, sizeof(soundloc) * MAXCHAN);







<
>







48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
	};
	if (stream) {
#ifndef USE_MIXER
		FSOUND_Stream_Close(stream);
#endif
		stream = NULL;
	};

}

VAR(soundbufferlen, 128, 1024, 4096);

void
initsound()
{
	memset(soundlocs, 0, sizeof(soundloc) * MAXCHAN);
158
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
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
223
224
225
226
227
228

229
230
231
232
233
234
235
		return;
	stopsound();
#ifdef USE_MIXER
	Mix_CloseAudio();
#else
	FSOUND_Close();
#endif
};


VAR(stereo, 0, 1, 1);

void
updatechanvol(int chan, OFVector3D *loc)
{
	int vol = soundvol, pan = 255 / 2;
	if (loc) {
		vdist(dist, v, *loc, player1->o);
		vol -= (int)(dist * 3 * soundvol /
		             255); // simple mono distance attenuation
		if (stereo && (v.x != 0 || v.y != 0)) {
			float yaw = -atan2(v.x, v.y) -
			            player1->yaw *
			                (PI / 180.0f); // relative angle of
			                               // sound along X-Y axis
			pan = int(255.9f * (0.5 * sin(yaw) +
			                       0.5f)); // range is from 0 (left)
			                               // to 255 (right)
		};
	};
	vol = (vol * MAXVOL) / 255;
#ifdef USE_MIXER
	Mix_Volume(chan, vol);
	Mix_SetPanning(chan, 255 - pan, pan);
#else
	FSOUND_SetVolume(chan, vol);
	FSOUND_SetPan(chan, pan);
#endif
};


void
newsoundloc(int chan, OFVector3D *loc)
{
	assert(chan >= 0 && chan < MAXCHAN);
	soundlocs[chan].loc = *loc;
	soundlocs[chan].inuse = true;
};


void
updatevol()
{
	if (nosound)
		return;
	loopi(MAXCHAN) if (soundlocs[i].inuse)
	{
#ifdef USE_MIXER
		if (Mix_Playing(i))
#else
		if (FSOUND_IsPlaying(i))
#endif
			updatechanvol(i, &soundlocs[i].loc);
		else
			soundlocs[i].inuse = false;
	};
};



void
playsoundc(int n)
{
	addmsg(0, 2, SV_SOUND, n);
	playsound(n);
};


int soundsatonce = 0, lastsoundmillis = 0;

void
playsound(int n, OFVector3D *loc)
{
	if (nosound)







<
>










|


|
|
|
|
|
|










<
>







<
>
















<
<
>
>






<
>







158
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
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
223
224
225
226
227

228
229
230
231
232
233
234
235
		return;
	stopsound();
#ifdef USE_MIXER
	Mix_CloseAudio();
#else
	FSOUND_Close();
#endif

}

VAR(stereo, 0, 1, 1);

void
updatechanvol(int chan, OFVector3D *loc)
{
	int vol = soundvol, pan = 255 / 2;
	if (loc) {
		vdist(dist, v, *loc, player1->o);
		vol -= (int)(dist * 3 * soundvol /
		    255); // simple mono distance attenuation
		if (stereo && (v.x != 0 || v.y != 0)) {
			float yaw = -atan2(v.x, v.y) -
			    player1->yaw *
			        (PI / 180.0f); // relative angle of
			                       // sound along X-Y axis
			pan = int(255.9f *
			    (0.5 * sin(yaw) + 0.5f)); // range is from 0 (left)
			                              // to 255 (right)
		};
	};
	vol = (vol * MAXVOL) / 255;
#ifdef USE_MIXER
	Mix_Volume(chan, vol);
	Mix_SetPanning(chan, 255 - pan, pan);
#else
	FSOUND_SetVolume(chan, vol);
	FSOUND_SetPan(chan, pan);
#endif

}

void
newsoundloc(int chan, OFVector3D *loc)
{
	assert(chan >= 0 && chan < MAXCHAN);
	soundlocs[chan].loc = *loc;
	soundlocs[chan].inuse = true;

}

void
updatevol()
{
	if (nosound)
		return;
	loopi(MAXCHAN) if (soundlocs[i].inuse)
	{
#ifdef USE_MIXER
		if (Mix_Playing(i))
#else
		if (FSOUND_IsPlaying(i))
#endif
			updatechanvol(i, &soundlocs[i].loc);
		else
			soundlocs[i].inuse = false;


	}
}

void
playsoundc(int n)
{
	addmsg(0, 2, SV_SOUND, n);
	playsound(n);

}

int soundsatonce = 0, lastsoundmillis = 0;

void
playsound(int n, OFVector3D *loc)
{
	if (nosound)