Cube  Diff

Differences From Artifact [93eb0a5b3c]:

To Artifact [432ff899cb]:


1
2
3
4

5
6
7
8
9
10
11
1
2
3

4
5
6
7
8
9
10
11



-
+







#include "cube.h"

#import "Command.h"
#import "DynamicEntity.h"
#import "Player.h"

#include <SDL_mixer.h>

VARP(soundvol, 0, 255, 255);
VARP(musicvol, 0, 128, 255);
bool nosound = false;

109
110
111
112
113
114
115
116

117
118
119
120
121
122
123
124
125
126


127
128
129
130
131
132
133
109
110
111
112
113
114
115

116
117
118
119
120
121
122
123
124


125
126
127
128
129
130
131
132
133







-
+








-
-
+
+








static void
updatechanvol(int chan, const OFVector3D *loc)
{
	int vol = soundvol, pan = 255 / 2;

	if (loc) {
		OFVector3D origin = player1.origin;
		OFVector3D origin = Player.player1.origin;
		float dist = OFDistanceOfVectors3D(origin, *loc);
		OFVector3D v = OFSubtractVectors3D(origin, *loc);

		// simple mono distance attenuation
		vol -= (int)(dist * 3 * soundvol / 255);

		if (stereo && (v.x != 0 || v.y != 0)) {
			// relative angle of sound along X-Y axis
			float yaw =
			    -atan2(v.x, v.y) - player1.yaw * (PI / 180.0f);
			float yaw = -atan2(v.x, v.y) -
			    Player.player1.yaw * (PI / 180.0f);
			// range is from 0 (left) to 255 (right)
			pan = (int)(255.9f * (0.5 * sin(yaw) + 0.5f));
		}
	}

	vol = (vol * MAXVOL) / 255;
	Mix_Volume(chan, vol);