void Animation::loadAll()
{
-#define DECLARE_ANIM(id, file, height, attack, ...) if (id < loadable_anim_end) animations.emplace_back(file, height, attack);
+#define DECLARE_ANIM(id, file, height, attack, ...) \
+ if (id < loadable_anim_end) \
+ animations.emplace_back(file, height, attack);
#include "Animation.def"
#undef DECLARE_ANIM
}
funpackf(tfile, "Bf Bf Bf", &weapontarget.x, &weapontarget.y, &weapontarget.z);
}
-Animation::Animation():
- height(lowheight),
- attack(neutral),
- numjoints(0)
+Animation::Animation()
+ : height(lowheight)
+ , attack(neutral)
+ , numjoints(0)
{
}
/* EFFECT
* load an animation from file
*/
-Animation::Animation(const std::string& filename, anim_height_type aheight, anim_attack_type aattack):
- Animation()
+Animation::Animation(const std::string& filename, anim_height_type aheight, anim_attack_type aattack)
+ : Animation()
{
- FILE *tfile;
+ FILE* tfile;
int numframes;
unsigned i;
LOGFUNC;
// Changing the filename into something the OS can understand
- std::string filepath = Folders::getResourcePath("Animations/"+filename);
+ std::string filepath = Folders::getResourcePath("Animations/" + filename);
LOG(std::string("Loading animation...") + filepath);
Game::LoadingScreen();
// read file in binary mode
- tfile = Folders::openMandatoryFile( filepath, "rb" );
+ tfile = Folders::openMandatoryFile(filepath, "rb");
// read numframes, joints to know how much memory to allocate
funpackf(tfile, "Bi Bi", &numframes, &numjoints);
#include "Utils/binio.h"
-Joint::Joint() :
- blurred(0),
- length(0),
- mass(0),
- lower(false),
- hasparent(false),
- locked(false),
- modelnum(0),
- visible(false),
- parent(nullptr),
- sametwist(false),
- label(head),
- hasgun(0),
- delay(0)
+Joint::Joint()
+ : blurred(0)
+ , length(0)
+ , mass(0)
+ , lower(false)
+ , hasparent(false)
+ , locked(false)
+ , modelnum(0)
+ , visible(false)
+ , parent(nullptr)
+ , sametwist(false)
+ , label(head)
+ , hasgun(0)
+ , delay(0)
{
}
extern float multiplier;
extern bool freeze;
-Muscle::Muscle() :
- length(0),
- targetlength(0),
- parent1(0),
- parent2(0),
- maxlength(0),
- minlength(0),
- type(boneconnect),
- visible(false),
- rotate1(0), rotate2(0), rotate3(0),
- lastrotate1(0), lastrotate2(0), lastrotate3(0),
- oldrotate1(0), oldrotate2(0), oldrotate3(0),
- newrotate1(0), newrotate2(0), newrotate3(0),
+Muscle::Muscle()
+ : length(0)
+ , targetlength(0)
+ , parent1(0)
+ , parent2(0)
+ , maxlength(0)
+ , minlength(0)
+ , type(boneconnect)
+ , visible(false)
+ , rotate1(0)
+ , rotate2(0)
+ , rotate3(0)
+ , lastrotate1(0)
+ , lastrotate2(0)
+ , lastrotate3(0)
+ , oldrotate1(0)
+ , oldrotate2(0)
+ , oldrotate3(0)
+ , newrotate1(0)
+ , newrotate2(0)
+ , newrotate3(0)
+ ,
strength(0)
{
}
}
-
/* EFFECT
* sets strength, length,
* parent1->position, parent2->position,
#include "Animation/Animation.hpp"
#include "Audio/openal_wrapper.hpp"
#include "Game.hpp"
-#include "Utils/Folders.hpp"
#include "Tutorial.hpp"
+#include "Utils/Folders.hpp"
extern float multiplier;
extern float gravity;
extern int whichjointstartarray[26];
extern int whichjointendarray[26];
-Skeleton::Skeleton() :
- selected(0),
- id(0),
- num_models(0),
- clothes(false),
- spinny(false),
- skinsize(0),
- checkdelay(0),
- longdead(0),
- broken(false),
- free(0),
- oldfree(0),
- freetime(0),
- freefall(false)
+Skeleton::Skeleton()
+ : selected(0)
+ , id(0)
+ , num_models(0)
+ , clothes(false)
+ , spinny(false)
+ , skinsize(0)
+ , checkdelay(0)
+ , longdead(0)
+ , broken(false)
+ , free(0)
+ , oldfree(0)
+ , freetime(0)
+ , freefall(false)
{
memset(forwardjoints, 0, sizeof(forwardjoints));
memset(lowforwardjoints, 0, sizeof(lowforwardjoints));
* Person/Person::DoStuff
* Person/IKHelper
*/
-float Skeleton::DoConstraints(XYZ *coords, float *scale)
+float Skeleton::DoConstraints(XYZ* coords, float* scale)
{
const float elasticity = .3;
XYZ bounceness;
joints[i].position = joints[i].position + joints[i].velocity * multiplier;
switch (joints[i].label) {
- case head:
- groundlevel = .8;
- break;
- case righthand:
- case rightwrist:
- case rightelbow:
- case lefthand:
- case leftwrist:
- case leftelbow:
- groundlevel = .2;
- break;
- default:
- groundlevel = .15;
- break;
+ case head:
+ groundlevel = .8;
+ break;
+ case righthand:
+ case rightwrist:
+ case rightelbow:
+ case lefthand:
+ case leftwrist:
+ case leftelbow:
+ groundlevel = .2;
+ break;
+ default:
+ groundlevel = .15;
+ break;
}
joints[i].position.y -= groundlevel;
joints[i].velocity = joints[i].oldvelocity;
}
-
if (joints[i].locked == 0)
if (findLengthfast(&joints[i].velocity) < 1)
joints[i].locked = 1;
} else if (findLengthfast(&bounceness) > 500)
Sprite::MakeSprite(cloudsprite, joints[i].position * (*scale) + *coords, joints[i].velocity * .06, terrainlight.x, terrainlight.y, terrainlight.z, .5, .2);
-
joints[i].position.y = (terrain.getHeight(joints[i].position.x * (*scale) + coords->x, joints[i].position.z * (*scale) + coords->z) + groundlevel - coords->y) / (*scale);
if (longdead > 100)
broken = 1;
}
joints[i].velocity += bounceness * elasticity;
-
if (!joints[i].locked)
if (findLengthfast(&joints[i].velocity) < 1) {
joints[i].locked = 1;
}
multiplier = tempmult;
-
for (unsigned int m = 0; m < terrain.patchobjects[whichpatchx][whichpatchz].size(); m++) {
unsigned int k = terrain.patchobjects[whichpatchx][whichpatchz][m];
if (Object::objects[k]->possible) {
for (i = 0; i < joints.size(); i++) {
switch (joints[i].label) {
- case head:
- groundlevel = .8;
- break;
- case righthand:
- case rightwrist:
- case rightelbow:
- case lefthand:
- case leftwrist:
- case leftelbow:
- groundlevel = .2;
- break;
- default:
- groundlevel = .15;
- break;
+ case head:
+ groundlevel = .8;
+ break;
+ case righthand:
+ case rightwrist:
+ case rightelbow:
+ case lefthand:
+ case leftwrist:
+ case leftelbow:
+ groundlevel = .2;
+ break;
+ default:
+ groundlevel = .15;
+ break;
}
joints[i].position.y += groundlevel;
joints[i].mass = 1;
* USES:
* Person/Person::DoStuff
*/
-void Skeleton::DoGravity(float *scale)
+void Skeleton::DoGravity(float* scale)
{
for (unsigned i = 0; i < joints.size(); i++) {
if (
- (
- ((joints[i].label != leftknee) && (joints[i].label != rightknee)) ||
- (lowforward.y > -.1) ||
- (joints[i].mass < 5)
- ) && (
- ((joints[i].label != leftelbow) && (joints[i].label != rightelbow)) ||
- (forward.y < .3)
- )
- ) {
+ (
+ ((joints[i].label != leftknee) && (joints[i].label != rightknee)) ||
+ (lowforward.y > -.1) ||
+ (joints[i].mass < 5)) &&
+ (((joints[i].label != leftelbow) && (joints[i].label != rightelbow)) ||
+ (forward.y < .3))) {
joints[i].velocity.y += gravity * multiplier / (*scale);
}
}
const int label1 = muscles[which].parent1->label;
const int label2 = muscles[which].parent2->label;
switch (label1) {
- case head:
- fwd = specialforward[0];
- break;
- case rightshoulder:
- case rightelbow:
- case rightwrist:
- case righthand:
- fwd = specialforward[1];
- break;
- case leftshoulder:
- case leftelbow:
- case leftwrist:
- case lefthand:
- fwd = specialforward[2];
- break;
- case righthip:
- case rightknee:
- case rightankle:
- case rightfoot:
- fwd = specialforward[3];
- break;
- case lefthip:
- case leftknee:
- case leftankle:
- case leftfoot:
- fwd = specialforward[4];
- break;
- default:
- if (muscles[which].parent1->lower)
- fwd = lowforward;
- else
- fwd = forward;
- break;
+ case head:
+ fwd = specialforward[0];
+ break;
+ case rightshoulder:
+ case rightelbow:
+ case rightwrist:
+ case righthand:
+ fwd = specialforward[1];
+ break;
+ case leftshoulder:
+ case leftelbow:
+ case leftwrist:
+ case lefthand:
+ fwd = specialforward[2];
+ break;
+ case righthip:
+ case rightknee:
+ case rightankle:
+ case rightfoot:
+ fwd = specialforward[3];
+ break;
+ case lefthip:
+ case leftknee:
+ case leftankle:
+ case leftfoot:
+ fwd = specialforward[4];
+ break;
+ default:
+ if (muscles[which].parent1->lower)
+ fwd = lowforward;
+ else
+ fwd = forward;
+ break;
}
if (animation == hanganim) {
* load skeleton
* takes filenames for three skeleton files and various models
*/
-void Skeleton::Load(const std::string& filename, const std::string& lowfilename, const std::string& clothesfilename,
- const std::string& modelfilename, const std::string& model2filename,
+void Skeleton::Load(const std::string& filename, const std::string& lowfilename, const std::string& clothesfilename,
+ const std::string& modelfilename, const std::string& model2filename,
const std::string& model3filename, const std::string& model4filename,
const std::string& model5filename, const std::string& model6filename,
const std::string& model7filename, const std::string& modellowfilename,
const std::string& modelclothesfilename, bool clothes)
{
GLfloat M[16];
- FILE *tfile;
+ FILE* tfile;
float lSize;
int j, num_joints, num_muscles;
// load skeleton
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
// read num_joints
funpackf(tfile, "Bi", &num_joints);
// load ???
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(lowfilename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(lowfilename), "rb");
// skip joints section
fseek(tfile, sizeof(num_joints), SEEK_CUR);
for (int i = 0; i < num_joints; i++) {
// skip joint info
- lSize = sizeof(XYZ)
- + sizeof(float)
- + sizeof(float)
- + 1 //sizeof(bool)
- + 1 //sizeof(bool)
- + sizeof(int)
- + 1 //sizeof(bool)
- + 1 //sizeof(bool)
- + sizeof(int)
- + sizeof(int)
- + 1 //sizeof(bool)
+ lSize = sizeof(XYZ) + sizeof(float) + sizeof(float) + 1 //sizeof(bool)
+ + 1 //sizeof(bool)
+ + sizeof(int) + 1 //sizeof(bool)
+ + 1 //sizeof(bool)
+ + sizeof(int) + sizeof(int) + 1 //sizeof(bool)
+ sizeof(int);
fseek(tfile, lSize, SEEK_CUR);
}
for (int i = 0; i < num_muscles; i++) {
// skip muscle info
- lSize = sizeof(float)
- + sizeof(float)
- + sizeof(float)
- + sizeof(float)
- + sizeof(float)
- + sizeof(int);
+ lSize = sizeof(float) + sizeof(float) + sizeof(float) + sizeof(float) + sizeof(float) + sizeof(int);
fseek(tfile, lSize, SEEK_CUR);
muscles[i].loadVerticesLow(tfile, modellow.vertexNum);
// skip more stuff
lSize = 1; //sizeof(bool);
- fseek ( tfile, lSize, SEEK_CUR);
+ fseek(tfile, lSize, SEEK_CUR);
lSize = sizeof(int);
- fseek ( tfile, lSize, SEEK_CUR);
- fseek ( tfile, lSize, SEEK_CUR);
+ fseek(tfile, lSize, SEEK_CUR);
+ fseek(tfile, lSize, SEEK_CUR);
}
for (j = 0; j < num_muscles; j++) {
// load clothes
if (clothes) {
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(clothesfilename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(clothesfilename), "rb");
// skip num_joints
fseek(tfile, sizeof(num_joints), SEEK_CUR);
for (int i = 0; i < num_joints; i++) {
// skip joint info
- lSize = sizeof(XYZ)
- + sizeof(float)
- + sizeof(float)
- + 1 //sizeof(bool)
- + 1 //sizeof(bool)
- + sizeof(int)
- + 1 //sizeof(bool)
- + 1 //sizeof(bool)
- + sizeof(int)
- + sizeof(int)
- + 1 //sizeof(bool)
+ lSize = sizeof(XYZ) + sizeof(float) + sizeof(float) + 1 //sizeof(bool)
+ + 1 //sizeof(bool)
+ + sizeof(int) + 1 //sizeof(bool)
+ + 1 //sizeof(bool)
+ + sizeof(int) + sizeof(int) + 1 //sizeof(bool)
+ sizeof(int);
fseek(tfile, lSize, SEEK_CUR);
}
for (int i = 0; i < num_muscles; i++) {
// skip muscle info
- lSize = sizeof(float)
- + sizeof(float)
- + sizeof(float)
- + sizeof(float)
- + sizeof(float)
- + sizeof(int);
+ lSize = sizeof(float) + sizeof(float) + sizeof(float) + sizeof(float) + sizeof(float) + sizeof(int);
fseek(tfile, lSize, SEEK_CUR);
muscles[i].loadVerticesClothes(tfile, modelclothes.vertexNum);
// skip more stuff
lSize = 1; //sizeof(bool);
- fseek ( tfile, lSize, SEEK_CUR);
+ fseek(tfile, lSize, SEEK_CUR);
lSize = sizeof(int);
- fseek ( tfile, lSize, SEEK_CUR);
- fseek ( tfile, lSize, SEEK_CUR);
+ fseek(tfile, lSize, SEEK_CUR);
+ fseek(tfile, lSize, SEEK_CUR);
}
// ???
#include "Audio/openal_wrapper.hpp"
#include "Utils/Folders.hpp"
-struct OPENAL_SAMPLE *samp[sounds_count];
+struct OPENAL_SAMPLE* samp[sounds_count];
extern XYZ envsound[30];
extern float envsoundvol[30];
int channels[100];
-static const char *sound_data[sounds_count] = {
+static const char* sound_data[sounds_count] = {
#define DECLARE_SOUND(id, filename) filename,
#include "Sounds.def"
#undef DECLARE_SOUND
static int snd_mode(int snd)
{
switch (snd) {
- case alarmsound:
- case consolefailsound:
- case consolesuccesssound:
- case firestartsound:
- case fireendsound:
- return OPENAL_2D;
- default:
- return OPENAL_HW3D;
+ case alarmsound:
+ case consolefailsound:
+ case consolesuccesssound:
+ case firestartsound:
+ case fireendsound:
+ return OPENAL_2D;
+ default:
+ return OPENAL_HW3D;
}
}
numenvsounds++;
}
-void emit_sound_at(int soundid, const XYZ &pos, float vol)
+void emit_sound_at(int soundid, const XYZ& pos, float vol)
{
- PlaySoundEx (soundid, samp[soundid], NULL, true);
- OPENAL_3D_SetAttributes_ (channels[soundid], pos);
- OPENAL_SetVolume (channels[soundid], vol);
- OPENAL_SetPaused (channels[soundid], false);
+ PlaySoundEx(soundid, samp[soundid], NULL, true);
+ OPENAL_3D_SetAttributes_(channels[soundid], pos);
+ OPENAL_SetVolume(channels[soundid], vol);
+ OPENAL_SetPaused(channels[soundid], false);
}
void emit_sound_np(int soundid, float vol)
{
- PlaySoundEx (soundid, samp[soundid], NULL, true);
- OPENAL_SetVolume (channels[soundid], vol);
- OPENAL_SetPaused (channels[soundid], false);
+ PlaySoundEx(soundid, samp[soundid], NULL, true);
+ OPENAL_SetVolume(channels[soundid], vol);
+ OPENAL_SetPaused(channels[soundid], false);
}
-void emit_stream_at(int soundid, const XYZ &pos, float vol)
+void emit_stream_at(int soundid, const XYZ& pos, float vol)
{
- PlayStreamEx (soundid, samp[soundid], NULL, true);
- OPENAL_3D_SetAttributes_ (channels[soundid], pos);
- OPENAL_SetVolume (channels[soundid], vol);
- OPENAL_SetPaused (channels[soundid], false);
+ PlayStreamEx(soundid, samp[soundid], NULL, true);
+ OPENAL_3D_SetAttributes_(channels[soundid], pos);
+ OPENAL_SetVolume(channels[soundid], vol);
+ OPENAL_SetPaused(channels[soundid], false);
}
void emit_stream_np(int soundid, float vol)
{
- PlayStreamEx (soundid, samp[soundid], NULL, true);
- OPENAL_SetVolume (channels[soundid], vol);
- OPENAL_SetPaused (channels[soundid], false);
+ PlayStreamEx(soundid, samp[soundid], NULL, true);
+ OPENAL_SetVolume(channels[soundid], vol);
+ OPENAL_SetPaused(channels[soundid], false);
}
void resume_stream(int soundid)
{
- OPENAL_SetPaused (channels[soundid], false);
+ OPENAL_SetPaused(channels[soundid], false);
}
void pause_sound(int soundid)
{
- OPENAL_SetPaused (channels[soundid], true);
+ OPENAL_SetPaused(channels[soundid], true);
}
// FMOD uses a Left Handed Coordinate system, OpenAL uses a Right Handed
// one...so we just need to flip the sign on the Z axis when appropriate.
-typedef struct {
+typedef struct
+{
ALuint sid;
- OPENAL_SAMPLE *sample;
+ OPENAL_SAMPLE* sample;
bool startpaused;
float position[3];
} OPENAL_Channels;
-typedef struct OPENAL_SAMPLE {
- char *name;
- ALuint bid; // buffer id.
+typedef struct OPENAL_SAMPLE
+{
+ char* name;
+ ALuint bid; // buffer id.
int mode;
int is2d;
} OPENAL_SAMPLE;
static size_t num_channels = 0;
-static OPENAL_Channels *impl_channels = NULL;
+static OPENAL_Channels* impl_channels = NULL;
static bool initialized = false;
static float listener_position[3];
static void set_channel_position(const int channel, const float x,
const float y, const float z)
{
- OPENAL_Channels *chan = &impl_channels[channel];
+ OPENAL_Channels* chan = &impl_channels[channel];
chan->position[0] = x;
chan->position[1] = y;
chan->position[2] = z;
- OPENAL_SAMPLE *sptr = chan->sample;
+ OPENAL_SAMPLE* sptr = chan->sample;
if (sptr == NULL)
return;
}
}
-
-AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *, float fx, float fy, float fz, float tx, float ty, float tz)
+AL_API void OPENAL_3D_Listener_SetAttributes(const float* pos, const float*, float fx, float fy, float fz, float tx, float ty, float tz)
{
if (!initialized)
return;
// adjust existing positions...
for (unsigned i = 0; i < num_channels; i++) {
- const float *p = impl_channels[i].position;
+ const float* p = impl_channels[i].position;
set_channel_position(i, p[0], p[1], p[2]);
}
}
-AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos)
+AL_API signed char OPENAL_3D_SetAttributes(int channel, const float* pos)
{
if (!initialized)
return false;
return true;
}
-AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos)
+AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ& pos)
{
if (!initialized)
return false;
if (maxsoftwarechannels == 0)
return false;
- if (flags != 0) // unsupported.
+ if (flags != 0) // unsupported.
return false;
- ALCdevice *dev = alcOpenDevice(NULL);
+ ALCdevice* dev = alcOpenDevice(NULL);
if (!dev)
return false;
ALint caps[] = { ALC_FREQUENCY, mixrate, 0 };
- ALCcontext *ctx = alcCreateContext(dev, caps);
+ ALCcontext* ctx = alcCreateContext(dev, caps);
if (!ctx) {
alcCloseDevice(dev);
return false;
alcProcessContext(ctx);
if (commandLineOptions[OPENALINFO]) {
- printf("AL_VENDOR: %s\n", (char *) alGetString(AL_VENDOR));
- printf("AL_RENDERER: %s\n", (char *) alGetString(AL_RENDERER));
- printf("AL_VERSION: %s\n", (char *) alGetString(AL_VERSION));
- printf("AL_EXTENSIONS: %s\n", (char *) alGetString(AL_EXTENSIONS));
+ printf("AL_VENDOR: %s\n", (char*)alGetString(AL_VENDOR));
+ printf("AL_RENDERER: %s\n", (char*)alGetString(AL_RENDERER));
+ printf("AL_VERSION: %s\n", (char*)alGetString(AL_VERSION));
+ printf("AL_EXTENSIONS: %s\n", (char*)alGetString(AL_EXTENSIONS));
}
num_channels = maxsoftwarechannels;
impl_channels = new OPENAL_Channels[maxsoftwarechannels];
- memset(impl_channels, '\0', sizeof (OPENAL_Channels) * num_channels);
+ memset(impl_channels, '\0', sizeof(OPENAL_Channels) * num_channels);
for (unsigned i = 0; i < num_channels; i++)
- alGenSources(1, &impl_channels[i].sid); // !!! FIXME: verify this didn't fail!
+ alGenSources(1, &impl_channels[i].sid); // !!! FIXME: verify this didn't fail!
initialized = true;
return true;
if (!initialized)
return;
- ALCcontext *ctx = alcGetCurrentContext();
+ ALCcontext* ctx = alcGetCurrentContext();
if (ctx) {
for (unsigned i = 0; i < num_channels; i++) {
alSourceStop(impl_channels[i].sid);
alSourcei(impl_channels[i].sid, AL_BUFFER, 0);
alDeleteSources(1, &impl_channels[i].sid);
}
- ALCdevice *dev = alcGetContextsDevice(ctx);
+ ALCdevice* dev = alcGetContextsDevice(ctx);
alcMakeContextCurrent(NULL);
alcSuspendContext(ctx);
alcDestroyContext(ctx);
initialized = false;
}
-static OPENAL_SAMPLE *OPENAL_GetCurrentSample(int channel)
+static OPENAL_SAMPLE* OPENAL_GetCurrentSample(int channel)
{
if (!initialized)
return NULL;
if ((channel < 0) || (channel >= (int)num_channels))
return false;
if (impl_channels[channel].startpaused)
- return(true);
+ return (true);
ALint state = 0;
alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
- return((state == AL_PAUSED) ? true : false);
+ return ((state == AL_PAUSED) ? true : false);
}
static unsigned int OPENAL_GetLoopMode(int channel)
ALint loop = 0;
alGetSourceiv(impl_channels[channel].sid, AL_LOOPING, &loop);
if (loop)
- return(OPENAL_LOOP_NORMAL);
+ return (OPENAL_LOOP_NORMAL);
return OPENAL_LOOP_OFF;
}
return false;
ALint state = 0;
alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
- return((state == AL_PLAYING) ? true : false);
+ return ((state == AL_PLAYING) ? true : false);
}
-static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused)
{
if (!initialized)
return -1;
return channel;
}
-
-static void *decode_to_pcm(const char *_fname, ALenum &format, ALsizei &size, ALuint &freq)
+static void* decode_to_pcm(const char* _fname, ALenum& format, ALsizei& size, ALuint& freq)
{
#ifdef __POWERPC__
const int bigendian = 1;
#endif
// !!! FIXME: if it's not Ogg, we don't have a decoder. I'm lazy. :/
- char *fname = (char *) alloca(strlen(_fname) + 16);
+ char* fname = (char*)alloca(strlen(_fname) + 16);
strcpy(fname, _fname);
- char *ptr = strchr(fname, '.');
+ char* ptr = strchr(fname, '.');
if (ptr)
*ptr = '\0';
strcat(fname, ".ogg");
// just in case...
- FILE *io = fopen(fname, "rb");
+ FILE* io = fopen(fname, "rb");
if (io == NULL)
return NULL;
- ALubyte *retval = NULL;
+ ALubyte* retval = NULL;
-#if 0 // untested, so disable this!
+#if 0 // untested, so disable this!
// Can we just feed it to the AL compressed?
if (alIsExtensionPresent((const ALubyte *) "AL_EXT_vorbis")) {
format = alGetEnumValue((const ALubyte *) "AL_FORMAT_VORBIS_EXT");
// Uncompress and feed to the AL.
OggVorbis_File vf;
- memset(&vf, '\0', sizeof (vf));
+ memset(&vf, '\0', sizeof(vf));
if (ov_open(io, &vf, NULL, 0) == 0) {
int bitstream = 0;
- vorbis_info *info = ov_info(&vf, -1);
+ vorbis_info* info = ov_info(&vf, -1);
size = 0;
format = (info->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
freq = info->rate;
char buf[1024 * 16];
long rc = 0;
size_t allocated = 64 * 1024;
- retval = (ALubyte *) malloc(allocated);
- while ( (rc = ov_read(&vf, buf, sizeof (buf), bigendian, 2, 1, &bitstream)) != 0 ) {
+ retval = (ALubyte*)malloc(allocated);
+ while ((rc = ov_read(&vf, buf, sizeof(buf), bigendian, 2, 1, &bitstream)) != 0) {
if (rc > 0) {
size += rc;
if (size >= (int)allocated) {
allocated *= 2;
- ALubyte *tmp = (ALubyte *) realloc(retval, allocated);
+ ALubyte* tmp = (ALubyte*)realloc(retval, allocated);
if (tmp == NULL) {
free(retval);
retval = NULL;
return NULL;
}
-
-AL_API OPENAL_SAMPLE *OPENAL_Sample_Load(int index, const char *name_or_data, unsigned int mode, int offset, int length)
+AL_API OPENAL_SAMPLE* OPENAL_Sample_Load(int index, const char* name_or_data, unsigned int mode, int offset, int length)
{
if (!initialized)
return NULL;
if (index != OPENAL_FREE)
- return NULL; // this is all the game does...
+ return NULL; // this is all the game does...
if (offset != 0)
- return NULL; // this is all the game does...
+ return NULL; // this is all the game does...
if (length != 0)
- return NULL; // this is all the game does...
+ return NULL; // this is all the game does...
if ((mode != OPENAL_HW3D) && (mode != OPENAL_2D))
- return NULL; // this is all the game does...
+ return NULL; // this is all the game does...
- OPENAL_SAMPLE *retval = NULL;
+ OPENAL_SAMPLE* retval = NULL;
ALenum format = AL_NONE;
ALsizei size = 0;
ALuint frequency = 0;
- void *data = decode_to_pcm(name_or_data, format, size, frequency);
+ void* data = decode_to_pcm(name_or_data, format, size, frequency);
if (data == NULL)
return NULL;
}
free(data);
- return(retval);
+ return (retval);
}
-AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr)
+AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE* sptr)
{
if (!initialized)
return;
}
}
-static signed char OPENAL_Sample_SetMode(OPENAL_SAMPLE *sptr, unsigned int mode)
+static signed char OPENAL_Sample_SetMode(OPENAL_SAMPLE* sptr, unsigned int mode)
{
if (!initialized)
return false;
if ((channel < 0) || (channel >= (int)num_channels))
return false;
if (slomo)
- alSourcef(impl_channels[channel].sid, AL_PITCH, ((ALfloat) slomofreq) / 44100.0f);
+ alSourcef(impl_channels[channel].sid, AL_PITCH, ((ALfloat)slomofreq) / 44100.0f);
else
alSourcef(impl_channels[channel].sid, AL_PITCH, 1.0f);
return true;
vol = 0;
else if (vol > 255)
vol = 255;
- ALfloat gain = ((ALfloat) vol) / 255.0f;
+ ALfloat gain = ((ALfloat)vol) / 255.0f;
alSourcef(impl_channels[channel].sid, AL_GAIN, gain);
return true;
}
{
if (!initialized)
return;
- ALfloat gain = ((ALfloat) volume) / 255.0f;
+ ALfloat gain = ((ALfloat)volume) / 255.0f;
alListenerf(AL_GAIN, gain);
}
return true;
}
-static OPENAL_SAMPLE *OPENAL_Stream_GetSample(OPENAL_STREAM *stream)
+static OPENAL_SAMPLE* OPENAL_Stream_GetSample(OPENAL_STREAM* stream)
{
if (!initialized)
return NULL;
- return (OPENAL_SAMPLE *) stream;
+ return (OPENAL_SAMPLE*)stream;
}
-static int OPENAL_Stream_PlayEx(int channel, OPENAL_STREAM *stream, OPENAL_DSPUNIT *dsp, signed char startpaused)
+static int OPENAL_Stream_PlayEx(int channel, OPENAL_STREAM* stream, OPENAL_DSPUNIT* dsp, signed char startpaused)
{
- return OPENAL_PlaySoundEx(channel, (OPENAL_SAMPLE *) stream, dsp, startpaused);
+ return OPENAL_PlaySoundEx(channel, (OPENAL_SAMPLE*)stream, dsp, startpaused);
}
-static signed char OPENAL_Stream_Stop(OPENAL_STREAM *stream)
+static signed char OPENAL_Stream_Stop(OPENAL_STREAM* stream)
{
if (!initialized)
return false;
for (unsigned i = 0; i < num_channels; i++) {
- if (impl_channels[i].sample == (OPENAL_SAMPLE *) stream) {
+ if (impl_channels[i].sample == (OPENAL_SAMPLE*)stream) {
alSourceStop(impl_channels[i].sid);
impl_channels[i].startpaused = false;
}
return true;
}
-AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM *stream, unsigned int mode)
+AL_API signed char OPENAL_Stream_SetMode(OPENAL_STREAM* stream, unsigned int mode)
{
- return OPENAL_Sample_SetMode((OPENAL_SAMPLE *) stream, mode);
+ return OPENAL_Sample_SetMode((OPENAL_SAMPLE*)stream, mode);
}
AL_API void OPENAL_Update()
extern int channels[];
-extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused)
{
- const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
+ const OPENAL_SAMPLE* currSample = OPENAL_GetCurrentSample(channels[chan]);
if (currSample && currSample == samp[chan]) {
if (OPENAL_GetPaused(channels[chan])) {
OPENAL_StopSound(channels[chan]);
}
}
-extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)
+extern "C" void PlayStreamEx(int chan, OPENAL_STREAM* sptr, OPENAL_DSPUNIT* dsp, signed char startpaused)
{
- const OPENAL_SAMPLE * currSample = OPENAL_GetCurrentSample(channels[chan]);
+ const OPENAL_SAMPLE* currSample = OPENAL_GetCurrentSample(channels[chan]);
if (currSample && currSample == OPENAL_Stream_GetSample(sptr)) {
OPENAL_StopSound(channels[chan]);
OPENAL_Stream_Stop(sptr);
#include "Game.hpp"
#include "Level/Dialog.hpp"
#include "Level/Hotspot.hpp"
-#include "Utils/Folders.hpp"
#include "Tutorial.hpp"
+#include "Utils/Folders.hpp"
-const char *cmd_names[cmd_count] = {
+const char* cmd_names[cmd_count] = {
#define DECLARE_COMMAND(cmd) #cmd,
#include "ConsoleCmds.def"
-#undef DECLARE_COMMAND
+#undef DECLARE_COMMAND
};
console_handler cmd_handlers[cmd_count] = {
#define DECLARE_COMMAND(cmd) ch_##cmd,
#include "ConsoleCmds.def"
-#undef DECLARE_COMMAND
+#undef DECLARE_COMMAND
};
using namespace Game;
/* Helpers used in console commands */
/* Return true if PFX is a prefix of STR (case-insensitive). */
-static bool stripfx(const char *str, const char *pfx)
+static bool stripfx(const char* str, const char* pfx)
{
return !strncasecmp(str, pfx, strlen(pfx));
}
-static void set_proportion(int pnum, const char *args)
+static void set_proportion(int pnum, const char* args)
{
float headprop, bodyprop, armprop, legprop;
}
}
-static void set_protection(int pnum, const char *args)
+static void set_protection(int pnum, const char* args)
{
float head, high, low;
sscanf(args, "%f%f%f", &head, &high, &low);
Person::players[pnum]->protectionhead = head;
Person::players[pnum]->protectionhigh = high;
- Person::players[pnum]->protectionlow = low;
+ Person::players[pnum]->protectionlow = low;
}
-static void set_armor(int pnum, const char *args)
+static void set_armor(int pnum, const char* args)
{
float head, high, low;
sscanf(args, "%f%f%f", &head, &high, &low);
Person::players[pnum]->armorhead = head;
Person::players[pnum]->armorhigh = high;
- Person::players[pnum]->armorlow = low;
+ Person::players[pnum]->armorlow = low;
}
-static void set_metal(int pnum, const char *args)
+static void set_metal(int pnum, const char* args)
{
float head, high, low;
sscanf(args, "%f%f%f", &head, &high, &low);
Person::players[pnum]->metalhead = head;
Person::players[pnum]->metalhigh = high;
- Person::players[pnum]->metallow = low;
+ Person::players[pnum]->metallow = low;
}
static void set_noclothes(int pnum, const char*)
&Person::players[pnum]->skeleton.skinText[0], &Person::players[pnum]->skeleton.skinsize);
}
-static void set_clothes(int pnum, const char *args)
+static void set_clothes(int pnum, const char* args)
{
char buf[64];
snprintf(buf, 63, "Textures/%s.png", args);
/* Console commands themselves */
-void ch_quit(const char *)
+void ch_quit(const char*)
{
tryquit = 1;
}
-void ch_map(const char *args)
+void ch_map(const char* args)
{
if (!LoadLevel(args)) {
// FIXME: Reduce code duplication with GameTick (should come from a Console class)
campaign = 0;
}
-void ch_save(const char *args)
+void ch_save(const char* args)
{
std::string map_path = Folders::getUserDataPath() + "/Maps";
Folders::makeDirectory(map_path);
int mapvers = 12;
- FILE *tfile;
- tfile = fopen( map_path.c_str(), "wb" );
+ FILE* tfile;
+ tfile = fopen(map_path.c_str(), "wb");
if (tfile == NULL) {
perror((std::string("Couldn't open file ") + map_path + " for saving").c_str());
return;
fclose(tfile);
}
-void ch_cellar(const char *)
+void ch_cellar(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Furdarko.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_tint(const char *args)
+void ch_tint(const char* args)
{
sscanf(args, "%f%f%f", &tintr, &tintg, &tintb);
}
-void ch_tintr(const char *args)
+void ch_tintr(const char* args)
{
tintr = atof(args);
}
-void ch_tintg(const char *args)
+void ch_tintg(const char* args)
{
tintg = atof(args);
}
-void ch_tintb(const char *args)
+void ch_tintb(const char* args)
{
tintb = atof(args);
}
-void ch_speed(const char *args)
+void ch_speed(const char* args)
{
Person::players[0]->speedmult = atof(args);
}
-void ch_strength(const char *args)
+void ch_strength(const char* args)
{
Person::players[0]->power = atof(args);
}
-void ch_power(const char *args)
+void ch_power(const char* args)
{
Person::players[0]->power = atof(args);
}
-void ch_size(const char *args)
+void ch_size(const char* args)
{
Person::players[0]->scale = atof(args) * .2;
}
-void ch_sizenear(const char *args)
+void ch_sizenear(const char* args)
{
int closest = findClosestPlayer();
if (closest >= 0)
Person::players[closest]->scale = atof(args) * .2;
}
-void ch_proportion(const char *args)
+void ch_proportion(const char* args)
{
set_proportion(0, args);
}
-void ch_proportionnear(const char *args)
+void ch_proportionnear(const char* args)
{
int closest = findClosestPlayer();
if (closest >= 0)
set_proportion(closest, args);
}
-void ch_protection(const char *args)
+void ch_protection(const char* args)
{
set_protection(0, args);
}
-void ch_protectionnear(const char *args)
+void ch_protectionnear(const char* args)
{
int closest = findClosestPlayer();
if (closest >= 0)
set_protection(closest, args);
}
-void ch_armor(const char *args)
+void ch_armor(const char* args)
{
set_armor(0, args);
}
-void ch_armornear(const char *args)
+void ch_armornear(const char* args)
{
int closest = findClosestPlayer();
if (closest >= 0)
set_armor(closest, args);
}
-void ch_protectionreset(const char *)
+void ch_protectionreset(const char*)
{
set_protection(0, "1 1 1");
set_armor(0, "1 1 1");
}
-void ch_metal(const char *args)
+void ch_metal(const char* args)
{
set_metal(0, args);
}
-void ch_noclothes(const char *args)
+void ch_noclothes(const char* args)
{
set_noclothes(0, args);
}
-void ch_noclothesnear(const char *args)
+void ch_noclothesnear(const char* args)
{
int closest = findClosestPlayer();
if (closest >= 0)
set_noclothes(closest, args);
}
-void ch_clothes(const char *args)
+void ch_clothes(const char* args)
{
set_clothes(0, args);
}
-void ch_clothesnear(const char *args)
+void ch_clothesnear(const char* args)
{
int closest = findClosestPlayer();
if (closest >= 0)
set_clothes(closest, args);
}
-void ch_belt(const char *)
+void ch_belt(const char*)
{
Person::players[0]->skeleton.clothes = !Person::players[0]->skeleton.clothes;
}
-
-void ch_cellophane(const char *)
+void ch_cellophane(const char*)
{
cellophane = !cellophane;
float mul = (cellophane ? 0 : 1);
}
}
-void ch_funnybunny(const char *)
+void ch_funnybunny(const char*)
{
Person::players[0]->creature = rabbittype;
Person::players[0]->skeletonLoad(true);
set_proportion(0, "1 1 1 1");
}
-void ch_wolfie(const char *)
+void ch_wolfie(const char*)
{
Person::players[0]->creature = wolftype;
Person::players[0]->skeletonLoad();
set_proportion(0, "1 1 1 1");
}
-void ch_wolfieisgod(const char *args)
+void ch_wolfieisgod(const char* args)
{
ch_wolfie(args);
}
-void ch_wolf(const char *)
+void ch_wolf(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Wolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_snowwolf(const char *)
+void ch_snowwolf(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/SnowWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_darkwolf(const char *)
+void ch_darkwolf(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/DarkWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_lizardwolf(const char *)
+void ch_lizardwolf(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/LizardWolf.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_white(const char *)
+void ch_white(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Fur.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_brown(const char *)
+void ch_brown(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Fur3.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_black(const char *)
+void ch_black(const char*)
{
Person::players[0]->skeleton.drawmodel.textureptr.load("Textures/Fur2.jpg", 1, &Person::players[0]->skeleton.skinText[0], &Person::players[0]->skeleton.skinsize);
}
-void ch_sizemin(const char *)
+void ch_sizemin(const char*)
{
for (unsigned i = 1; i < Person::players.size(); i++)
if (Person::players[i]->scale < 0.8 * 0.2)
Person::players[i]->scale = 0.8 * 0.2;
}
-void ch_tutorial(const char *args)
+void ch_tutorial(const char* args)
{
Tutorial::active = atoi(args);
}
-void ch_hostile(const char *args)
+void ch_hostile(const char* args)
{
hostile = atoi(args);
}
-void ch_type(const char *args)
+void ch_type(const char* args)
{
int n = sizeof(editortypenames) / sizeof(editortypenames[0]);
for (int i = 0; i < n; i++)
}
}
-void ch_path(const char *args)
+void ch_path(const char* args)
{
unsigned int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
for (unsigned int i = 0; i < n; i++)
}
}
-void ch_hs(const char *args)
+void ch_hs(const char* args)
{
float size;
int type, shift;
strcat(Hotspot::hotspots.back().text, "\n");
}
-void ch_dialogue(const char *args)
+void ch_dialogue(const char* args)
{
int type;
char buf1[32];
Dialog::whichdialogue = Dialog::dialogs.size();
}
-void ch_fixdialogue(const char *args)
+void ch_fixdialogue(const char* args)
{
char buf1[32];
int whichdi;
Dialog::dialogs[whichdi] = Dialog(Dialog::dialogs[whichdi].type, filename);
}
-void ch_fixtype(const char *args)
+void ch_fixtype(const char* args)
{
int dlg;
sscanf(args, "%d", &dlg);
Dialog::dialogs[0].type = dlg;
}
-void ch_fixrotation(const char *)
+void ch_fixrotation(const char*)
{
int playerId = Dialog::currentScene().participantfocus;
Dialog::currentDialog().participantyaw[playerId] = Person::players[playerId]->yaw;
}
-void ch_ddialogue(const char *)
+void ch_ddialogue(const char*)
{
if (!Dialog::dialogs.empty()) {
Dialog::dialogs.pop_back();
}
}
-void ch_dhs(const char *)
+void ch_dhs(const char*)
{
if (!Hotspot::hotspots.empty()) {
Hotspot::hotspots.pop_back();
}
}
-void ch_immobile(const char *)
+void ch_immobile(const char*)
{
Person::players[0]->immobile = 1;
}
-void ch_allimmobile(const char *)
+void ch_allimmobile(const char*)
{
for (unsigned i = 1; i < Person::players.size(); i++)
Person::players[i]->immobile = 1;
}
-void ch_mobile(const char *)
+void ch_mobile(const char*)
{
Person::players[0]->immobile = 0;
}
-void ch_default(const char *)
+void ch_default(const char*)
{
Person::players[0]->armorhead = 1;
Person::players[0]->armorhigh = 1;
Person::players[0]->immobile = 0;
}
-void ch_play(const char *args)
+void ch_play(const char* args)
{
int dlg;
sscanf(args, "%d", &dlg);
Dialog::currentDialog().play();
}
-void ch_mapkilleveryone(const char *)
+void ch_mapkilleveryone(const char*)
{
maptype = mapkilleveryone;
}
-void ch_mapkillmost(const char *)
+void ch_mapkillmost(const char*)
{
maptype = mapkillmost;
}
-void ch_mapkillsomeone(const char *)
+void ch_mapkillsomeone(const char*)
{
maptype = mapkillsomeone;
}
-void ch_mapgosomewhere(const char *)
+void ch_mapgosomewhere(const char*)
{
maptype = mapgosomewhere;
}
-void ch_viewdistance(const char *args)
+void ch_viewdistance(const char* args)
{
viewdistance = atof(args) * 100;
}
-void ch_fadestart(const char *args)
+void ch_fadestart(const char* args)
{
fadestart = atof(args);
}
-void ch_slomo(const char *args)
+void ch_slomo(const char* args)
{
slomospeed = atof(args);
slomo = !slomo;
slomodelay = 1000;
}
-void ch_slofreq(const char *args)
+void ch_slofreq(const char* args)
{
slomofreq = atof(args);
}
-void ch_skytint(const char *args)
+void ch_skytint(const char* args)
{
sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb);
Object::DoShadows();
}
-void ch_skylight(const char *args)
+void ch_skylight(const char* args)
{
sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb);
void SetUpLight(Light* whichsource, int whichlight)
{
- static float qattenuation[] = {0.0002f};
+ static float qattenuation[] = { 0.0002f };
//Initialize lights
if (whichlight == 0) {
- GLfloat LightAmbient[] = { whichsource->ambient[0], whichsource->ambient[1], whichsource->ambient[2], 1.0f};
+ GLfloat LightAmbient[] = { whichsource->ambient[0], whichsource->ambient[1], whichsource->ambient[2], 1.0f };
GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 0.0f };
} else {
GLenum lightselect = GL_LIGHT1;
switch (whichlight) {
- case 2:
- lightselect = GL_LIGHT2;
- break;
- case 3:
- lightselect = GL_LIGHT3;
- break;
- case 4:
- lightselect = GL_LIGHT4;
- break;
- case 5:
- lightselect = GL_LIGHT5;
- break;
- case 6:
- lightselect = GL_LIGHT6;
- break;
- case 7:
- lightselect = GL_LIGHT7;
- break;
+ case 2:
+ lightselect = GL_LIGHT2;
+ break;
+ case 3:
+ lightselect = GL_LIGHT3;
+ break;
+ case 4:
+ lightselect = GL_LIGHT4;
+ break;
+ case 5:
+ lightselect = GL_LIGHT5;
+ break;
+ case 6:
+ lightselect = GL_LIGHT6;
+ break;
+ case 7:
+ lightselect = GL_LIGHT7;
+ break;
}
- GLfloat LightAmbient[] = { 0, 0, 0, 1.0f};
+ GLfloat LightAmbient[] = { 0, 0, 0, 1.0f };
GLfloat LightDiffuse[] = { whichsource->color[0], whichsource->color[1], whichsource->color[2], 1.0f };
GLfloat LightPosition[] = { whichsource->location.x, whichsource->location.y, whichsource->location.z, 1.0f };
glLightfv(lightselect, GL_AMBIENT, LightAmbient);
glLightfv(lightselect, GL_DIFFUSE, LightDiffuse);
glEnable(lightselect);
-
}
}
extern float skyboxg;
extern float skyboxb;
-void SkyBox::load (const std::string& ffront, const std::string& fleft, const std::string& fback,
- const std::string& fright, const std::string& fup, const std::string& fdown)
+void SkyBox::load(const std::string& ffront, const std::string& fleft, const std::string& fback,
+ const std::string& fright, const std::string& fup, const std::string& fdown)
{
front.load(ffront, true);
left.load(fleft, true);
glDisable(GL_LIGHTING);
if (skyboxtexture)
glEnable(GL_TEXTURE_2D);
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
front.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
- glNormal3f( 0.0f, 0.0f, -1);
+ glNormal3f(0.0f, 0.0f, -1);
glTexCoord2f(0, 0);
- glVertex3f(-size, -size, size);
+ glVertex3f(-size, -size, size);
glTexCoord2f(1, 0);
- glVertex3f( size, -size, size);
+ glVertex3f(size, -size, size);
glTexCoord2f(1, 1);
- glVertex3f( size, size, size);
+ glVertex3f(size, size, size);
glTexCoord2f(0, 1);
- glVertex3f(-size, size, size);
+ glVertex3f(-size, size, size);
glEnd();
back.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
- glNormal3f( 0.0f, 0.0f, 1);
+ glNormal3f(0.0f, 0.0f, 1);
glTexCoord2f(1, 0);
glVertex3f(-size, -size, -size);
glTexCoord2f(1, 1);
- glVertex3f(-size, size, -size);
+ glVertex3f(-size, size, -size);
glTexCoord2f(0, 1);
- glVertex3f( size, size, -size);
+ glVertex3f(size, size, -size);
glTexCoord2f(0, 0);
- glVertex3f( size, -size, -size);
+ glVertex3f(size, -size, -size);
glEnd();
up.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
- glNormal3f( 0.0f, -1.0f, 0);
+ glNormal3f(0.0f, -1.0f, 0);
glTexCoord2f(0, 1);
- glVertex3f(-size, size, -size);
+ glVertex3f(-size, size, -size);
glTexCoord2f(0, 0);
- glVertex3f(-size, size, size);
+ glVertex3f(-size, size, size);
glTexCoord2f(1, 0);
- glVertex3f( size, size, size);
+ glVertex3f(size, size, size);
glTexCoord2f(1, 1);
- glVertex3f( size, size, -size);
+ glVertex3f(size, size, -size);
glEnd();
down.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
- glNormal3f( 0.0f, 1.0f, 0);
+ glNormal3f(0.0f, 1.0f, 0);
glTexCoord2f(0, 0);
glVertex3f(-size, -size, -size);
glTexCoord2f(1, 0);
- glVertex3f( size, -size, -size);
+ glVertex3f(size, -size, -size);
glTexCoord2f(1, 1);
- glVertex3f( size, -size, size);
+ glVertex3f(size, -size, size);
glTexCoord2f(0, 1);
- glVertex3f(-size, -size, size);
+ glVertex3f(-size, -size, size);
glEnd();
right.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
- glNormal3f( -1.0f, 0.0f, 0);
+ glNormal3f(-1.0f, 0.0f, 0);
glTexCoord2f(1, 0);
- glVertex3f( size, -size, -size);
+ glVertex3f(size, -size, -size);
glTexCoord2f(1, 1);
- glVertex3f( size, size, -size);
+ glVertex3f(size, size, -size);
glTexCoord2f(0, 1);
- glVertex3f( size, size, size);
+ glVertex3f(size, size, size);
glTexCoord2f(0, 0);
- glVertex3f( size, -size, size);
+ glVertex3f(size, -size, size);
glEnd();
left.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
- glNormal3f( 1.0f, 0.0f, 0);
+ glNormal3f(1.0f, 0.0f, 0);
glTexCoord2f(0, 0);
glVertex3f(-size, -size, -size);
glTexCoord2f(1, 0);
- glVertex3f(-size, -size, size);
+ glVertex3f(-size, -size, size);
glTexCoord2f(1, 1);
- glVertex3f(-size, size, size);
+ glVertex3f(-size, size, size);
glTexCoord2f(0, 1);
- glVertex3f(-size, size, -size);
+ glVertex3f(-size, size, -size);
glEnd();
glEnable(GL_CULL_FACE);
glDepthMask(1);
#include "Game.hpp"
#include "Objects/Object.hpp"
-#include "Utils/Folders.hpp"
#include "Tutorial.hpp"
+#include "Utils/Folders.hpp"
extern XYZ viewer;
extern float viewdistance;
//Functions
-int Terrain::lineTerrain(XYZ p1, XYZ p2, XYZ *p)
+int Terrain::lineTerrain(XYZ p1, XYZ p2, XYZ* p)
{
static int i, j, k;
static float distance;
{
static int i, j, a, b, c, patch_size, stepsize;
-
numtris[whichx][whichy] = 0;
patch_size = size / subdivision;
minypatch[whichx][whichy] = 10000;
for (a = 0; a < size / subdivision; a++) {
for (b = 0; b < size / subdivision; b++) {
- if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale > maxypatch[whichx][whichy])
+ if (heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale > maxypatch[whichx][whichy])
maxypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
- if (heightmap[(size / subdivision)*whichx + a][(size / subdivision)*whichy + b]*scale < minypatch[whichx][whichy])
+ if (heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale < minypatch[whichx][whichy])
minypatch[whichx][whichy] = heightmap[(size / subdivision) * whichx + a][(size / subdivision) * whichy + b] * scale;
}
}
heightypatch[whichx][whichy] = size / subdivision * scale;
avgypatch[whichx][whichy] = (minypatch[whichx][whichy] + maxypatch[whichx][whichy]) / 2;
- for (i = whichx * size / subdivision; i < (whichx + 1)*size / subdivision - 1; i++) {
- for (j = whichy * size / subdivision; j < (whichy + 1)*size / subdivision - 1; j++) {
+ for (i = whichx * size / subdivision; i < (whichx + 1) * size / subdivision - 1; i++) {
+ for (j = whichy * size / subdivision; j < (whichy + 1) * size / subdivision - 1; j++) {
triangles[(i * (size - 1) * 2) + (j * 2)][0].x = i * scale;
triangles[(i * (size - 1) * 2) + (j * 2)][0].y = heightmap[i][j] * scale;
triangles[(i * (size - 1) * 2) + (j * 2)][0].z = j * scale;
triangles[(i * (size - 1) * 2) + (j * 2) + 1][2].z = j * scale + 1 * scale;
}
}
-
}
-
bool Terrain::load(const std::string& fileName)
{
static long i, j;
}
Game::LoadingScreen();
-
for (i = 0; i < size; i++) {
for (j = 0; j < size; j++) {
heightmap[i][j] *= .5;
if (opacityother[i][j] != 1 && textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] == allsecond)
textureness[(int)(x * subdivision / size)][(int)(y * subdivision / size)] = mixed;
j--;
-
}
}
}
normals[i][j + 1] = normals[i][j + 1] + facenormal;
normals[i + 1][j] = normals[i + 1][j] + facenormal;
-
a.x = i + 1;
a.y = heightmap[i + 1][j];
a.z = j;
glMatrixMode(GL_MODELVIEW);
}
-
float Terrain::getHeight(float pointx, float pointz)
{
static int tilex, tiley;
glPushMatrix();
if (frustum.CubeInFrustum(i * patch_size + patch_size * .5, avgypatch[i][j], j * patch_size + patch_size * .5, heightypatch[i][j] / 2)) {
if (environment == desertenvironment && distance[i][j] > viewdistsquared / 4)
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness);
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness);
else if (environment == desertenvironment)
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
if (!layer && textureness[i][j] != allsecond)
drawpatch(i, j, opacity);
if (layer == 1 && textureness[i][j] != allfirst)
}
}
if (environment == desertenvironment)
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
}
void Terrain::drawdecals()
if (distancemult >= 1)
glColor4f(1, 1, 1, decals[i].opacity);
if (distancemult < 1)
- glColor4f(1, 1, 1, decals[i].opacity*distancemult);
+ glColor4f(1, 1, 1, decals[i].opacity * distancemult);
}
if (decals[i].type == footprintdecal || decals[i].type == bodyprintdecal) {
distancemult = (viewdistsquared - (distsq(&viewer, &decals[i].position) - (viewdistsquared * fadestart)) * (1 / (1 - fadestart))) / viewdistsquared;
glColor4f(1, 1, 1, decals[i].opacity * (5 - decals[i].alivetime) / 2);
}
if (distancemult < 1) {
- glColor4f(1, 1, 1, decals[i].opacity*distancemult);
+ glColor4f(1, 1, 1, decals[i].opacity * distancemult);
if (decals[i].alivetime > 3)
glColor4f(1, 1, 1, decals[i].opacity * (5 - decals[i].alivetime) / 2 * distancemult);
}
if (distancemult >= 1) {
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity);
if (decals[i].alivetime < 4)
- glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity*decals[i].alivetime*.25);
+ glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * decals[i].alivetime * .25);
if (decals[i].alivetime > 58)
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * (60 - decals[i].alivetime) / 2);
}
if (distancemult < 1) {
- glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity*distancemult);
+ glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * distancemult);
if (decals[i].alivetime < 4)
- glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity*decals[i].alivetime*distancemult * .25);
+ glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * decals[i].alivetime * distancemult * .25);
if (decals[i].alivetime > 58)
glColor4f(decals[i].brightness, decals[i].brightness, decals[i].brightness, decals[i].opacity * (60 - decals[i].alivetime) / 2 * distancemult);
}
colors[i][j][1] = light.color[1] * brightness + light.ambient[1];
colors[i][j][2] = light.color[2] * brightness + light.ambient[2];
- if (colors[i][j][0] > 1) colors[i][j][0] = 1;
- if (colors[i][j][1] > 1) colors[i][j][1] = 1;
- if (colors[i][j][2] > 1) colors[i][j][2] = 1;
- if (colors[i][j][0] < 0) colors[i][j][0] = 0;
- if (colors[i][j][1] < 0) colors[i][j][1] = 0;
- if (colors[i][j][2] < 0) colors[i][j][2] = 0;
+ if (colors[i][j][0] > 1)
+ colors[i][j][0] = 1;
+ if (colors[i][j][1] > 1)
+ colors[i][j][1] = 1;
+ if (colors[i][j][2] > 1)
+ colors[i][j][2] = 1;
+ if (colors[i][j][0] < 0)
+ colors[i][j][0] = 0;
+ if (colors[i][j][1] < 0)
+ colors[i][j][1] = 0;
+ if (colors[i][j][2] < 0)
+ colors[i][j][2] = 0;
}
}
extern int mainmenu;
-const char *pathtypenames[] = {"keepwalking", "pause"};
-const char *editortypenames[] = {
+const char* pathtypenames[] = { "keepwalking", "pause" };
+const char* editortypenames[] = {
"active", "sitting", "sitting wall", "sleeping",
"dead1", "dead2", "dead3", "dead4"
};
int oldmousecoordv = 0;
float yaw = 0;
float pitch = 0;
-SkyBox *skybox = NULL;
+SkyBox* skybox = NULL;
bool cameramode = 0;
bool firstLoadDone = false;
XYZ mapcenter;
float mapradius = 0;
-Text *text = NULL;
-Text *textmono = NULL;
+Text* text = NULL;
+Text* textmono = NULL;
float fps = 0;
bool editorenabled = 0;
break;
}
switch (evenement.type) {
- case SDL_TEXTEDITING:
- /* FIXME - We should handle this for complete input method support */
- break;
- case SDL_TEXTINPUT:
- str.insert(*charselected, evenement.text.text);
- (*charselected) += strlen(evenement.text.text);
- break;
- case SDL_KEYDOWN:
- if (evenement.key.keysym.sym == SDLK_ESCAPE) {
- str.clear();
- *charselected = 0;
- waiting = false;
- } else if (evenement.key.keysym.sym == SDLK_BACKSPACE) {
- if ((*charselected) > 0) {
- (*charselected)--;
- str.erase(*charselected, 1);
+ case SDL_TEXTEDITING:
+ /* FIXME - We should handle this for complete input method support */
+ break;
+ case SDL_TEXTINPUT:
+ str.insert(*charselected, evenement.text.text);
+ (*charselected) += strlen(evenement.text.text);
+ break;
+ case SDL_KEYDOWN:
+ if (evenement.key.keysym.sym == SDLK_ESCAPE) {
+ str.clear();
+ *charselected = 0;
+ waiting = false;
+ } else if (evenement.key.keysym.sym == SDLK_BACKSPACE) {
+ if ((*charselected) > 0) {
+ (*charselected)--;
+ str.erase(*charselected, 1);
+ }
+ } else if (evenement.key.keysym.sym == SDLK_DELETE) {
+ if ((*charselected) < str.size()) {
+ str.erase(*charselected, 1);
+ }
+ } else if (evenement.key.keysym.sym == SDLK_HOME) {
+ (*charselected) = 0;
+ } else if (evenement.key.keysym.sym == SDLK_END) {
+ (*charselected) = str.size();
+ } else if (evenement.key.keysym.sym == SDLK_LEFT) {
+ if ((*charselected) != 0)
+ (*charselected)--;
+ } else if (evenement.key.keysym.sym == SDLK_RIGHT) {
+ if ((*charselected) < str.size())
+ (*charselected)++;
+ } else if (evenement.key.keysym.sym == SDLK_RETURN) {
+ waiting = false;
}
- } else if (evenement.key.keysym.sym == SDLK_DELETE) {
- if ((*charselected) < str.size()) {
- str.erase(*charselected, 1);
- }
- } else if (evenement.key.keysym.sym == SDLK_HOME) {
- (*charselected) = 0;
- } else if (evenement.key.keysym.sym == SDLK_END) {
- (*charselected) = str.size();
- } else if (evenement.key.keysym.sym == SDLK_LEFT) {
- if ((*charselected) != 0)
- (*charselected)--;
- } else if (evenement.key.keysym.sym == SDLK_RIGHT) {
- if ((*charselected) < str.size())
- (*charselected)++;
- } else if (evenement.key.keysym.sym == SDLK_RETURN) {
- waiting = false;
- }
- break;
+ break;
}
}
#include "Level/Dialog.hpp"
#include "Level/Hotspot.hpp"
#include "Menu/Menu.hpp"
-#include "Utils/Input.hpp"
#include "Tutorial.hpp"
+#include "Utils/Input.hpp"
extern XYZ viewer;
extern int environment;
extern bool showdamagebar;
-
-
int drawtoggle = 0;
int numboundaries = 0;
XYZ boundary[360];
int change = 0;
-
-
-enum drawmodes {
- normalmode, motionblurmode, radialzoommode,
- realmotionblurmode, doublevisionmode, glowmode,
+enum drawmodes
+{
+ normalmode,
+ motionblurmode,
+ radialzoommode,
+ realmotionblurmode,
+ doublevisionmode,
+ glowmode,
};
-void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
+void Game::flash(float amount, int delay) // shouldn't be that way, these should be attributes and Person class should not change rendering.
{
flashr = 1;
flashg = 0;
std::string string;
static int drawmode = 0;
- if ( stereomode == stereoAnaglyph ) {
+ if (stereomode == stereoAnaglyph) {
switch (side) {
- case stereoLeft:
- glColorMask( 0.0, 1.0, 1.0, 1.0 );
- break;
- case stereoRight:
- glColorMask( 1.0, 0.0, 0.0, 1.0 );
- break;
- default:
- break;
+ case stereoLeft:
+ glColorMask(0.0, 1.0, 1.0, 1.0);
+ break;
+ case stereoRight:
+ glColorMask(1.0, 0.0, 0.0, 1.0);
+ break;
+ default:
+ break;
}
} else {
- glColorMask( 1.0, 1.0, 1.0, 1.0 );
+ glColorMask(1.0, 1.0, 1.0, 1.0);
- if ( stereomode == stereoHorizontalInterlaced ||
- stereomode == stereoVerticalInterlaced ) {
+ if (stereomode == stereoHorizontalInterlaced ||
+ stereomode == stereoVerticalInterlaced) {
glStencilFunc(side == stereoLeft ? GL_NOTEQUAL : GL_EQUAL, 0x01, 0x01);
}
}
}
if ((!changed && !slomo) || loading) {
drawmode = normalmode;
- if (ismotionblur && (/*fps>100||*/alwaysblur)) {
+ if (ismotionblur && (/*fps>100||*/ alwaysblur)) {
if (olddrawmode != realmotionblurmode)
change = 1;
else
glClearColor(0.25f, 0.25f, 0.25f, 1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
- glMatrixMode (GL_MODELVIEW);
+ glMatrixMode(GL_MODELVIEW);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glLoadIdentity ();
+ glLoadIdentity();
// Move the camera for the current eye's point of view.
// Reverse the movement if we're reversing stereo
- glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
+ glTranslatef((stereoseparation / 2) * side * (stereoreverse ? -1 : 1), 0, 0);
//camera effects
if (!cameramode && !freeze && !winfreeze) {
//shake
- glRotatef(float(Random() % 100) / 10 * camerashake/*+(woozy*woozy)/10*/, 0, 0, 1);
+ glRotatef(float(Random() % 100) / 10 * camerashake /*+(woozy*woozy)/10*/, 0, 0, 1);
//sway
glRotatef(pitch + sin(woozy / 2) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 1, 0, 0);
glRotatef(yaw + sin(woozy) * (Person::players[0]->damage / Person::players[0]->damagetolerance) * 5, 0, 1, 0);
if (environment == desertenvironment) {
if (detail == 2) {
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, blurness + .4 );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, blurness + .4);
}
glRotatef((float)(abs(Random() % 100)) / 1000, 1, 0, 0);
glRotatef((float)(abs(Random() % 100)) / 1000, 0, 1, 0);
}
skybox->draw();
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
glPopMatrix();
glTranslatef(-viewer.x, -viewer.y, -viewer.z);
frustum.GetFrustum();
}
}
-
if (numpathpoints > 1) {
glColor4f(0, 1, 0, 1);
for (unsigned k = 0; int(k) < numpathpoints; k++) {
if (!console) {
if (!Tutorial::active)
if (bonus > 0 && bonustime < 1 && !winfreeze && !Dialog::inDialog()) {
- const char *bonus_name;
+ const char* bonus_name;
if (bonus < bonus_count)
bonus_name = bonus_names[bonus];
else
int i = 0;
while (!done) {
if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') {
- text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * (i - lastline)*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
+ text->glPrintOutlined(1, 1, 1, tutorialopac, screenwidth / 2 - 7.6 * (i - lastline) * screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i);
lastline = i + 1;
line++;
if (string[i] == '\0')
string = std::string(tempname) + ": ";
if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) {
- text->glPrintOutlined(0.7, 0.7, 0.7, tutorialopac, startx - 2 * 7.6 * string.size()*screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
+ text->glPrintOutlined(0.7, 0.7, 0.7, tutorialopac, startx - 2 * 7.6 * string.size() * screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
} else {
glColor4f(0, 0, 0, tutorialopac);
- text->glPrintOutline(startx - 2 * 7.6 * string.size()*screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
+ text->glPrintOutline(startx - 2 * 7.6 * string.size() * screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight);
}
tempnum = 0;
glColor4f(.5, .5, .5, 1);
-
if ((texttoggle || editorenabled) && devtools && !mainmenu) {
string = "The framespersecond is " + to_string(int(fps));
text->glPrint(10, 30, string, 0, .8, 1024, 768);
string = "Object type: " + to_string(editortype);
text->glPrint(10, 120, string, 0, .8, 1024, 768);
switch (editortype) {
- case boxtype:
- string = "(box)";
- break;
- case treetrunktype:
- string = "(tree)";
- break;
- case walltype:
- string = "(wall)";
- break;
- case weirdtype:
- string = "(weird)";
- break;
- case spiketype:
- string = "(spike)";
- break;
- case rocktype:
- string = "(rock)";
- break;
- case bushtype:
- string = "(bush)";
- break;
- case tunneltype:
- string = "(tunnel)";
- break;
- case chimneytype:
- string = "(chimney)";
- break;
- case platformtype:
- string = "(platform)";
- break;
- case cooltype:
- string = "(cool)";
- break;
- case firetype:
- string = "(fire)";
- break;
+ case boxtype:
+ string = "(box)";
+ break;
+ case treetrunktype:
+ string = "(tree)";
+ break;
+ case walltype:
+ string = "(wall)";
+ break;
+ case weirdtype:
+ string = "(weird)";
+ break;
+ case spiketype:
+ string = "(spike)";
+ break;
+ case rocktype:
+ string = "(rock)";
+ break;
+ case bushtype:
+ string = "(bush)";
+ break;
+ case tunneltype:
+ string = "(tunnel)";
+ break;
+ case chimneytype:
+ string = "(chimney)";
+ break;
+ case platformtype:
+ string = "(platform)";
+ break;
+ case cooltype:
+ string = "(cool)";
+ break;
+ case firetype:
+ string = "(fire)";
+ break;
}
text->glPrint(130, 120, string, 0, .8, 1024, 768);
}
string = "Difficulty: " + to_string(difficulty);
text->glPrint(10, 240, string, 0, .8, 1024, 768);
-
}
}
glEnable(GL_BLEND);
glColor4f(0, 0, 0, .5);
glBegin(GL_QUADS);
- glVertex3f(0, 0, 0.0f);
+ glVertex3f(0, 0, 0.0f);
glVertex3f(256, 0, 0.0f);
glVertex3f(256, 256, 0.0f);
glVertex3f(0, 256, 0.0f);
blackout = .6;
glColor4f(0, 0, 0, blackout);
if (!Person::players[0]->dead) {
- if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5))*.3 < .3) {
- glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)*.3);
+ if ((Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5)) * .3 < .3) {
+ glColor4f(0, 0, 0, Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3);
blackout = Person::players[0]->blooddimamount * Person::players[0]->bloodloss / Person::players[0]->damagetolerance * (sin(woozy) / 4 + .5) * .3;
} else {
glColor4f(0, 0, 0, Person::players[0]->blooddimamount * .3);
if (console)
glColor4f(.7, 0, 0, .2);
glBegin(GL_QUADS);
- glVertex3f(0, 0, 0.0f);
- glVertex3f(256, 0, 0.0f);
+ glVertex3f(0, 0, 0.0f);
+ glVertex3f(256, 0, 0.0f);
glVertex3f(256, 256, 0.0f);
glVertex3f(0, 256, 0.0f);
glEnd();
glEnable(GL_BLEND);
glColor4f(flashr, flashg, flashb, flashamount);
glBegin(GL_QUADS);
- glVertex3f(0, 0, 0.0f);
+ glVertex3f(0, 0, 0.0f);
glVertex3f(256, 0, 0.0f);
glVertex3f(256, 256, 0.0f);
glVertex3f(0, 256, 0.0f);
float mapviewdist = 20000;
glDisable(GL_DEPTH_TEST);
- glColor3f (1.0, 1.0, 1.0); // no coloring
+ glColor3f(1.0, 1.0, 1.0); // no coloring
glEnable(GL_TEXTURE_2D);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
//logo
glDisable(GL_DEPTH_TEST);
- glColor3f (1.0, 1.0, 1.0); // no coloring
+ glColor3f(1.0, 1.0, 1.0); // no coloring
glEnable(GL_TEXTURE_2D);
//logo
glDisable(GL_DEPTH_TEST);
- glColor3f (1.0, 1.0, 1.0); // no coloring
+ glColor3f(1.0, 1.0, 1.0); // no coloring
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_CONSTANT);
glTexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE, 2.0f);
- glBindTexture( GL_TEXTURE_2D, screentexture);
+ glBindTexture(GL_TEXTURE_2D, screentexture);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
}
}
if ((drawtoggle || change == 1) && drawmode == realmotionblurmode) {
if (screentexture2) {
- glBindTexture( GL_TEXTURE_2D, screentexture2);
+ glBindTexture(GL_TEXTURE_2D, screentexture2);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texviewwidth, texviewheight);
}
if (!screentexture2) {
- glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glGenTextures( 1, &screentexture2 );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ glGenTextures(1, &screentexture2);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, screentexture2);
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glBindTexture(GL_TEXTURE_2D, screentexture2);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
}
glDrawBuffer(GL_FRONT);
glReadBuffer(GL_BACK);
}
- glColor3f (1.0, 1.0, 1.0); // no coloring
+ glColor3f(1.0, 1.0, 1.0); // no coloring
glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, screentexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glBindTexture(GL_TEXTURE_2D, screentexture);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- glBindTexture( GL_TEXTURE_2D, screentexture);
+ glBindTexture(GL_TEXTURE_2D, screentexture);
glColor4f(1, 1, 1, .5);
glPushMatrix();
glBegin(GL_QUADS);
glVertex3f(-1, 1, 0.0f);
glEnd();
glPopMatrix();
- glBindTexture( GL_TEXTURE_2D, screentexture2);
+ glBindTexture(GL_TEXTURE_2D, screentexture2);
glColor4f(1, 1, 1, .5);
glPushMatrix();
glBegin(GL_QUADS);
multiplier = 0;
}
- if ( side == stereoRight || side == stereoCenter ) {
+ if (side == stereoRight || side == stereoCenter) {
if (drawmode != motionblurmode || mainmenu) {
swap_gl_buffers();
}
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
Game::ReSizeGLScene(90, .1f);
//draw menu background
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
glColor4f(0, 0, 0, 1.0);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glVertex3f(-1, -1, 0);
glEnd();
glEnable(GL_BLEND);
glColor4f(0.4, 0.4, 0.4, 1.0);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glEnable(GL_TEXTURE_2D);
Game::Mainmenuitems[4].bind();
glBegin(GL_QUADS);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
-
-
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glColor4f(1, 1, 1, 1);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glPopMatrix();
if (!Game::waiting) { // hide the cursor while waiting for a key
glPushMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
-
//draw screen flash
if (flashamount > 0) {
if (flashamount > 1)
extern int accountcampaignchoicesmade[10];
extern int accountcampaignchoices[10][5000];
-void LOG(const std::string &, ...)
+void LOG(const std::string&, ...)
{
// !!! FIXME: write me.
}
Dispose();
}
-
-
-void LoadSave(const std::string& fileName, GLubyte *array)
+void LoadSave(const std::string& fileName, GLubyte* array)
{
LOGFUNC;
}
}
-
-
//***************> ResizeGLScene() <******/
GLvoid Game::ReSizeGLScene(float fov, float pnear)
{
}
static float loadprogress;
- static AbsoluteTime frametime = {0, 0};
- AbsoluteTime currTime = UpTime ();
- double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
+ static AbsoluteTime frametime = { 0, 0 };
+ AbsoluteTime currTime = UpTime();
+ double deltaTime = (float)AbsoluteDeltaToDuration(currTime, frametime);
if (0 > deltaTime) // if negative microseconds
deltaTime /= -1000000.0;
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
loadtime += multiplier * 4;
loadprogress = loadtime;
glEnable(GL_TEXTURE_2D);
loadscreentexture.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
loadscreentexture.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
loadscreentexture.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
//Background
glDisable(GL_TEXTURE_2D);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glDisable(GL_LIGHTING);
FadeLoadingScreen(95);
-
gameon = 0;
mainmenu = 1;
Animation::loadAll();
}
-
void Game::LoadScreenTexture()
{
- glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if (!Game::screentexture)
- glGenTextures( 1, &Game::screentexture );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-
+ glGenTextures(1, &Game::screentexture);
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glEnable(GL_TEXTURE_2D);
- glBindTexture( GL_TEXTURE_2D, Game::screentexture);
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
+ glBindTexture(GL_TEXTURE_2D, Game::screentexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, kTextureSize, kTextureSize, 0);
}
terrain.breaktexture.load("Textures/Break.png", 0);
terrain.bloodtexture2.load("Textures/Blood.png", 0);
-
terrain.footprinttexture.load("Textures/Footprint.png", 0);
terrain.bodyprinttexture.load("Textures/Bodyprint.png", 0);
hawktexture.load("Textures/Hawk.png", 0);
-
Sprite::cloudtexture.load("Textures/Cloud.png", 1);
Sprite::cloudimpacttexture.load("Textures/CloudImpact.png", 1);
Sprite::bloodtexture.load("Textures/BloodParticle.png", 1);
SetUpLighting();
-
fadestart = .6;
gravity = -10;
visibleloading = false;
firstLoadDone = true;
}
-
#include "Level/Dialog.hpp"
#include "Level/Hotspot.hpp"
#include "Menu/Menu.hpp"
+#include "Tutorial.hpp"
#include "User/Settings.hpp"
#include "Utils/Folders.hpp"
#include "Utils/Input.hpp"
-#include "Tutorial.hpp"
#if PLATFORM_UNIX
#include <sys/stat.h>
#define snprintf(buf, size, format, ...) _sprintf_p(buf, size, format)
#endif
-
extern float multiplier;
extern XYZ viewer;
extern int environment;
float oldmusicvolume[4] = {};
int musicselected = 0;
-const char *rabbitskin[] = {
+const char* rabbitskin[] = {
"Textures/Fur3.jpg",
"Textures/Fur.jpg",
"Textures/Fur2.jpg",
"Textures/WB2.jpg"
};
-const char *wolfskin[] = {
+const char* wolfskin[] = {
"Textures/Wolf.jpg",
"Textures/DarkWolf.jpg",
"Textures/SnowWolf.jpg"
};
-const char **creatureskin[] = {rabbitskin, wolfskin};
+const char** creatureskin[] = { rabbitskin, wolfskin };
#define STATIC_ASSERT(x) extern int s_a_dummy[2 * (!!(x)) - 1];
-STATIC_ASSERT (rabbittype == 0 && wolftype == 1)
+STATIC_ASSERT(rabbittype == 0 && wolftype == 1)
// utility functions
int sound = -1;
switch (Dialog::currentScene().sound) {
- case -6:
- sound = alarmsound;
- break;
- case -4:
- sound = consolefailsound;
- break;
- case -3:
- sound = consolesuccesssound;
- break;
- case -2:
- sound = firestartsound;
- break;
- case -1:
- sound = fireendsound;
- break;
- case 1:
- sound = rabbitchitter;
- break;
- case 2:
- sound = rabbitchitter2;
- break;
- case 3:
- sound = rabbitpainsound;
- break;
- case 4:
- sound = rabbitpain1sound;
- break;
- case 5:
- sound = rabbitattacksound;
- break;
- case 6:
- sound = rabbitattack2sound;
- break;
- case 7:
- sound = rabbitattack3sound;
- break;
- case 8:
- sound = rabbitattack4sound;
- break;
- case 9:
- sound = growlsound;
- break;
- case 10:
- sound = growl2sound;
- break;
- case 11:
- sound = snarlsound;
- break;
- case 12:
- sound = snarl2sound;
- break;
- case 13:
- sound = barksound;
- break;
- case 14:
- sound = bark2sound;
- break;
- case 15:
- sound = bark3sound;
- break;
- case 16:
- sound = barkgrowlsound;
- break;
- default:
- break;
+ case -6:
+ sound = alarmsound;
+ break;
+ case -4:
+ sound = consolefailsound;
+ break;
+ case -3:
+ sound = consolesuccesssound;
+ break;
+ case -2:
+ sound = firestartsound;
+ break;
+ case -1:
+ sound = fireendsound;
+ break;
+ case 1:
+ sound = rabbitchitter;
+ break;
+ case 2:
+ sound = rabbitchitter2;
+ break;
+ case 3:
+ sound = rabbitpainsound;
+ break;
+ case 4:
+ sound = rabbitpain1sound;
+ break;
+ case 5:
+ sound = rabbitattacksound;
+ break;
+ case 6:
+ sound = rabbitattack2sound;
+ break;
+ case 7:
+ sound = rabbitattack3sound;
+ break;
+ case 8:
+ sound = rabbitattack4sound;
+ break;
+ case 9:
+ sound = growlsound;
+ break;
+ case 10:
+ sound = growl2sound;
+ break;
+ case 11:
+ sound = snarlsound;
+ break;
+ case 12:
+ sound = snarl2sound;
+ break;
+ case 13:
+ sound = barksound;
+ break;
+ case 14:
+ sound = bark2sound;
+ break;
+ case 15:
+ sound = bark3sound;
+ break;
+ case 16:
+ sound = barkgrowlsound;
+ break;
+ default:
+ break;
}
if (sound != -1)
emit_sound_at(sound, temppos);
for (unsigned int i = 0; i < Object::objects.size(); i++) {
float distance = distsq(&Object::objects[i]->position,
- &Person::players[0]->coords);
+ &Person::players[0]->coords);
if (distance < closestdist) {
closestdist = distance;
- closest = (int) i;
+ closest = (int)i;
}
}
return closest;
}
/********************> Tick() <*****/
-extern bool save_screenshot(const char * fname);
-void Screenshot (void)
+extern bool save_screenshot(const char* fname);
+void Screenshot(void)
{
char filename[1024];
time_t t = time(NULL);
- struct tm *tme = localtime(&t);
+ struct tm* tme = localtime(&t);
sprintf(filename, "Screenshot-%04d%02d%02d-%02d%02d%02d.png",
tme->tm_year + 1900, tme->tm_mon + 1, tme->tm_mday, tme->tm_hour, tme->tm_min, tme->tm_sec);
pause_sound(stream_wind);
pause_sound(stream_desertambient);
-
if (environment == snowyenvironment) {
windvector = 0;
windvector.z = 3;
terraintexture.load("Textures/Snow.jpg", 1);
terraintexture2.load("Textures/Rock.jpg", 1);
-
temptexdetail = texdetail;
if (texdetail > 1)
texdetail = 4;
- skybox->load( "Textures/Skybox(snow)/Front.jpg",
- "Textures/Skybox(snow)/Left.jpg",
- "Textures/Skybox(snow)/Back.jpg",
- "Textures/Skybox(snow)/Right.jpg",
- "Textures/Skybox(snow)/Up.jpg",
- "Textures/Skybox(snow)/Down.jpg");
-
+ skybox->load("Textures/Skybox(snow)/Front.jpg",
+ "Textures/Skybox(snow)/Left.jpg",
+ "Textures/Skybox(snow)/Back.jpg",
+ "Textures/Skybox(snow)/Right.jpg",
+ "Textures/Skybox(snow)/Up.jpg",
+ "Textures/Skybox(snow)/Down.jpg");
texdetail = temptexdetail;
} else if (environment == desertenvironment) {
Object::rocktextureptr.load("Textures/BoulderDesert.jpg", 1);
Object::boxtextureptr.load("Textures/DesertBox.jpg", 1);
-
if (ambientsound)
emit_stream_np(stream_desertambient);
terraintexture.load("Textures/Sand.jpg", 1);
terraintexture2.load("Textures/SandSlope.jpg", 1);
-
temptexdetail = texdetail;
if (texdetail > 1)
texdetail = 4;
- skybox->load( "Textures/Skybox(sand)/Front.jpg",
- "Textures/Skybox(sand)/Left.jpg",
- "Textures/Skybox(sand)/Back.jpg",
- "Textures/Skybox(sand)/Right.jpg",
- "Textures/Skybox(sand)/Up.jpg",
- "Textures/Skybox(sand)/Down.jpg");
-
+ skybox->load("Textures/Skybox(sand)/Front.jpg",
+ "Textures/Skybox(sand)/Left.jpg",
+ "Textures/Skybox(sand)/Back.jpg",
+ "Textures/Skybox(sand)/Right.jpg",
+ "Textures/Skybox(sand)/Up.jpg",
+ "Textures/Skybox(sand)/Down.jpg");
texdetail = temptexdetail;
} else if (environment == grassyenvironment) {
terraintexture.load("Textures/GrassDirt.jpg", 1);
terraintexture2.load("Textures/MossRock.jpg", 1);
-
temptexdetail = texdetail;
if (texdetail > 1)
texdetail = 4;
- skybox->load( "Textures/Skybox(grass)/Front.jpg",
- "Textures/Skybox(grass)/Left.jpg",
- "Textures/Skybox(grass)/Back.jpg",
- "Textures/Skybox(grass)/Right.jpg",
- "Textures/Skybox(grass)/Up.jpg",
- "Textures/Skybox(grass)/Down.jpg");
-
+ skybox->load("Textures/Skybox(grass)/Front.jpg",
+ "Textures/Skybox(grass)/Left.jpg",
+ "Textures/Skybox(grass)/Back.jpg",
+ "Textures/Skybox(grass)/Right.jpg",
+ "Textures/Skybox(grass)/Up.jpg",
+ "Textures/Skybox(grass)/Down.jpg");
texdetail = temptexdetail;
}
pause_sound(stream_firesound);
int mapvers;
- FILE *tfile;
+ FILE* tfile;
errno = 0;
tfile = Folders::openMandatoryFile(level_path, "rb");
}
}
-
Game::LoadingScreen();
if (cellophane) {
/* Grow tree leaves?? */
if (Input::isKeyPressed(SDL_SCANCODE_Y)) {
- for (auto& an_object : Object::objects) {
+ for (auto& an_object : Object::objects) {
if (an_object->type == treeleavestype) {
an_object->scale *= .9;
}
Person::players[closest]->whichskin = 0;
Person::players[closest]->skeleton.drawmodel.textureptr.load(creatureskin[Person::players[closest]->creature][Person::players[closest]->whichskin], 1,
- &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
+ &Person::players[closest]->skeleton.skinText[0], &Person::players[closest]->skeleton.skinsize);
}
Person::players[closest]->addClothes();
legprop = Person::players[closest]->proportionlegs.x / 1.1;
}
-
if (Person::players[closest]->creature == rabbittype) {
Person::players[closest]->creature = wolftype;
Person::players[closest]->whichskin = 0;
Person::players[closest]->proportionlegs = 1.1 * legprop;
Person::players[closest]->proportionlegs.y = 1.05 * legprop;
}
-
}
}
Person::players[closest]->skeleton.free = 2;
camerashake += .6;
-
}
}
if (Input::isKeyPressed(SDL_SCANCODE_DELETE) && Input::isKeyDown(SDL_SCANCODE_LSHIFT)) {
int closest = findClosestPlayer();
if (closest >= 0) {
- Person::players.erase(Person::players.begin()+closest);
+ Person::players.erase(Person::players.begin() + closest);
}
}
if (Input::isKeyPressed(SDL_SCANCODE_P) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && !Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
Person::players.push_back(shared_ptr<Person>(new Person()));
- Person::players.back()->id = Person::players.size()-1;
+ Person::players.back()->id = Person::players.size() - 1;
Person::players.back()->scale = Person::players[0]->scale;
Person::players.back()->creature = rabbittype;
editorsize = .1;
}
-
if (Input::isKeyPressed(SDL_SCANCODE_LEFT) && Input::isKeyDown(SDL_SCANCODE_LSHIFT) && Input::isKeyDown(SDL_SCANCODE_LCTRL)) {
mapradius -= multiplier * 10;
}
{
for (unsigned k = 0; k < Person::players.size(); k++) {
for (unsigned i = k + 1; i < Person::players.size(); i++) {
- if ( Person::players[k]->skeleton.free == 0 &&
- Person::players[i]->skeleton.oldfree == 0 &&
- (Person::players[i]->animTarget == jumpupanim ||
- Person::players[k]->animTarget == jumpupanim) &&
- (Person::players[i]->aitype == playercontrolled ||
- Person::players[k]->aitype == playercontrolled) &&
- ((Person::players[i]->aitype == attacktypecutoff && Person::players[i]->stunned <= 0) ||
- (Person::players[k]->aitype == attacktypecutoff && Person::players[k]->stunned <= 0))) {
- if ( distsq(&Person::players[i]->coords, &Person::players[k]->coords) < 10 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5) &&
- distsqflat(&Person::players[i]->coords, &Person::players[k]->coords) < 2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5)) {
+ if (Person::players[k]->skeleton.free == 0 &&
+ Person::players[i]->skeleton.oldfree == 0 &&
+ (Person::players[i]->animTarget == jumpupanim ||
+ Person::players[k]->animTarget == jumpupanim) &&
+ (Person::players[i]->aitype == playercontrolled ||
+ Person::players[k]->aitype == playercontrolled) &&
+ ((Person::players[i]->aitype == attacktypecutoff && Person::players[i]->stunned <= 0) ||
+ (Person::players[k]->aitype == attacktypecutoff && Person::players[k]->stunned <= 0))) {
+ if (distsq(&Person::players[i]->coords, &Person::players[k]->coords) < 10 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5) &&
+ distsqflat(&Person::players[i]->coords, &Person::players[k]->coords) < 2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5)) {
//TODO: refactor two huge similar ifs
if (Person::players[i]->animTarget == jumpupanim &&
- Person::players[k]->animTarget != getupfrombackanim &&
- Person::players[k]->animTarget != getupfromfrontanim &&
- Animation::animations[Person::players[k]->animTarget].height == middleheight &&
- normaldotproduct(Person::players[i]->velocity, Person::players[k]->coords - Person::players[i]->coords) < 0 &&
- ((Person::players[k]->aitype == playercontrolled && Person::players[k]->attackkeydown) ||
- Person::players[k]->aitype != playercontrolled)) {
+ Person::players[k]->animTarget != getupfrombackanim &&
+ Person::players[k]->animTarget != getupfromfrontanim &&
+ Animation::animations[Person::players[k]->animTarget].height == middleheight &&
+ normaldotproduct(Person::players[i]->velocity, Person::players[k]->coords - Person::players[i]->coords) < 0 &&
+ ((Person::players[k]->aitype == playercontrolled && Person::players[k]->attackkeydown) ||
+ Person::players[k]->aitype != playercontrolled)) {
Person::players[i]->victim = Person::players[k];
Person::players[i]->velocity = 0;
Person::players[i]->animCurrent = jumpreversedanim;
Person::players[k]->stunned = .5;
}
if (Person::players[k]->animTarget == jumpupanim &&
- Person::players[i]->animTarget != getupfrombackanim &&
- Person::players[i]->animTarget != getupfromfrontanim &&
- Animation::animations[Person::players[i]->animTarget].height == middleheight &&
- normaldotproduct(Person::players[k]->velocity, Person::players[i]->coords - Person::players[k]->coords) < 0 &&
- ((Person::players[i]->aitype == playercontrolled && Person::players[i]->attackkeydown) ||
- Person::players[i]->aitype != playercontrolled)) {
+ Person::players[i]->animTarget != getupfrombackanim &&
+ Person::players[i]->animTarget != getupfromfrontanim &&
+ Animation::animations[Person::players[i]->animTarget].height == middleheight &&
+ normaldotproduct(Person::players[k]->velocity, Person::players[i]->coords - Person::players[k]->coords) < 0 &&
+ ((Person::players[i]->aitype == playercontrolled && Person::players[i]->attackkeydown) ||
+ Person::players[i]->aitype != playercontrolled)) {
Person::players[k]->victim = Person::players[i];
Person::players[k]->velocity = 0;
Person::players[k]->animCurrent = jumpreversedanim;
Person::players[k]->turnspeed = 500;
if ((Person::players[k]->isRun() &&
- ((Person::players[k]->targetyaw != rabbitrunninganim &&
- Person::players[k]->targetyaw != wolfrunninganim) ||
- Person::players[k]->frameTarget == 4)) ||
- Person::players[k]->animTarget == removeknifeanim ||
- Person::players[k]->animTarget == crouchremoveknifeanim ||
- Person::players[k]->animTarget == flipanim ||
- Person::players[k]->animTarget == fightsidestep ||
- Person::players[k]->animTarget == walkanim) {
+ ((Person::players[k]->targetyaw != rabbitrunninganim &&
+ Person::players[k]->targetyaw != wolfrunninganim) ||
+ Person::players[k]->frameTarget == 4)) ||
+ Person::players[k]->animTarget == removeknifeanim ||
+ Person::players[k]->animTarget == crouchremoveknifeanim ||
+ Person::players[k]->animTarget == flipanim ||
+ Person::players[k]->animTarget == fightsidestep ||
+ Person::players[k]->animTarget == walkanim) {
Person::players[k]->yaw = stepTowardf(Person::players[k]->yaw, Person::players[k]->targetyaw, multiplier * Person::players[k]->turnspeed);
}
-
if (Person::players[k]->isStop() ||
- Person::players[k]->isLanding() ||
- Person::players[k]->animTarget == staggerbackhighanim ||
- (Person::players[k]->animTarget == sneakanim && Person::players[k]->animCurrent == sneakanim) ||
- Person::players[k]->animTarget == staggerbackhardanim ||
- Person::players[k]->animTarget == backhandspringanim ||
- Person::players[k]->animTarget == dodgebackanim ||
- Person::players[k]->animTarget == rollanim ||
- (Animation::animations[Person::players[k]->animTarget].attack &&
- Person::players[k]->animTarget != rabbitkickanim &&
- (Person::players[k]->animTarget != crouchstabanim || Person::players[k]->hasvictim) &&
- (Person::players[k]->animTarget != swordgroundstabanim || Person::players[k]->hasvictim))) {
+ Person::players[k]->isLanding() ||
+ Person::players[k]->animTarget == staggerbackhighanim ||
+ (Person::players[k]->animTarget == sneakanim && Person::players[k]->animCurrent == sneakanim) ||
+ Person::players[k]->animTarget == staggerbackhardanim ||
+ Person::players[k]->animTarget == backhandspringanim ||
+ Person::players[k]->animTarget == dodgebackanim ||
+ Person::players[k]->animTarget == rollanim ||
+ (Animation::animations[Person::players[k]->animTarget].attack &&
+ Person::players[k]->animTarget != rabbitkickanim &&
+ (Person::players[k]->animTarget != crouchstabanim || Person::players[k]->hasvictim) &&
+ (Person::players[k]->animTarget != swordgroundstabanim || Person::players[k]->hasvictim))) {
Person::players[k]->yaw = stepTowardf(Person::players[k]->yaw, Person::players[k]->targetyaw, multiplier * Person::players[k]->turnspeed * 2);
}
//if player's position has changed (?)
if (distsq(&Person::players[k]->coords, &Person::players[k]->realoldcoords) > 0 &&
- !Person::players[k]->skeleton.free &&
- Person::players[k]->animTarget != climbanim &&
- Person::players[k]->animTarget != hanganim) {
+ !Person::players[k]->skeleton.free &&
+ Person::players[k]->animTarget != climbanim &&
+ Person::players[k]->animTarget != hanganim) {
XYZ lowpoint, lowpointtarget, lowpoint2, lowpointtarget2, lowpoint3, lowpointtarget3, lowpoint4, lowpointtarget4, lowpoint5, lowpointtarget5, lowpoint6, lowpointtarget6, lowpoint7, lowpointtarget7, colpoint, colpoint2;
int whichhit;
bool tempcollide = 0;
for (unsigned int l = 0; l < terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz].size(); l++) {
unsigned int i = terrain.patchobjects[Person::players[k]->whichpatchx][Person::players[k]->whichpatchz][l];
if (Object::objects[i]->type != rocktype ||
- Object::objects[i]->scale > .5 && Person::players[k]->aitype == playercontrolled ||
- Object::objects[i]->position.y > Person::players[k]->coords.y) {
+ Object::objects[i]->scale > .5 && Person::players[k]->aitype == playercontrolled ||
+ Object::objects[i]->position.y > Person::players[k]->coords.y) {
lowpoint = Person::players[k]->coords;
if (Person::players[k]->animTarget != jumpupanim &&
- Person::players[k]->animTarget != jumpdownanim &&
- !Person::players[k]->isFlip())
+ Person::players[k]->animTarget != jumpdownanim &&
+ !Person::players[k]->isFlip())
lowpoint.y += 1.25;
else
lowpoint.y += 1.3;
- if ( Person::players[k]->coords.y < terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) &&
- Person::players[k]->coords.y > terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) - .1)
+ if (Person::players[k]->coords.y < terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) &&
+ Person::players[k]->coords.y > terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z) - .1)
Person::players[k]->coords.y = terrain.getHeight(Person::players[k]->coords.x, Person::players[k]->coords.z);
if (Person::players[k]->SphereCheck(&lowpoint, 1.3, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
flatfacing = lowpoint - Person::players[k]->coords;
//wall jumps
//TODO: refactor four similar blocks
if (Person::players[k]->aitype == playercontrolled &&
- (Person::players[k]->animTarget == jumpupanim ||
- Person::players[k]->animTarget == jumpdownanim ||
- Person::players[k]->isFlip()) &&
- !Person::players[k]->jumptogglekeydown &&
- Person::players[k]->jumpkeydown) {
+ (Person::players[k]->animTarget == jumpupanim ||
+ Person::players[k]->animTarget == jumpdownanim ||
+ Person::players[k]->isFlip()) &&
+ !Person::players[k]->jumptogglekeydown &&
+ Person::players[k]->jumpkeydown) {
lowpointtarget = lowpoint + DoRotation(Person::players[k]->facing, 0, -90, 0) * 1.5;
XYZ tempcoords1 = lowpoint;
whichhit = Object::objects[i]->model.LineCheck(&lowpoint, &lowpointtarget, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw);
if (Object::objects[i]->type != rocktype)
if (Person::players[k]->SphereCheck(&lowpoint, 1.33, &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw, &Object::objects[i]->model) != -1) {
if (Person::players[k]->animTarget != jumpupanim &&
- Person::players[k]->animTarget != jumpdownanim &&
- Person::players[k]->onterrain)
+ Person::players[k]->animTarget != jumpdownanim &&
+ Person::players[k]->onterrain)
Person::players[k]->avoidcollided = 1;
Person::players[k]->coords = lowpoint;
Person::players[k]->coords.y -= 1.35;
Person::players[k]->collide = 1;
if ((Person::players[k]->grabdelay <= 0 || Person::players[k]->aitype != playercontrolled) &&
- (Person::players[k]->animCurrent != climbanim &&
+ (Person::players[k]->animCurrent != climbanim &&
Person::players[k]->animCurrent != hanganim &&
!Person::players[k]->isWallJump() ||
- Person::players[k]->animTarget == jumpupanim ||
- Person::players[k]->animTarget == jumpdownanim)) {
+ Person::players[k]->animTarget == jumpupanim ||
+ Person::players[k]->animTarget == jumpdownanim)) {
lowpoint = Person::players[k]->coords;
Object::objects[i]->model.SphereCheckPossible(&lowpoint, 1.5, &Object::objects[i]->position, &Object::objects[i]->yaw);
lowpoint = Person::players[k]->coords;
Person::players[k]->collided = 1;
if (Object::checkcollide(lowpoint7, lowpointtarget7) == -1)
if (Object::checkcollide(lowpoint6, lowpointtarget6) == -1)
- if ( Object::objects[i]->model.LineCheckPossible(&lowpoint2, &lowpointtarget2,
- &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
- Object::objects[i]->model.LineCheckPossible(&lowpoint3, &lowpointtarget3,
- &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
- Object::objects[i]->model.LineCheckPossible(&lowpoint4, &lowpointtarget4,
- &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
- Object::objects[i]->model.LineCheckPossible(&lowpoint5, &lowpointtarget5,
- &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
+ if (Object::objects[i]->model.LineCheckPossible(&lowpoint2, &lowpointtarget2,
+ &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
+ Object::objects[i]->model.LineCheckPossible(&lowpoint3, &lowpointtarget3,
+ &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
+ Object::objects[i]->model.LineCheckPossible(&lowpoint4, &lowpointtarget4,
+ &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1 &&
+ Object::objects[i]->model.LineCheckPossible(&lowpoint5, &lowpointtarget5,
+ &colpoint, &Object::objects[i]->position, &Object::objects[i]->yaw) != -1)
for (int j = 0; j < 45; j++) {
lowpoint = Person::players[k]->coords;
lowpoint.y += (float)j / 13;
lowpointtarget = lowpoint + facing * 1.4;
if (Object::objects[i]->model.LineCheckPossible(&lowpoint, &lowpointtarget,
- &colpoint2, &Object::objects[i]->position, &Object::objects[i]->yaw) == -1) {
+ &colpoint2, &Object::objects[i]->position, &Object::objects[i]->yaw) == -1) {
if (j <= 6 || j <= 25 && Person::players[k]->animTarget == jumpdownanim)
break;
if (Person::players[k]->animTarget == jumpupanim || Person::players[k]->animTarget == jumpdownanim) {
if (Person::players[k]->collide <= 0) {
//in the air
if (!Person::players[k]->onterrain &&
- Person::players[k]->animTarget != jumpupanim &&
- Person::players[k]->animTarget != jumpdownanim &&
- Person::players[k]->animTarget != climbanim &&
- Person::players[k]->animTarget != hanganim &&
- !Person::players[k]->isWallJump() &&
- !Person::players[k]->isFlip()) {
+ Person::players[k]->animTarget != jumpupanim &&
+ Person::players[k]->animTarget != jumpdownanim &&
+ Person::players[k]->animTarget != climbanim &&
+ Person::players[k]->animTarget != hanganim &&
+ !Person::players[k]->isWallJump() &&
+ !Person::players[k]->isFlip()) {
if (Person::players[k]->animCurrent != climbanim &&
- Person::players[k]->animCurrent != tempanim &&
- Person::players[k]->animTarget != backhandspringanim &&
- (Person::players[k]->animTarget != rollanim ||
- Person::players[k]->frameTarget < 2 ||
- Person::players[k]->frameTarget > 6)) {
+ Person::players[k]->animCurrent != tempanim &&
+ Person::players[k]->animTarget != backhandspringanim &&
+ (Person::players[k]->animTarget != rollanim ||
+ Person::players[k]->frameTarget < 2 ||
+ Person::players[k]->frameTarget > 6)) {
//stagger off ledge (?)
if (Person::players[k]->animTarget == staggerbackhighanim || Person::players[k]->animTarget == staggerbackhardanim)
Person::players[k]->RagDoll(0);
if (!oldattackkey)
playerrealattackkeydown = Input::isKeyDown(attackkey);
if ((Person::players[0]->parriedrecently <= 0 ||
- Person::players[0]->weaponactive == -1) &&
- (!oldattackkey ||
- (realthreat &&
- Person::players[0]->lastattack != swordslashanim &&
- Person::players[0]->lastattack != knifeslashstartanim &&
- Person::players[0]->lastattack != staffhitanim &&
- Person::players[0]->lastattack != staffspinhitanim)))
+ Person::players[0]->weaponactive == -1) &&
+ (!oldattackkey ||
+ (realthreat &&
+ Person::players[0]->lastattack != swordslashanim &&
+ Person::players[0]->lastattack != knifeslashstartanim &&
+ Person::players[0]->lastattack != staffhitanim &&
+ Person::players[0]->lastattack != staffspinhitanim)))
Person::players[0]->attackkeydown = Input::isKeyDown(attackkey);
if (Input::isKeyDown(attackkey) &&
- !oldattackkey &&
- !Person::players[0]->backkeydown) {
+ !oldattackkey &&
+ !Person::players[0]->backkeydown) {
for (unsigned k = 0; k < Person::players.size(); k++) {
if ((Person::players[k]->animTarget == swordslashanim ||
- Person::players[k]->animTarget == staffhitanim ||
- Person::players[k]->animTarget == staffspinhitanim) &&
- Person::players[0]->animCurrent != dodgebackanim &&
- !Person::players[k]->skeleton.free)
+ Person::players[k]->animTarget == staffhitanim ||
+ Person::players[k]->animTarget == staffspinhitanim) &&
+ Person::players[0]->animCurrent != dodgebackanim &&
+ !Person::players[k]->skeleton.free)
Person::players[k]->Reverse();
}
}
if (Person::players[k]->attackkeydown) {
//dodge backward
if (Person::players[k]->backkeydown &&
- Person::players[k]->animTarget != backhandspringanim &&
- (Person::players[k]->isIdle() ||
- Person::players[k]->isStop() ||
- Person::players[k]->isRun() ||
- Person::players[k]->animTarget == walkanim)) {
+ Person::players[k]->animTarget != backhandspringanim &&
+ (Person::players[k]->isIdle() ||
+ Person::players[k]->isStop() ||
+ Person::players[k]->isRun() ||
+ Person::players[k]->animTarget == walkanim)) {
if (Person::players[k]->jumppower <= 1) {
Person::players[k]->jumppower -= 2;
} else {
if (i == k)
continue;
if (Person::players[i]->animTarget == swordslashanim ||
- Person::players[i]->animTarget == knifeslashstartanim ||
- Person::players[i]->animTarget == staffhitanim ||
- Person::players[i]->animTarget == staffspinhitanim)
+ Person::players[i]->animTarget == knifeslashstartanim ||
+ Person::players[i]->animTarget == staffhitanim ||
+ Person::players[i]->animTarget == staffspinhitanim)
if (distsq(&Person::players[k]->coords, &Person::players[i]->coords) < 6.5 && !Person::players[i]->skeleton.free) {
Person::players[k]->setTargetAnimation(dodgebackanim);
Person::players[k]->targetyaw = roughDirectionTo(Person::players[k]->coords, Person::players[i]->coords);
}
//attack
if (!Animation::animations[Person::players[k]->animTarget].attack &&
- !Person::players[k]->backkeydown &&
- (Person::players[k]->isIdle() ||
- Person::players[k]->isRun() ||
- Person::players[k]->animTarget == walkanim ||
- Person::players[k]->animTarget == sneakanim ||
- Person::players[k]->isCrouch())) {
+ !Person::players[k]->backkeydown &&
+ (Person::players[k]->isIdle() ||
+ Person::players[k]->isRun() ||
+ Person::players[k]->animTarget == walkanim ||
+ Person::players[k]->animTarget == sneakanim ||
+ Person::players[k]->isCrouch())) {
const int attackweapon = Person::players[k]->weaponactive == -1 ? 0 : weapons[Person::players[k]->weaponids[Person::players[k]->weaponactive]].getType();
//normal attacks (?)
Person::players[k]->hasvictim = 0;
//choose an attack
const float distance = distsq(&Person::players[k]->coords, &Person::players[i]->coords);
if (distance < 4.5 &&
- !Person::players[i]->skeleton.free &&
- Person::players[i]->howactive < typedead1 &&
- Person::players[i]->animTarget != jumpreversedanim &&
- Person::players[i]->animTarget != rabbitkickreversedanim &&
- Person::players[i]->animTarget != rabbitkickanim &&
- Person::players[k]->animTarget != rabbitkickanim &&
- Person::players[i]->animTarget != getupfrombackanim &&
- (Person::players[i]->animTarget != staggerbackhighanim &&
- (Person::players[i]->animTarget != staggerbackhardanim || Person::players[i]->targetFrame().label == 6)) &&
- Person::players[i]->animTarget != jumpdownanim &&
- Person::players[i]->animTarget != jumpupanim &&
- Person::players[i]->animTarget != getupfromfrontanim) {
+ !Person::players[i]->skeleton.free &&
+ Person::players[i]->howactive < typedead1 &&
+ Person::players[i]->animTarget != jumpreversedanim &&
+ Person::players[i]->animTarget != rabbitkickreversedanim &&
+ Person::players[i]->animTarget != rabbitkickanim &&
+ Person::players[k]->animTarget != rabbitkickanim &&
+ Person::players[i]->animTarget != getupfrombackanim &&
+ (Person::players[i]->animTarget != staggerbackhighanim &&
+ (Person::players[i]->animTarget != staggerbackhardanim || Person::players[i]->targetFrame().label == 6)) &&
+ Person::players[i]->animTarget != jumpdownanim &&
+ Person::players[i]->animTarget != jumpupanim &&
+ Person::players[i]->animTarget != getupfromfrontanim) {
Person::players[k]->victim = Person::players[i];
Person::players[k]->hasvictim = 1;
if (Person::players[k]->aitype == playercontrolled) { //human player
//sweep
if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- Person::players[k]->crouchkeydown &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ Person::players[k]->crouchkeydown &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight)
Person::players[k]->animTarget = sweepanim;
//winduppunch
else if (distance < 1.5 * sq(Person::players[k]->scale * 5) &&
if (attackweapon) {
//sweep
if ((!Tutorial::active || !attackweapon) &&
- distance < 2.5 * sq(Person::players[k]->scale * 5) &&
- randattack == 0 &&
- Animation::animations[Person::players[i]->animTarget].height != lowheight)
+ distance < 2.5 * sq(Person::players[k]->scale * 5) &&
+ randattack == 0 &&
+ Animation::animations[Person::players[i]->animTarget].height != lowheight)
Person::players[k]->animTarget = sweepanim;
//knifeslashstart
else if (distance < 2.5 * sq(Person::players[k]->scale * 5) &&
}
//sneak attacks
if ((k == 0) && (!Tutorial::active || Tutorial::stage == 22) &&
- Person::players[i]->howactive < typedead1 &&
- distance < 1.5 * sq(Person::players[k]->scale * 5) &&
- !Person::players[i]->skeleton.free &&
- Person::players[i]->animTarget != getupfrombackanim &&
- Person::players[i]->animTarget != getupfromfrontanim &&
- (Person::players[i]->surprised > 0 ||
- Person::players[i]->aitype == passivetype ||
- attackweapon && Person::players[i]->stunned > 0) &&
- normaldotproduct(Person::players[i]->facing, Person::players[i]->coords - Person::players[k]->coords) > 0) {
+ Person::players[i]->howactive < typedead1 &&
+ distance < 1.5 * sq(Person::players[k]->scale * 5) &&
+ !Person::players[i]->skeleton.free &&
+ Person::players[i]->animTarget != getupfrombackanim &&
+ Person::players[i]->animTarget != getupfromfrontanim &&
+ (Person::players[i]->surprised > 0 ||
+ Person::players[i]->aitype == passivetype ||
+ attackweapon && Person::players[i]->stunned > 0) &&
+ normaldotproduct(Person::players[i]->facing, Person::players[i]->coords - Person::players[k]->coords) > 0) {
//sneakattack
if (!attackweapon) {
Person::players[k]->animCurrent = sneakattackanim;
}
}
if (Animation::animations[Person::players[k]->animTarget].attack == normalattack &&
- Person::players[k]->victim == Person::players[i] &&
- (!Person::players[i]->skeleton.free)) {
+ Person::players[k]->victim == Person::players[i] &&
+ (!Person::players[i]->skeleton.free)) {
oldattackkey = 1;
Person::players[k]->frameTarget = 0;
Person::players[k]->target = 0;
Person::players[k]->lastattack = Person::players[k]->animTarget;
}
if (Person::players[k]->animTarget == knifefollowanim &&
- Person::players[k]->victim == Person::players[i]) {
+ Person::players[k]->victim == Person::players[i]) {
oldattackkey = 1;
Person::players[k]->targetyaw = roughDirectionTo(Person::players[k]->coords, Person::players[i]->coords);
Person::players[k]->targettilt2 = pitchTo(Person::players[k]->coords, Person::players[i]->coords);
if (i == k)
continue;
if ((playerrealattackkeydown || Person::players[i]->dead || !hasstaff) &&
- Animation::animations[Person::players[k]->animTarget].attack == neutral) {
+ Animation::animations[Person::players[k]->animTarget].attack == neutral) {
const float distance = distsq(&Person::players[k]->coords, &Person::players[i]->coords);
if (!Person::players[i]->dead || !realthreat || (!attackweapon && Person::players[k]->crouchkeydown))
if (Person::players[i]->skeleton.free)
if (distance < 3.5 * sq(Person::players[k]->scale * 5) &&
- (Person::players[i]->dead ||
- Person::players[i]->skeleton.longdead > 1000 ||
- Person::players[k]->isRun() ||
- hasstaff ||
- (attackweapon &&
- (Person::players[i]->skeleton.longdead > 2000 ||
- Person::players[i]->damage > Person::players[i]->damagetolerance / 8 ||
- Person::players[i]->bloodloss > Person::players[i]->damagetolerance / 2) &&
- distance < 1.5 * sq(Person::players[k]->scale * 5)))) {
+ (Person::players[i]->dead ||
+ Person::players[i]->skeleton.longdead > 1000 ||
+ Person::players[k]->isRun() ||
+ hasstaff ||
+ (attackweapon &&
+ (Person::players[i]->skeleton.longdead > 2000 ||
+ Person::players[i]->damage > Person::players[i]->damagetolerance / 8 ||
+ Person::players[i]->bloodloss > Person::players[i]->damagetolerance / 2) &&
+ distance < 1.5 * sq(Person::players[k]->scale * 5)))) {
Person::players[k]->victim = Person::players[i];
Person::players[k]->hasvictim = 1;
if (attackweapon && !Tutorial::active) {
Person::players[k]->animTarget = staffgroundsmashanim;
}
if (distance < 2.5 &&
- Person::players[k]->crouchkeydown &&
- Person::players[k]->animTarget != crouchstabanim &&
- !attackweapon &&
- Person::players[i]->dead &&
- Person::players[i]->skeleton.free &&
- Person::players[i]->skeleton.longdead > 1000) {
+ Person::players[k]->crouchkeydown &&
+ Person::players[k]->animTarget != crouchstabanim &&
+ !attackweapon &&
+ Person::players[i]->dead &&
+ Person::players[i]->skeleton.free &&
+ Person::players[i]->skeleton.longdead > 1000) {
Person::players[k]->animTarget = killanim;
terrain.deleteDeadDecals();
for (unsigned int l = 0; l < Object::objects.size(); l++) {
}
if (!Person::players[i]->dead || musictype != 2)
if (distance < 3.5 &&
- (Person::players[k]->isRun() || Person::players[k]->isIdle() && Person::players[k]->attackkeydown) &&
- Person::players[k]->staggerdelay <= 0 &&
- (Person::players[i]->dead ||
- Person::players[i]->skeleton.longdead < 300 &&
+ (Person::players[k]->isRun() || Person::players[k]->isIdle() && Person::players[k]->attackkeydown) &&
+ Person::players[k]->staggerdelay <= 0 &&
+ (Person::players[i]->dead ||
+ Person::players[i]->skeleton.longdead < 300 &&
Person::players[k]->lastattack != spinkickanim &&
Person::players[i]->skeleton.free) &&
- (!Person::players[i]->dead || musictype != stream_fighttheme)) {
+ (!Person::players[i]->dead || musictype != stream_fighttheme)) {
Person::players[k]->animTarget = dropkickanim;
terrain.deleteDeadDecals();
for (unsigned int l = 0; l < Object::objects.size(); l++) {
}
}
if (Animation::animations[Person::players[k]->animTarget].attack == normalattack &&
- Person::players[k]->victim == Person::players[i] &&
- (!Person::players[i]->skeleton.free ||
- Person::players[k]->animTarget == killanim ||
- Person::players[k]->animTarget == crouchstabanim ||
- Person::players[k]->animTarget == swordgroundstabanim ||
- Person::players[k]->animTarget == staffgroundsmashanim ||
- Person::players[k]->animTarget == dropkickanim)) {
+ Person::players[k]->victim == Person::players[i] &&
+ (!Person::players[i]->skeleton.free ||
+ Person::players[k]->animTarget == killanim ||
+ Person::players[k]->animTarget == crouchstabanim ||
+ Person::players[k]->animTarget == swordgroundstabanim ||
+ Person::players[k]->animTarget == staffgroundsmashanim ||
+ Person::players[k]->animTarget == dropkickanim)) {
oldattackkey = 1;
Person::players[k]->frameTarget = 0;
Person::players[k]->target = 0;
XYZ targetpoint = Person::players[i]->coords;
if (Person::players[k]->animTarget == crouchstabanim ||
- Person::players[k]->animTarget == swordgroundstabanim ||
- Person::players[k]->animTarget == staffgroundsmashanim) {
+ Person::players[k]->animTarget == swordgroundstabanim ||
+ Person::players[k]->animTarget == staffgroundsmashanim) {
targetpoint += (Person::players[i]->jointPos(abdomen) +
- Person::players[i]->jointPos(neck)) / 2 *
+ Person::players[i]->jointPos(neck)) /
+ 2 *
Person::players[i]->scale;
}
Person::players[k]->targetyaw = roughDirectionTo(Person::players[k]->coords, targetpoint);
if (!Person::players[i]->skeleton.free) {
if (Person::players[k]->hasvictim) {
if (distsq(&Person::players[k]->coords, &Person::players[i]->coords) <
- distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords))
+ distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords))
Person::players[k]->victim = Person::players[i];
} else {
Person::players[k]->victim = Person::players[i];
if (Person::players[k]->aitype == playercontrolled)
//rabbit kick
if (Person::players[k]->attackkeydown &&
- Person::players[k]->isRun() &&
- Person::players[k]->wasRun() &&
- ((Person::players[k]->hasvictim &&
- distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords) < 12 * sq(Person::players[k]->scale * 5) &&
- distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords) > 7 * sq(Person::players[k]->scale * 5) &&
- !Person::players[k]->victim->skeleton.free &&
- Person::players[k]->victim->animTarget != getupfrombackanim &&
- Person::players[k]->victim->animTarget != getupfromfrontanim &&
- Animation::animations[Person::players[k]->victim->animTarget].height != lowheight &&
- Person::players[k]->aitype != playercontrolled && //wat???
- normaldotproduct(Person::players[k]->facing, Person::players[k]->victim->coords - Person::players[k]->coords) > 0 &&
- Person::players[k]->rabbitkickenabled) ||
- Person::players[k]->jumpkeydown)) {
+ Person::players[k]->isRun() &&
+ Person::players[k]->wasRun() &&
+ ((Person::players[k]->hasvictim &&
+ distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords) < 12 * sq(Person::players[k]->scale * 5) &&
+ distsq(&Person::players[k]->coords, &Person::players[k]->victim->coords) > 7 * sq(Person::players[k]->scale * 5) &&
+ !Person::players[k]->victim->skeleton.free &&
+ Person::players[k]->victim->animTarget != getupfrombackanim &&
+ Person::players[k]->victim->animTarget != getupfromfrontanim &&
+ Animation::animations[Person::players[k]->victim->animTarget].height != lowheight &&
+ Person::players[k]->aitype != playercontrolled && //wat???
+ normaldotproduct(Person::players[k]->facing, Person::players[k]->victim->coords - Person::players[k]->coords) > 0 &&
+ Person::players[k]->rabbitkickenabled) ||
+ Person::players[k]->jumpkeydown)) {
oldattackkey = 1;
Person::players[k]->setTargetAnimation(rabbitkickanim);
}
if (Animation::animations[Person::players[k]->animTarget].attack && k == 0) {
numattacks++;
switch (attackweapon) {
- case 0:
- numunarmedattack++;
- break;
- case knife:
- numknifeattack++;
- break;
- case sword:
- numswordattack++;
- break;
- case staff:
- numstaffattack++;
- break;
+ case 0:
+ numunarmedattack++;
+ break;
+ case knife:
+ numknifeattack++;
+ break;
+ case sword:
+ numswordattack++;
+ break;
+ case staff:
+ numstaffattack++;
+ break;
}
}
}
for (unsigned i = k + 1; i < Person::players.size(); i++) {
//neither player is part of a reversal
if ((Animation::animations[Person::players[i]->animTarget].attack != reversed &&
- Animation::animations[Person::players[i]->animTarget].attack != reversal &&
- Animation::animations[Person::players[k]->animTarget].attack != reversed &&
- Animation::animations[Person::players[k]->animTarget].attack != reversal) || (i != 0 && k != 0))
+ Animation::animations[Person::players[i]->animTarget].attack != reversal &&
+ Animation::animations[Person::players[k]->animTarget].attack != reversed &&
+ Animation::animations[Person::players[k]->animTarget].attack != reversal) ||
+ (i != 0 && k != 0))
if ((Animation::animations[Person::players[i]->animCurrent].attack != reversed &&
- Animation::animations[Person::players[i]->animCurrent].attack != reversal &&
- Animation::animations[Person::players[k]->animCurrent].attack != reversed &&
- Animation::animations[Person::players[k]->animCurrent].attack != reversal) || (i != 0 && k != 0))
+ Animation::animations[Person::players[i]->animCurrent].attack != reversal &&
+ Animation::animations[Person::players[k]->animCurrent].attack != reversed &&
+ Animation::animations[Person::players[k]->animCurrent].attack != reversal) ||
+ (i != 0 && k != 0))
//neither is sleeping
if (Person::players[i]->howactive <= typesleeping && Person::players[k]->howactive <= typesleeping)
if (Person::players[i]->howactive != typesittingwall && Person::players[k]->howactive != typesittingwall)
//in same patch, neither is climbing
if (Person::players[i]->whichpatchx == Person::players[k]->whichpatchx &&
- Person::players[i]->whichpatchz == Person::players[k]->whichpatchz &&
- Person::players[k]->skeleton.oldfree == Person::players[k]->skeleton.free &&
- Person::players[i]->skeleton.oldfree == Person::players[i]->skeleton.free &&
- Person::players[i]->animTarget != climbanim &&
- Person::players[i]->animTarget != hanganim &&
- Person::players[k]->animTarget != climbanim &&
- Person::players[k]->animTarget != hanganim)
+ Person::players[i]->whichpatchz == Person::players[k]->whichpatchz &&
+ Person::players[k]->skeleton.oldfree == Person::players[k]->skeleton.free &&
+ Person::players[i]->skeleton.oldfree == Person::players[i]->skeleton.free &&
+ Person::players[i]->animTarget != climbanim &&
+ Person::players[i]->animTarget != hanganim &&
+ Person::players[k]->animTarget != climbanim &&
+ Person::players[k]->animTarget != hanganim)
//players are close (bounding box test)
if (Person::players[i]->coords.y > Person::players[k]->coords.y - 3)
if (Person::players[i]->coords.y < Person::players[k]->coords.y + 3)
if (Person::players[i]->coords.z > Person::players[k]->coords.z - 3)
if (Person::players[i]->coords.z < Person::players[k]->coords.z + 3) {
//spread fire from player to player
- if (distsq(&Person::players[i]->coords, &Person::players[k]->coords)
- < 3 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5)) {
+ if (distsq(&Person::players[i]->coords, &Person::players[k]->coords) < 3 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5)) {
if (Person::players[i]->onfire || Person::players[k]->onfire) {
if (!Person::players[i]->onfire)
Person::players[i]->CatchFire();
if (Person::players[0]->animTarget == rabbitkickanim && (k == 0 || i == 0) && !Person::players[0]->victim->skeleton.free)
collisionradius = 3;
if ((!Person::players[i]->skeleton.oldfree || !Person::players[k]->skeleton.oldfree) &&
- (distsq(&tempcoords1, &tempcoords2) < collisionradius ||
- distsq(&Person::players[i]->coords, &Person::players[k]->coords) < collisionradius)) {
+ (distsq(&tempcoords1, &tempcoords2) < collisionradius ||
+ distsq(&Person::players[i]->coords, &Person::players[k]->coords) < collisionradius)) {
//jump down on a dead body
if (k == 0 || i == 0) {
int l = i ? i : k;
if (Person::players[0]->animTarget == jumpdownanim &&
- !Person::players[0]->skeleton.oldfree &&
- !Person::players[0]->skeleton.free &&
- Person::players[l]->skeleton.oldfree &&
- Person::players[l]->skeleton.free &&
- Person::players[l]->dead &&
- Person::players[0]->lastcollide <= 0 &&
- fabs(Person::players[l]->coords.y - Person::players[0]->coords.y) < .2 &&
- distsq(&Person::players[0]->coords, &Person::players[l]->coords) < .7 * sq((Person::players[l]->scale + Person::players[0]->scale) * 2.5)) {
+ !Person::players[0]->skeleton.oldfree &&
+ !Person::players[0]->skeleton.free &&
+ Person::players[l]->skeleton.oldfree &&
+ Person::players[l]->skeleton.free &&
+ Person::players[l]->dead &&
+ Person::players[0]->lastcollide <= 0 &&
+ fabs(Person::players[l]->coords.y - Person::players[0]->coords.y) < .2 &&
+ distsq(&Person::players[0]->coords, &Person::players[l]->coords) < .7 * sq((Person::players[l]->scale + Person::players[0]->scale) * 2.5)) {
Person::players[0]->coords.y = Person::players[l]->coords.y;
Person::players[l]->velocity = Person::players[0]->velocity;
Person::players[l]->skeleton.free = 0;
}
}
- if ( (Person::players[i]->skeleton.oldfree == 1 && findLengthfast(&Person::players[i]->velocity) > 1) ||
- (Person::players[k]->skeleton.oldfree == 1 && findLengthfast(&Person::players[k]->velocity) > 1) ||
- (Person::players[i]->skeleton.oldfree == 0 && Person::players[k]->skeleton.oldfree == 0)) {
+ if ((Person::players[i]->skeleton.oldfree == 1 && findLengthfast(&Person::players[i]->velocity) > 1) ||
+ (Person::players[k]->skeleton.oldfree == 1 && findLengthfast(&Person::players[k]->velocity) > 1) ||
+ (Person::players[i]->skeleton.oldfree == 0 && Person::players[k]->skeleton.oldfree == 0)) {
rotatetarget = Person::players[k]->velocity - Person::players[i]->velocity;
if ((Person::players[i]->animTarget != getupfrombackanim && Person::players[i]->animTarget != getupfromfrontanim ||
- Person::players[i]->skeleton.free) &&
- (Person::players[k]->animTarget != getupfrombackanim && Person::players[k]->animTarget != getupfromfrontanim ||
- Person::players[k]->skeleton.free))
+ Person::players[i]->skeleton.free) &&
+ (Person::players[k]->animTarget != getupfrombackanim && Person::players[k]->animTarget != getupfromfrontanim ||
+ Person::players[k]->skeleton.free))
if ((((k != 0 && findLengthfast(&rotatetarget) > 150 ||
- k == 0 && findLengthfast(&rotatetarget) > 50 && Person::players[0]->rabbitkickragdoll) &&
- normaldotproduct(rotatetarget, Person::players[k]->coords - Person::players[i]->coords) > 0) &&
- (k == 0 ||
- k != 0 && Person::players[i]->skeleton.oldfree == 1 && Animation::animations[Person::players[k]->animCurrent].attack == neutral ||
- /*i!=0&&*/Person::players[k]->skeleton.oldfree == 1 && Animation::animations[Person::players[i]->animCurrent].attack == neutral)) ||
- (Person::players[i]->animTarget == jumpupanim || Person::players[i]->animTarget == jumpdownanim || Person::players[i]->isFlip()) &&
+ k == 0 && findLengthfast(&rotatetarget) > 50 && Person::players[0]->rabbitkickragdoll) &&
+ normaldotproduct(rotatetarget, Person::players[k]->coords - Person::players[i]->coords) > 0) &&
+ (k == 0 ||
+ k != 0 && Person::players[i]->skeleton.oldfree == 1 && Animation::animations[Person::players[k]->animCurrent].attack == neutral ||
+ /*i!=0&&*/ Person::players[k]->skeleton.oldfree == 1 && Animation::animations[Person::players[i]->animCurrent].attack == neutral)) ||
+ (Person::players[i]->animTarget == jumpupanim || Person::players[i]->animTarget == jumpdownanim || Person::players[i]->isFlip()) &&
(Person::players[k]->animTarget == jumpupanim || Person::players[k]->animTarget == jumpdownanim || Person::players[k]->isFlip()) &&
k == 0 && !Person::players[i]->skeleton.oldfree && !Person::players[k]->skeleton.oldfree) {
//If hit by body
- if ( (i != 0 || Person::players[i]->skeleton.free) &&
- (k != 0 || Person::players[k]->skeleton.free) ||
- (Animation::animations[Person::players[i]->animTarget].height == highheight &&
- Animation::animations[Person::players[k]->animTarget].height == highheight)) {
+ if ((i != 0 || Person::players[i]->skeleton.free) &&
+ (k != 0 || Person::players[k]->skeleton.free) ||
+ (Animation::animations[Person::players[i]->animTarget].height == highheight &&
+ Animation::animations[Person::players[k]->animTarget].height == highheight)) {
if (!Tutorial::active) {
emit_sound_at(heavyimpactsound, Person::players[i]->coords);
}
for (unsigned j = 0; j < Person::players[k]->skeleton.joints.size(); j++) {
Person::players[k]->skeleton.joints[j].velocity = Person::players[k]->skeleton.joints[j].velocity / 5 + Person::players[i]->velocity;
}
-
}
}
- if ( (Animation::animations[Person::players[i]->animTarget].attack == neutral ||
- Animation::animations[Person::players[i]->animTarget].attack == normalattack) &&
- (Animation::animations[Person::players[k]->animTarget].attack == neutral ||
- Animation::animations[Person::players[k]->animTarget].attack == normalattack)) {
+ if ((Animation::animations[Person::players[i]->animTarget].attack == neutral ||
+ Animation::animations[Person::players[i]->animTarget].attack == normalattack) &&
+ (Animation::animations[Person::players[k]->animTarget].attack == neutral ||
+ Animation::animations[Person::players[k]->animTarget].attack == normalattack)) {
//If bumped
if (Person::players[i]->skeleton.oldfree == 0 && Person::players[k]->skeleton.oldfree == 0) {
if (distsq(&Person::players[k]->coords, &Person::players[i]->coords) < .5 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5)) {
rotatetarget = Person::players[k]->coords - Person::players[i]->coords;
Normalise(&rotatetarget);
Person::players[k]->coords = (Person::players[k]->coords + Person::players[i]->coords) / 2;
- Person::players[i]->coords = Person::players[k]->coords - rotatetarget * fast_sqrt(.6) / 2
- * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5);
+ Person::players[i]->coords = Person::players[k]->coords - rotatetarget * fast_sqrt(.6) / 2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5);
Person::players[k]->coords += rotatetarget * fast_sqrt(.6) / 2 * sq((Person::players[i]->scale + Person::players[k]->scale) * 2.5);
if (Person::players[k]->howactive == typeactive || hostile)
if (Person::players[k]->isIdle()) {
//jump down on player
if (hostile) {
if (k == 0 && i != 0 && Person::players[k]->animTarget == jumpdownanim &&
- !Person::players[i]->isCrouch() &&
- Person::players[i]->animTarget != rollanim &&
- !Person::players[k]->skeleton.oldfree && !
- Person::players[k]->skeleton.free &&
- Person::players[k]->lastcollide <= 0 &&
- Person::players[k]->velocity.y < -10) {
+ !Person::players[i]->isCrouch() &&
+ Person::players[i]->animTarget != rollanim &&
+ !Person::players[k]->skeleton.oldfree && !Person::players[k]->skeleton.free &&
+ Person::players[k]->lastcollide <= 0 &&
+ Person::players[k]->velocity.y < -10) {
Person::players[i]->velocity = Person::players[k]->velocity;
Person::players[k]->velocity = Person::players[k]->velocity * -.5;
Person::players[k]->velocity.y = Person::players[i]->velocity.y;
award_bonus(k, AboveBonus);
}
if (i == 0 && k != 0 && Person::players[i]->animTarget == jumpdownanim &&
- !Person::players[k]->isCrouch() &&
- Person::players[k]->animTarget != rollanim &&
- !Person::players[i]->skeleton.oldfree &&
- !Person::players[i]->skeleton.free &&
- Person::players[i]->lastcollide <= 0 &&
- Person::players[i]->velocity.y < -10) {
+ !Person::players[k]->isCrouch() &&
+ Person::players[k]->animTarget != rollanim &&
+ !Person::players[i]->skeleton.oldfree &&
+ !Person::players[i]->skeleton.free &&
+ Person::players[i]->lastcollide <= 0 &&
+ Person::players[i]->velocity.y < -10) {
Person::players[k]->velocity = Person::players[i]->velocity;
Person::players[i]->velocity = Person::players[i]->velocity * -.3;
Person::players[i]->velocity.y = Person::players[k]->velocity.y;
printf("Stereo separation increased to %f\n", stereoseparation);
}
-
if (Input::isKeyPressed(SDL_SCANCODE_TAB) && Tutorial::active) {
if (Tutorial::stage != 51) {
Tutorial::stagetime = Tutorial::maxtime;
}
//escape key pressed
if (Input::isKeyPressed(SDL_SCANCODE_ESCAPE) &&
- (gameon || mainmenu == 0)) {
+ (gameon || mainmenu == 0)) {
selected = -1;
if (mainmenu == 0 && !winfreeze)
mainmenu = 2; //pause
}
}
-
-
if (!freeze && !winfreeze && !(mainmenu && gameon) && (gameon || !gamestarted)) {
//dialogues
//bonuses
if (!Tutorial::active) {
if (bonustime == 0 &&
- bonus != solidhit &&
- bonus != spinecrusher &&
- bonus != tracheotomy &&
- bonus != backstab &&
- bonusvalue > 10) {
+ bonus != solidhit &&
+ bonus != spinecrusher &&
+ bonus != tracheotomy &&
+ bonus != backstab &&
+ bonusvalue > 10) {
emit_sound_np(consolesuccesssound);
}
} else if (bonustime == 0) {
}
if (bonustime == 0) {
if (bonus != solidhit &&
- bonus != twoxcombo &&
- bonus != threexcombo &&
- bonus != fourxcombo &&
- bonus != megacombo)
+ bonus != twoxcombo &&
+ bonus != threexcombo &&
+ bonus != fourxcombo &&
+ bonus != megacombo)
bonusnum[bonus]++;
else
bonusnum[bonus] += 0.15;
}
}
-
doAerialAcrobatics();
-
static XYZ oldviewer;
//control keys
if (!Person::players[0]->jumpkeydown)
Person::players[0]->jumpclimb = 0;
-
if (Dialog::inDialog()) {
cameramode = 1;
if (Dialog::directing) {
viewer.y += multiplier * 4;
if (Input::isKeyDown(crouchkey))
viewer.y -= multiplier * 4;
- if ( Input::isKeyPressed(SDL_SCANCODE_1) ||
- Input::isKeyPressed(SDL_SCANCODE_2) ||
- Input::isKeyPressed(SDL_SCANCODE_3) ||
- Input::isKeyPressed(SDL_SCANCODE_4) ||
- Input::isKeyPressed(SDL_SCANCODE_5) ||
- Input::isKeyPressed(SDL_SCANCODE_6) ||
- Input::isKeyPressed(SDL_SCANCODE_7) ||
- Input::isKeyPressed(SDL_SCANCODE_8) ||
- Input::isKeyPressed(SDL_SCANCODE_9) ||
- Input::isKeyPressed(SDL_SCANCODE_0) ||
- Input::isKeyPressed(SDL_SCANCODE_MINUS)) {
+ if (Input::isKeyPressed(SDL_SCANCODE_1) ||
+ Input::isKeyPressed(SDL_SCANCODE_2) ||
+ Input::isKeyPressed(SDL_SCANCODE_3) ||
+ Input::isKeyPressed(SDL_SCANCODE_4) ||
+ Input::isKeyPressed(SDL_SCANCODE_5) ||
+ Input::isKeyPressed(SDL_SCANCODE_6) ||
+ Input::isKeyPressed(SDL_SCANCODE_7) ||
+ Input::isKeyPressed(SDL_SCANCODE_8) ||
+ Input::isKeyPressed(SDL_SCANCODE_9) ||
+ Input::isKeyPressed(SDL_SCANCODE_0) ||
+ Input::isKeyPressed(SDL_SCANCODE_MINUS)) {
int whichend;
- if (Input::isKeyPressed(SDL_SCANCODE_1)) whichend = 1;
- if (Input::isKeyPressed(SDL_SCANCODE_2)) whichend = 2;
- if (Input::isKeyPressed(SDL_SCANCODE_3)) whichend = 3;
- if (Input::isKeyPressed(SDL_SCANCODE_4)) whichend = 4;
- if (Input::isKeyPressed(SDL_SCANCODE_5)) whichend = 5;
- if (Input::isKeyPressed(SDL_SCANCODE_6)) whichend = 6;
- if (Input::isKeyPressed(SDL_SCANCODE_7)) whichend = 7;
- if (Input::isKeyPressed(SDL_SCANCODE_8)) whichend = 8;
- if (Input::isKeyPressed(SDL_SCANCODE_9)) whichend = 9;
- if (Input::isKeyPressed(SDL_SCANCODE_0)) whichend = 0;
+ if (Input::isKeyPressed(SDL_SCANCODE_1))
+ whichend = 1;
+ if (Input::isKeyPressed(SDL_SCANCODE_2))
+ whichend = 2;
+ if (Input::isKeyPressed(SDL_SCANCODE_3))
+ whichend = 3;
+ if (Input::isKeyPressed(SDL_SCANCODE_4))
+ whichend = 4;
+ if (Input::isKeyPressed(SDL_SCANCODE_5))
+ whichend = 5;
+ if (Input::isKeyPressed(SDL_SCANCODE_6))
+ whichend = 6;
+ if (Input::isKeyPressed(SDL_SCANCODE_7))
+ whichend = 7;
+ if (Input::isKeyPressed(SDL_SCANCODE_8))
+ whichend = 8;
+ if (Input::isKeyPressed(SDL_SCANCODE_9))
+ whichend = 9;
+ if (Input::isKeyPressed(SDL_SCANCODE_0))
+ whichend = 0;
if (Input::isKeyPressed(SDL_SCANCODE_MINUS))
whichend = -1;
if (whichend != -1) {
}
}
//TODO: should these be KeyDown or KeyPressed?
- if ( Input::isKeyDown(SDL_SCANCODE_KP_1) ||
- Input::isKeyDown(SDL_SCANCODE_KP_2) ||
- Input::isKeyDown(SDL_SCANCODE_KP_3) ||
- Input::isKeyDown(SDL_SCANCODE_KP_4) ||
- Input::isKeyDown(SDL_SCANCODE_KP_5) ||
- Input::isKeyDown(SDL_SCANCODE_KP_6) ||
- Input::isKeyDown(SDL_SCANCODE_KP_7) ||
- Input::isKeyDown(SDL_SCANCODE_KP_8) ||
- Input::isKeyDown(SDL_SCANCODE_KP_9) ||
- Input::isKeyDown(SDL_SCANCODE_KP_0)) {
+ if (Input::isKeyDown(SDL_SCANCODE_KP_1) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_2) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_3) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_4) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_5) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_6) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_7) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_8) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_9) ||
+ Input::isKeyDown(SDL_SCANCODE_KP_0)) {
int whichend;
- if (Input::isKeyDown(SDL_SCANCODE_KP_1)) whichend = 1;
- if (Input::isKeyDown(SDL_SCANCODE_KP_2)) whichend = 2;
- if (Input::isKeyDown(SDL_SCANCODE_KP_3)) whichend = 3;
- if (Input::isKeyDown(SDL_SCANCODE_KP_4)) whichend = 4;
- if (Input::isKeyDown(SDL_SCANCODE_KP_5)) whichend = 5;
- if (Input::isKeyDown(SDL_SCANCODE_KP_6)) whichend = 6;
- if (Input::isKeyDown(SDL_SCANCODE_KP_7)) whichend = 7;
- if (Input::isKeyDown(SDL_SCANCODE_KP_8)) whichend = 8;
- if (Input::isKeyDown(SDL_SCANCODE_KP_9)) whichend = 9;
- if (Input::isKeyDown(SDL_SCANCODE_KP_0)) whichend = 0;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_1))
+ whichend = 1;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_2))
+ whichend = 2;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_3))
+ whichend = 3;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_4))
+ whichend = 4;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_5))
+ whichend = 5;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_6))
+ whichend = 6;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_7))
+ whichend = 7;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_8))
+ whichend = 8;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_9))
+ whichend = 9;
+ if (Input::isKeyDown(SDL_SCANCODE_KP_0))
+ whichend = 0;
Dialog::currentScene().participantfacing[whichend] = facing;
}
if (Dialog::indialogue >= int(Dialog::currentDialog().scenes.size())) {
Person::players[0]->jumptogglekeydown = 0;
}
if (Person::players[0]->jumpkeydown &&
- Person::players[0]->animTarget != jumpupanim &&
- Person::players[0]->animTarget != jumpdownanim &&
- !Person::players[0]->isFlip())
+ Person::players[0]->animTarget != jumpupanim &&
+ Person::players[0]->animTarget != jumpdownanim &&
+ !Person::players[0]->isFlip())
Person::players[0]->jumptogglekeydown = 1;
-
Dialog::dialoguetime += multiplier;
hawkyaw += multiplier * 25;
realhawkcoords = 0;
//respawn
static bool respawnkeydown;
if (!editorenabled &&
- (whichlevel != -2 &&
+ (whichlevel != -2 &&
(Input::isKeyDown(SDL_SCANCODE_Z) &&
Input::isKeyDown(SDL_SCANCODE_LGUI) &&
devtools) ||
- (Input::isKeyDown(jumpkey) &&
- !respawnkeydown &&
- !oldattackkey &&
- Person::players[0]->dead))) {
+ (Input::isKeyDown(jumpkey) &&
+ !respawnkeydown &&
+ !oldattackkey &&
+ Person::players[0]->dead))) {
targetlevel = whichlevel;
loading = 1;
leveltime = 5;
}
respawnkeydown = Input::isKeyDown(jumpkey);
-
static bool movekey;
//?
if (i == 0 && !Dialog::inDialog()) {
//TODO: refactor repetitive code
if (!Animation::animations[Person::players[0]->animTarget].attack &&
- Person::players[0]->animTarget != staggerbackhighanim &&
- Person::players[0]->animTarget != staggerbackhardanim &&
- Person::players[0]->animTarget != crouchremoveknifeanim &&
- Person::players[0]->animTarget != removeknifeanim &&
- Person::players[0]->animTarget != backhandspringanim &&
- Person::players[0]->animTarget != dodgebackanim &&
- Person::players[0]->animTarget != walljumprightkickanim &&
- Person::players[0]->animTarget != walljumpleftkickanim) {
+ Person::players[0]->animTarget != staggerbackhighanim &&
+ Person::players[0]->animTarget != staggerbackhardanim &&
+ Person::players[0]->animTarget != crouchremoveknifeanim &&
+ Person::players[0]->animTarget != removeknifeanim &&
+ Person::players[0]->animTarget != backhandspringanim &&
+ Person::players[0]->animTarget != dodgebackanim &&
+ Person::players[0]->animTarget != walljumprightkickanim &&
+ Person::players[0]->animTarget != walljumpleftkickanim) {
if (cameramode)
Person::players[0]->targetyaw = 0;
else
}
if (i != 0 && Person::players[i]->aitype == playercontrolled && !Dialog::inDialog()) {
if (!Animation::animations[Person::players[i]->animTarget].attack &&
- Person::players[i]->animTarget != staggerbackhighanim &&
- Person::players[i]->animTarget != staggerbackhardanim &&
- Person::players[i]->animTarget != crouchremoveknifeanim &&
- Person::players[i]->animTarget != removeknifeanim &&
- Person::players[i]->animTarget != backhandspringanim &&
- Person::players[i]->animTarget != dodgebackanim &&
- Person::players[i]->animTarget != walljumprightkickanim &&
- Person::players[i]->animTarget != walljumpleftkickanim) {
+ Person::players[i]->animTarget != staggerbackhighanim &&
+ Person::players[i]->animTarget != staggerbackhardanim &&
+ Person::players[i]->animTarget != crouchremoveknifeanim &&
+ Person::players[i]->animTarget != removeknifeanim &&
+ Person::players[i]->animTarget != backhandspringanim &&
+ Person::players[i]->animTarget != dodgebackanim &&
+ Person::players[i]->animTarget != walljumprightkickanim &&
+ Person::players[i]->animTarget != walljumpleftkickanim) {
Person::players[i]->targetyaw = -Person::players[i]->lookyaw + 180;
}
for (unsigned int j = 0; j < Object::objects.size(); j++)
if (Object::objects[j]->onfire)
if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) < sq(Object::objects[j]->scale) * 200)
- if ( distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
- distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
+ if (distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
+ distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
Person::players[i]->collided = 0;
Person::players[i]->avoidcollided = 1;
if (Person::players[i]->avoidsomething == 0 ||
- distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
+ distsq(&Person::players[i]->coords, &Object::objects[j]->position) <
distsq(&Person::players[i]->coords, &Person::players[i]->avoidwhere)) {
Person::players[i]->avoidwhere = Object::objects[j]->position;
Person::players[i]->avoidsomething = 1;
for (unsigned j = 0; j < Person::players.size(); j++)
if (Person::players[j]->onfire)
if (distsq(&Person::players[j]->coords, &Person::players[i]->coords) < sq(0.3) * 200)
- if ( distsq(&Person::players[i]->coords, &Person::players[j]->coords) <
- distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
+ if (distsq(&Person::players[i]->coords, &Person::players[j]->coords) <
+ distsq(&Person::players[i]->coords, &Person::players[0]->coords)) {
Person::players[i]->collided = 0;
Person::players[i]->avoidcollided = 1;
if (Person::players[i]->avoidsomething == 0 ||
- distsq(&Person::players[i]->coords, &Person::players[j]->coords) <
+ distsq(&Person::players[i]->coords, &Person::players[j]->coords) <
distsq(&Person::players[i]->coords, &Person::players[i]->avoidwhere)) {
Person::players[i]->avoidwhere = Person::players[j]->coords;
Person::players[i]->avoidsomething = 1;
Person::players[i]->surprised -= multiplier;
}
if (i != 0 && Person::players[i]->surprised <= 0 &&
- Person::players[i]->aitype == attacktypecutoff &&
- !Person::players[i]->dead &&
- !Person::players[i]->skeleton.free &&
- Animation::animations[Person::players[i]->animTarget].attack == neutral)
+ Person::players[i]->aitype == attacktypecutoff &&
+ !Person::players[i]->dead &&
+ !Person::players[i]->skeleton.free &&
+ Animation::animations[Person::players[i]->animTarget].attack == neutral)
numresponded = 1;
if (!Person::players[i]->throwkeydown)
//pick up weapon
if (Person::players[i]->throwkeydown && !Person::players[i]->throwtogglekeydown) {
if (Person::players[i]->weaponactive == -1 &&
- Person::players[i]->num_weapons < 2 &&
- (Person::players[i]->isIdle() ||
- Person::players[i]->isCrouch() ||
- Person::players[i]->animTarget == sneakanim ||
- Person::players[i]->animTarget == rollanim ||
- Person::players[i]->animTarget == backhandspringanim ||
- Person::players[i]->isFlip() ||
- Person::players[i]->aitype != playercontrolled)) {
+ Person::players[i]->num_weapons < 2 &&
+ (Person::players[i]->isIdle() ||
+ Person::players[i]->isCrouch() ||
+ Person::players[i]->animTarget == sneakanim ||
+ Person::players[i]->animTarget == rollanim ||
+ Person::players[i]->animTarget == backhandspringanim ||
+ Person::players[i]->isFlip() ||
+ Person::players[i]->aitype != playercontrolled)) {
for (unsigned j = 0; j < weapons.size(); j++) {
if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 ||
- Person::players[i]->aitype == playercontrolled) &&
- weapons[j].owner == -1 &&
- Person::players[i]->weaponactive == -1)
+ Person::players[i]->aitype == playercontrolled) &&
+ weapons[j].owner == -1 &&
+ Person::players[i]->weaponactive == -1)
if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2) {
if (distsq(&Person::players[i]->coords, &weapons[j].position) < 2) {
if (Person::players[i]->isCrouch() ||
- Person::players[i]->animTarget == sneakanim ||
- Person::players[i]->isRun() ||
- Person::players[i]->isIdle() ||
- Person::players[i]->aitype != playercontrolled) {
+ Person::players[i]->animTarget == sneakanim ||
+ Person::players[i]->isRun() ||
+ Person::players[i]->isIdle() ||
+ Person::players[i]->aitype != playercontrolled) {
Person::players[i]->throwtogglekeydown = 1;
Person::players[i]->setTargetAnimation(crouchremoveknifeanim);
Person::players[i]->targetyaw = roughDirectionTo(Person::players[i]->coords, weapons[j].position);
Person::players[i]->hasvictim = 0;
if ((weapons[j].velocity.x == 0 && weapons[j].velocity.y == 0 && weapons[j].velocity.z == 0 ||
- Person::players[i]->aitype == playercontrolled) &&
+ Person::players[i]->aitype == playercontrolled) &&
weapons[j].owner == -1 ||
- Person::players[i]->victim &&
+ Person::players[i]->victim &&
weapons[j].owner == int(Person::players[i]->victim->id))
if (distsqflat(&Person::players[i]->coords, &weapons[j].position) < 2 && Person::players[i]->weaponactive == -1)
if (distsq(&Person::players[i]->coords, &weapons[j].position) < 1 || Person::players[i]->victim) {
for (unsigned k = 0; k < weapons.size(); k++) {
if (Person::players[i]->weaponactive == -1)
if ((weapons[k].velocity.x == 0 && weapons[k].velocity.y == 0 && weapons[k].velocity.z == 0 ||
- Person::players[i]->aitype == playercontrolled) &&
+ Person::players[i]->aitype == playercontrolled) &&
weapons[k].owner == -1 ||
- Person::players[i]->victim &&
+ Person::players[i]->victim &&
weapons[k].owner == int(Person::players[i]->victim->id))
if (distsqflat(&Person::players[i]->coords, &weapons[k].position) < 3 &&
- Person::players[i]->weaponactive == -1) {
+ Person::players[i]->weaponactive == -1) {
if (weapons[k].getType() != staff)
emit_sound_at(knifedrawsound, Person::players[i]->coords, 128.);
}
}
if (Person::players[i]->isCrouch() ||
- Person::players[i]->animTarget == sneakanim ||
- Person::players[i]->isRun() ||
- Person::players[i]->isIdle() || Person::players[i]->animTarget == rollanim ||
- Person::players[i]->animTarget == backhandspringanim) {
+ Person::players[i]->animTarget == sneakanim ||
+ Person::players[i]->isRun() ||
+ Person::players[i]->isIdle() || Person::players[i]->animTarget == rollanim ||
+ Person::players[i]->animTarget == backhandspringanim) {
if (Person::players.size() > 1)
for (unsigned j = 0; j < Person::players.size(); j++) {
if (Person::players[i]->weaponactive == -1)
if (j != i)
if (Person::players[j]->num_weapons &&
- Person::players[j]->skeleton.free &&
- distsq(&Person::players[i]->coords, &Person::players[j]->coords) < 2/*&&Person::players[j]->dead*/ &&
- (((Person::players[j]->skeleton.forward.y < 0 &&
- Person::players[j]->weaponstuckwhere == 0) ||
- (Person::players[j]->skeleton.forward.y > 0 &&
- Person::players[j]->weaponstuckwhere == 1)) ||
- Person::players[j]->weaponstuck == -1 ||
- Person::players[j]->num_weapons > 1)) {
+ Person::players[j]->skeleton.free &&
+ distsq(&Person::players[i]->coords, &Person::players[j]->coords) < 2 /*&&Person::players[j]->dead*/ &&
+ (((Person::players[j]->skeleton.forward.y < 0 &&
+ Person::players[j]->weaponstuckwhere == 0) ||
+ (Person::players[j]->skeleton.forward.y > 0 &&
+ Person::players[j]->weaponstuckwhere == 1)) ||
+ Person::players[j]->weaponstuck == -1 ||
+ Person::players[j]->num_weapons > 1)) {
if (Person::players[i]->animTarget != rollanim && Person::players[i]->animTarget != backhandspringanim) {
Person::players[i]->throwtogglekeydown = 1;
Person::players[i]->victim = Person::players[j];
if (Person::players[i]->weaponactive != -1 && Person::players[i]->aitype == playercontrolled) {
if (weapons[Person::players[i]->weaponids[0]].getType() == knife) {
if (Person::players[i]->isIdle() ||
- Person::players[i]->isRun() ||
- Person::players[i]->isCrouch() ||
- Person::players[i]->animTarget == sneakanim ||
- Person::players[i]->isFlip())
+ Person::players[i]->isRun() ||
+ Person::players[i]->isCrouch() ||
+ Person::players[i]->animTarget == sneakanim ||
+ Person::players[i]->isFlip())
if (Person::players.size() > 1)
for (unsigned j = 0; j < Person::players.size(); j++) {
if (i != j)
if (!Tutorial::active || Tutorial::stage == 49)
if (hostile)
if (normaldotproduct(Person::players[i]->facing, Person::players[i]->coords - Person::players[j]->coords) < 0 &&
- distsq(&Person::players[i]->coords, &Person::players[j]->coords) < 100 &&
- distsq(&Person::players[i]->coords, &Person::players[j]->coords) > 1.5 &&
- !Person::players[j]->skeleton.free &&
- -1 == Object::checkcollide(DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0)*Person::players[j]->scale + Person::players[j]->coords, DoRotation(Person::players[i]->jointPos(head), 0, Person::players[i]->yaw, 0)*Person::players[i]->scale + Person::players[i]->coords)) {
+ distsq(&Person::players[i]->coords, &Person::players[j]->coords) < 100 &&
+ distsq(&Person::players[i]->coords, &Person::players[j]->coords) > 1.5 &&
+ !Person::players[j]->skeleton.free &&
+ -1 == Object::checkcollide(DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0) * Person::players[j]->scale + Person::players[j]->coords, DoRotation(Person::players[i]->jointPos(head), 0, Person::players[i]->yaw, 0) * Person::players[i]->scale + Person::players[i]->coords)) {
if (!Person::players[i]->isFlip()) {
Person::players[i]->throwtogglekeydown = 1;
Person::players[i]->victim = Person::players[j];
}
}
}
-
}
//draw weapon
if (i == 0 || !Person::players[0]->dead || (Person::players[i]->weaponactive != -1)) {
if (Person::players[i]->drawkeydown && !Person::players[i]->drawtogglekeydown ||
- (Person::players[i]->num_weapons == 2) &&
+ (Person::players[i]->num_weapons == 2) &&
(Person::players[i]->weaponactive == -1) &&
Person::players[i]->isIdle() ||
- Person::players[0]->dead &&
+ Person::players[0]->dead &&
(Person::players[i]->weaponactive != -1) &&
i != 0) {
bool isgood = true;
Person::players[i]->drawtogglekeydown = 1;
}
if ((Person::players[i]->isIdle() ||
- (Person::players[i]->aitype != playercontrolled &&
- Person::players[0]->weaponactive != -1 &&
- Person::players[i]->isRun())) &&
- Person::players[i]->num_weapons &&
- weapons[Person::players[i]->weaponids[0]].getType() == sword) {
+ (Person::players[i]->aitype != playercontrolled &&
+ Person::players[0]->weaponactive != -1 &&
+ Person::players[i]->isRun())) &&
+ Person::players[i]->num_weapons &&
+ weapons[Person::players[i]->weaponids[0]].getType() == sword) {
Person::players[i]->setTargetAnimation(drawleftanim);
Person::players[i]->drawtogglekeydown = 1;
}
//clean weapon
if (Person::players[i]->weaponactive != -1) {
if (Person::players[i]->isCrouch() &&
- weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].bloody &&
- bloodtoggle &&
- Person::players[i]->onterrain &&
- Person::players[i]->num_weapons &&
- Person::players[i]->attackkeydown &&
- musictype != stream_fighttheme) {
+ weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].bloody &&
+ bloodtoggle &&
+ Person::players[i]->onterrain &&
+ Person::players[i]->num_weapons &&
+ Person::players[i]->attackkeydown &&
+ musictype != stream_fighttheme) {
if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == knife)
Person::players[i]->setTargetAnimation(crouchstabanim);
if (weapons[Person::players[i]->weaponids[Person::players[i]->weaponactive]].getType() == sword)
movekey = 0;
//Do controls
if (!Animation::animations[Person::players[i]->animTarget].attack &&
- Person::players[i]->animTarget != staggerbackhighanim &&
- Person::players[i]->animTarget != staggerbackhardanim &&
- Person::players[i]->animTarget != backhandspringanim &&
- Person::players[i]->animTarget != dodgebackanim) {
+ Person::players[i]->animTarget != staggerbackhighanim &&
+ Person::players[i]->animTarget != staggerbackhardanim &&
+ Person::players[i]->animTarget != backhandspringanim &&
+ Person::players[i]->animTarget != dodgebackanim) {
if (!Person::players[i]->forwardkeydown)
Person::players[i]->forwardstogglekeydown = 0;
if (Person::players[i]->crouchkeydown) {
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != i && !Person::players[j]->skeleton.free && Person::players[j]->victim && Person::players[i]->lowreversaldelay <= 0) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 3 &&
- Person::players[j]->victim == Person::players[i] &&
- (Person::players[j]->animTarget == sweepanim ||
- Person::players[j]->animTarget == upunchanim ||
- Person::players[j]->animTarget == wolfslapanim ||
- ((Person::players[j]->animTarget == swordslashanim ||
- Person::players[j]->animTarget == knifeslashstartanim ||
- Person::players[j]->animTarget == staffhitanim ||
- Person::players[j]->animTarget == staffspinhitanim) &&
- distsq(&Person::players[j]->coords, &Person::players[i]->coords) < 2))) {
+ Person::players[j]->victim == Person::players[i] &&
+ (Person::players[j]->animTarget == sweepanim ||
+ Person::players[j]->animTarget == upunchanim ||
+ Person::players[j]->animTarget == wolfslapanim ||
+ ((Person::players[j]->animTarget == swordslashanim ||
+ Person::players[j]->animTarget == knifeslashstartanim ||
+ Person::players[j]->animTarget == staffhitanim ||
+ Person::players[j]->animTarget == staffspinhitanim) &&
+ distsq(&Person::players[j]->coords, &Person::players[i]->coords) < 2))) {
if (target >= 0)
target = -1;
else
Person::players[i]->transspeed = 10;
}
if (Person::players[i]->isRun() ||
- (Person::players[i]->isStop() &&
- (Person::players[i]->leftkeydown ||
- Person::players[i]->rightkeydown ||
- Person::players[i]->forwardkeydown ||
- Person::players[i]->backkeydown))) {
+ (Person::players[i]->isStop() &&
+ (Person::players[i]->leftkeydown ||
+ Person::players[i]->rightkeydown ||
+ Person::players[i]->forwardkeydown ||
+ Person::players[i]->backkeydown))) {
Person::players[i]->setTargetAnimation(rollanim);
Person::players[i]->transspeed = 20;
}
if (Person::players.size() > 1)
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != i &&
- !Person::players[j]->skeleton.free &&
- Person::players[j]->victim &&
- Person::players[i]->highreversaldelay <= 0) {
+ !Person::players[j]->skeleton.free &&
+ Person::players[j]->victim &&
+ Person::players[i]->highreversaldelay <= 0) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 3 &&
- Person::players[j]->victim == Person::players[i] &&
- (Person::players[j]->animTarget == spinkickanim) &&
- Person::players[i]->isCrouch()) {
+ Person::players[j]->victim == Person::players[i] &&
+ (Person::players[j]->animTarget == spinkickanim) &&
+ Person::players[i]->isCrouch()) {
if (target >= 0)
target = -1;
else
}
if (Person::players[i]->forwardkeydown) {
if (Person::players[i]->isIdle() ||
- (Person::players[i]->isStop() &&
- Person::players[i]->targetyaw == Person::players[i]->yaw) ||
- (Person::players[i]->isLanding() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown) ||
- (Person::players[i]->isLandhard() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown &&
- Person::players[i]->crouchkeydown)) {
+ (Person::players[i]->isStop() &&
+ Person::players[i]->targetyaw == Person::players[i]->yaw) ||
+ (Person::players[i]->isLanding() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown) ||
+ (Person::players[i]->isLandhard() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown &&
+ Person::players[i]->crouchkeydown)) {
if (Person::players[i]->aitype == passivetype)
Person::players[i]->setTargetAnimation(walkanim);
else
Person::players[i]->target = 0;
Person::players[i]->frameTarget = 0;
}
- if (Person::players[i]->animTarget == hanganim/*&&(!Person::players[i]->forwardstogglekeydown||Person::players[i]->aitype!=playercontrolled)*/) {
+ if (Person::players[i]->animTarget == hanganim /*&&(!Person::players[i]->forwardstogglekeydown||Person::players[i]->aitype!=playercontrolled)*/) {
Person::players[i]->setTargetAnimation(climbanim);
Person::players[i]->frameTarget = 1;
Person::players[i]->jumpclimb = 1;
}
if (Person::players[i]->rightkeydown) {
if (Person::players[i]->isIdle() ||
- (Person::players[i]->isStop() &&
- Person::players[i]->targetyaw == Person::players[i]->yaw) ||
- (Person::players[i]->isLanding() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown) ||
- (Person::players[i]->isLandhard() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown &&
- Person::players[i]->crouchkeydown)) {
+ (Person::players[i]->isStop() &&
+ Person::players[i]->targetyaw == Person::players[i]->yaw) ||
+ (Person::players[i]->isLanding() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown) ||
+ (Person::players[i]->isLandhard() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown &&
+ Person::players[i]->crouchkeydown)) {
Person::players[i]->setTargetAnimation(Person::players[i]->getRun());
}
if (Person::players[i]->isCrouch()) {
Person::players[i]->targetyaw -= 45;
movekey = 1;
}
- if ( Person::players[i]->leftkeydown) {
+ if (Person::players[i]->leftkeydown) {
if (Person::players[i]->isIdle() ||
- (Person::players[i]->isStop() &&
- Person::players[i]->targetyaw == Person::players[i]->yaw) ||
- (Person::players[i]->isLanding() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown) ||
- (Person::players[i]->isLandhard() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown &&
- Person::players[i]->crouchkeydown)) {
+ (Person::players[i]->isStop() &&
+ Person::players[i]->targetyaw == Person::players[i]->yaw) ||
+ (Person::players[i]->isLanding() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown) ||
+ (Person::players[i]->isLandhard() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown &&
+ Person::players[i]->crouchkeydown)) {
Person::players[i]->setTargetAnimation(Person::players[i]->getRun());
}
if (Person::players[i]->isCrouch()) {
}
if (Person::players[i]->backkeydown) {
if (Person::players[i]->isIdle() ||
- (Person::players[i]->isStop() &&
- Person::players[i]->targetyaw == Person::players[i]->yaw) ||
- (Person::players[i]->isLanding() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown) ||
- (Person::players[i]->isLandhard() &&
- Person::players[i]->frameTarget > 0 &&
- !Person::players[i]->jumpkeydown &&
- Person::players[i]->crouchkeydown)) {
+ (Person::players[i]->isStop() &&
+ Person::players[i]->targetyaw == Person::players[i]->yaw) ||
+ (Person::players[i]->isLanding() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown) ||
+ (Person::players[i]->isLandhard() &&
+ Person::players[i]->frameTarget > 0 &&
+ !Person::players[i]->jumpkeydown &&
+ Person::players[i]->crouchkeydown)) {
Person::players[i]->setTargetAnimation(Person::players[i]->getRun());
}
if (Person::players[i]->isCrouch()) {
Person::players[i]->coords.y -= 1.4;
Person::players[i]->grabdelay = 1;
}
- if ( !Person::players[i]->leftkeydown && !Person::players[i]->rightkeydown)
+ if (!Person::players[i]->leftkeydown && !Person::players[i]->rightkeydown)
Person::players[i]->targetyaw += 180;
movekey = 1;
}
if ((Person::players[i]->jumpkeydown && !Person::players[i]->jumpclimb) || Person::players[i]->jumpstart) {
if ((((Person::players[i]->isLanding() && Person::players[i]->frameTarget >= 3) ||
- Person::players[i]->isRun() ||
- Person::players[i]->animTarget == walkanim ||
- Person::players[i]->isCrouch() ||
- Person::players[i]->animTarget == sneakanim) &&
- Person::players[i]->jumppower > 1) &&
- ((Person::players[i]->animTarget != rabbitrunninganim &&
- Person::players[i]->animTarget != wolfrunninganim) || i != 0)) {
+ Person::players[i]->isRun() ||
+ Person::players[i]->animTarget == walkanim ||
+ Person::players[i]->isCrouch() ||
+ Person::players[i]->animTarget == sneakanim) &&
+ Person::players[i]->jumppower > 1) &&
+ ((Person::players[i]->animTarget != rabbitrunninganim &&
+ Person::players[i]->animTarget != wolfrunninganim) ||
+ i != 0)) {
Person::players[i]->jumpstart = 0;
Person::players[i]->setTargetAnimation(jumpupanim);
Person::players[i]->yaw = Person::players[i]->targetyaw;
for (unsigned j = 0; j < Person::players.size(); j++) {
if (j != i && !Person::players[j]->skeleton.free && Person::players[j]->victim) {
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 3 &&
- (Person::players[j]->victim == Person::players[i]) &&
- (Person::players[j]->animTarget == sweepanim)) {
+ (Person::players[j]->victim == Person::players[i]) &&
+ (Person::players[j]->animTarget == sweepanim)) {
if (target >= 0)
target = -1;
else
}
if (target >= 0)
Person::players[i]->velocity.y = 1;
- else
- if (Person::players[i]->crouchkeydown || Person::players[i]->aitype != playercontrolled) {
+ else if (Person::players[i]->crouchkeydown || Person::players[i]->aitype != playercontrolled) {
Person::players[i]->velocity.y = 7;
Person::players[i]->crouchtogglekeydown = 1;
- } else Person::players[i]->velocity.y = 5;
+ } else
+ Person::players[i]->velocity.y = 5;
if (mousejump && i == 0 && devtools) {
if (!Person::players[i]->isLanding())
Person::players[i]->tempdeltav = deltav;
}
if (Person::players[i]->animTarget == jumpupanim &&
- (((!floatjump &&
- !editorenabled) ||
- !devtools) ||
- Person::players[i]->aitype != playercontrolled)) {
+ (((!floatjump &&
+ !editorenabled) ||
+ !devtools) ||
+ Person::players[i]->aitype != playercontrolled)) {
if (Person::players[i]->jumppower > multiplier * 6) {
Person::players[i]->velocity.y += multiplier * 6;
Person::players[i]->jumppower -= multiplier * 6;
}
}
if (Person::players[i]->animTarget == walkanim &&
- (Person::players[i]->aitype == attacktypecutoff ||
- Person::players[i]->aitype == searchtype ||
- (Person::players[i]->aitype == passivetype &&
- Person::players[i]->numwaypoints <= 1)))
+ (Person::players[i]->aitype == attacktypecutoff ||
+ Person::players[i]->aitype == searchtype ||
+ (Person::players[i]->aitype == passivetype &&
+ Person::players[i]->numwaypoints <= 1)))
Person::players[i]->setTargetAnimation(Person::players[i]->getStop());
if (Person::players[i]->isRun() && (Person::players[i]->aitype == passivetype))
Person::players[i]->setTargetAnimation(Person::players[i]->getStop());
Person::players[k]->targettilt = 0;
if (Person::players[k]->animTarget != jumpupanim &&
- Person::players[k]->animTarget != backhandspringanim &&
- Person::players[k]->animTarget != jumpdownanim &&
- !Person::players[k]->isFlip()) {
+ Person::players[k]->animTarget != backhandspringanim &&
+ Person::players[k]->animTarget != jumpdownanim &&
+ !Person::players[k]->isFlip()) {
Person::players[k]->targettilt = 0;
if (Person::players[k]->jumppower < 0 && !Person::players[k]->jumpkeydown)
Person::players[k]->jumppower = 0;
Tutorial::DoStuff(multiplier);
}
-
//3d sound
static float gLoc[3];
gLoc[0] = viewer.x;
facing = DoRotation(facing, -pitch, 0, 0);
facing = DoRotation(facing, 0, 0 - yaw, 0);
-
static float ori[6];
ori[0] = -facing.x;
ori[1] = facing.y;
musictype = leveltheme;
for (unsigned i = 0; i < Person::players.size(); i++) {
if ((Person::players[i]->aitype == attacktypecutoff ||
- Person::players[i]->aitype == getweapontype ||
- Person::players[i]->aitype == gethelptype ||
- Person::players[i]->aitype == searchtype) &&
- !Person::players[i]->dead &&
- (Person::players[i]->animTarget != sneakattackedanim &&
- Person::players[i]->animTarget != knifesneakattackedanim &&
- Person::players[i]->animTarget != swordsneakattackedanim)) {
+ Person::players[i]->aitype == getweapontype ||
+ Person::players[i]->aitype == gethelptype ||
+ Person::players[i]->aitype == searchtype) &&
+ !Person::players[i]->dead &&
+ (Person::players[i]->animTarget != sneakattackedanim &&
+ Person::players[i]->animTarget != knifesneakattackedanim &&
+ Person::players[i]->animTarget != swordsneakattackedanim)) {
musictype = stream_fighttheme;
realthreat = 1;
}
if (Person::players[0]->dead)
musictype = stream_menutheme;
-
if (musictype == stream_fighttheme)
unseendelay = 1;
musictype = stream_fighttheme;
}
-
if (loading == 2) {
musictype = stream_menutheme;
musicvolume[2] = 512;
if (Hotspot::killhotspot == 2)
Hotspot::killhotspot = 0;
-
winhotspot = false;
for (unsigned i = 0; i < Hotspot::hotspots.size(); i++) {
if (Hotspot::hotspots[i].type == -1) {
}
}
-
if (alldead && !Person::players[0]->dead && maptype == mapkilleveryone) {
changedelay = 1;
targetlevel = whichlevel + 1;
targetlevel = 0;
}
-
if (Hotspot::killhotspot) {
changedelay = 1;
targetlevel = whichlevel + 1;
loading = 3;
}
if (changedelay <= -999 &&
- whichlevel != -2 &&
- !loading &&
- (Person::players[0]->dead ||
- (alldead && maptype == mapkilleveryone) ||
- (winhotspot) ||
- (Hotspot::killhotspot)))
+ whichlevel != -2 &&
+ !loading &&
+ (Person::players[0]->dead ||
+ (alldead && maptype == mapkilleveryone) ||
+ (winhotspot) ||
+ (Hotspot::killhotspot)))
loading = 1;
if ((Person::players[0]->dead ||
- (alldead && maptype == mapkilleveryone) ||
- (winhotspot) ||
- (windialogue) ||
- (Hotspot::killhotspot)) &&
- changedelay <= 0) {
+ (alldead && maptype == mapkilleveryone) ||
+ (winhotspot) ||
+ (windialogue) ||
+ (Hotspot::killhotspot)) &&
+ changedelay <= 0) {
if (whichlevel != -2 && !loading && !Person::players[0]->dead) {
winfreeze = true;
changedelay = -999;
if (loading == 3)
loading = 0;
-
}
oldmusictype = musictype;
}
}
}
-
Light light;
Terrain terrain;
-SDL_Window *sdlwindow;
+SDL_Window* sdlwindow;
int kTextureSize = 0;
int detail = 0;
float playerdist = 0;
int slomo = 0;
float slomodelay = 0;
-GLubyte bloodText[512 * 512 * 3] = {0};
-GLubyte wolfbloodText[512 * 512 * 3] = {0};
+GLubyte bloodText[512 * 512 * 3] = { 0 };
+GLubyte wolfbloodText[512 * 512 * 3] = { 0 };
int bloodtoggle = 0;
float camerashake = 0;
float woozy = 0;
bool velocityblur = false;
XYZ windvector;
int mainmenu = 0;
-int whichjointstartarray[26] = {0};
-int whichjointendarray[26] = {0};
+int whichjointstartarray[26] = { 0 };
+int whichjointendarray[26] = { 0 };
float smoketex = 0;
float hostiletime = 0;
XYZ envsound[30];
-float envsoundvol[30] = {0};
-float envsoundlife[30] = {0};
+float envsoundvol[30] = { 0 };
+float envsoundlife[30] = { 0 };
int numenvsounds;
bool devtools = false;
bool gamestarted = false;
-StereoMode stereomode = stereoNone;
+StereoMode stereomode = stereoNone;
StereoMode newstereomode = stereoNone;
float stereoseparation = 0.05;
-bool stereoreverse = false;
+bool stereoreverse = false;
#include "Environment/Terrain.hpp"
#include "Graphic/Models.hpp"
-Decal::Decal() :
- position(),
- type(shadowdecal),
- opacity(0),
- rotation(0),
- alivetime(0),
- brightness(0)
+Decal::Decal()
+ : position()
+ , type(shadowdecal)
+ , opacity(0)
+ , rotation(0)
+ , alivetime(0)
+ , brightness(0)
{
}
-Decal::Decal(XYZ _position, decal_type _type, float _opacity, float _rotation, float _brightness, int whichx, int whichy, float size, const Terrain& terrain, bool first) :
- position(_position),
- type(_type),
- opacity(_opacity),
- rotation(_rotation),
- alivetime(0),
- brightness(_brightness)
+Decal::Decal(XYZ _position, decal_type _type, float _opacity, float _rotation, float _brightness, int whichx, int whichy, float size, const Terrain& terrain, bool first)
+ : position(_position)
+ , type(_type)
+ , opacity(_opacity)
+ , rotation(_rotation)
+ , alivetime(0)
+ , brightness(_brightness)
{
float placex, placez;
placex = (float)whichx * terrain.scale + terrain.scale;
vertex[1].y = terrain.heightmap[whichx][whichy] * terrain.scale + .01;
}
-
placex = (float)whichx * terrain.scale;
placez = (float)whichy * terrain.scale + terrain.scale;
}
}
-Decal::Decal(XYZ _position, decal_type _type, float _opacity, float _rotation, float size, const Model& model, int i, int which) :
- position(_position),
- type(_type),
- opacity(_opacity),
- rotation(_rotation),
- alivetime(0),
- brightness(0)
+Decal::Decal(XYZ _position, decal_type _type, float _opacity, float _rotation, float size, const Model& model, int i, int which)
+ : position(_position)
+ , type(_type)
+ , opacity(_opacity)
+ , rotation(_rotation)
+ , alivetime(0)
+ , brightness(0)
{
float placex, placez;
if (which == 0) {
vertex[0].z = placez;
vertex[0].y = model.getTriangleVertex(i, 0).y;
-
placex = model.getTriangleVertex(i, 1).x;
placez = model.getTriangleVertex(i, 1).z;
vertex[1].z = placez;
vertex[1].y = model.getTriangleVertex(i, 1).y;
-
placex = model.getTriangleVertex(i, 2).x;
placez = model.getTriangleVertex(i, 2).z;
vertex[0].z = placez;
vertex[0].y = placex;
-
placex = model.getTriangleVertex(i, 1).y;
placez = model.getTriangleVertex(i, 1).z;
vertex[1].z = placez;
vertex[1].y = placex;
-
placex = model.getTriangleVertex(i, 2).y;
placez = model.getTriangleVertex(i, 2).z;
vertex[0].z = model.getTriangleVertex(i, 0).z;
vertex[0].y = placez;
-
placex = model.getTriangleVertex(i, 1).x;
placez = model.getTriangleVertex(i, 1).y;
vertex[1].z = model.getTriangleVertex(i, 1).z;
vertex[1].y = placez;
-
placex = model.getTriangleVertex(i, 2).x;
placez = model.getTriangleVertex(i, 2).y;
extern float texdetail;
extern bool decalstoggle;
-int Model::LineCheck(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
+int Model::LineCheck(XYZ* p1, XYZ* p2, XYZ* p, XYZ* move, float* rotate)
{
static float distance;
static float olddistance;
return firstintersecting;
}
-int Model::LineCheckPossible(XYZ *p1, XYZ *p2, XYZ *p, XYZ *move, float *rotate)
+int Model::LineCheckPossible(XYZ* p1, XYZ* p2, XYZ* p, XYZ* move, float* rotate)
{
static float distance;
static float olddistance;
return firstintersecting;
}
-int Model::LineCheckSlidePossible(XYZ *p1, XYZ *p2, XYZ *move, float *rotate)
+int Model::LineCheckSlidePossible(XYZ* p1, XYZ* p2, XYZ* move, float* rotate)
{
static float distance;
static float olddistance;
return firstintersecting;
}
-int Model::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate)
+int Model::SphereCheck(XYZ* p1, float radius, XYZ* p, XYZ* move, float* rotate)
{
static int i;
static float distance;
distance = abs((Triangles[j].facenormal.x * p1->x) + (Triangles[j].facenormal.y * p1->y) + (Triangles[j].facenormal.z * p1->z) - ((Triangles[j].facenormal.x * vertex[Triangles[j].vertex[0]].x) + (Triangles[j].facenormal.y * vertex[Triangles[j].vertex[0]].y) + (Triangles[j].facenormal.z * vertex[Triangles[j].vertex[0]].z)));
if (distance < radius) {
point = *p1 - Triangles[j].facenormal * distance;
- if (PointInTriangle( &point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+ if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
intersecting = 1;
if (!intersecting)
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
return firstintersecting;
}
-int Model::SphereCheckPossible(XYZ *p1, float radius, XYZ *move, float *rotate)
+int Model::SphereCheckPossible(XYZ* p1, float radius, XYZ* move, float* rotate)
{
static float distance;
static float olddistance;
distance = abs((Triangles[j].facenormal.x * p1->x) + (Triangles[j].facenormal.y * p1->y) + (Triangles[j].facenormal.z * p1->z) - ((Triangles[j].facenormal.x * vertex[Triangles[j].vertex[0]].x) + (Triangles[j].facenormal.y * vertex[Triangles[j].vertex[0]].y) + (Triangles[j].facenormal.z * vertex[Triangles[j].vertex[0]].z)));
if (distance < radius) {
point = *p1 - Triangles[j].facenormal * distance;
- if (PointInTriangle( &point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
+ if (PointInTriangle(&point, Triangles[j].facenormal, &vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], &vertex[Triangles[j].vertex[2]]))
intersecting = 1;
if (!intersecting)
intersecting = sphere_line_intersection(&vertex[Triangles[j].vertex[0]], &vertex[Triangles[j].vertex[1]], p1, &radius);
return firstintersecting;
}
-
void Model::UpdateVertexArray()
{
if (type != normaltype && type != decalstype)
bool Model::loadnotex(const std::string& filename)
{
- FILE *tfile;
+ FILE* tfile;
long i;
short triangleNum;
type = notextype;
color = 0;
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
// read model settings
return true;
}
-
bool Model::load(const std::string& filename)
{
- FILE *tfile;
+ FILE* tfile;
long i;
short triangleNum;
type = normaltype;
color = 0;
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
// read model settings
bool Model::loaddecal(const std::string& filename)
{
- FILE *tfile;
+ FILE* tfile;
long i, j;
short triangleNum;
type = decalstype;
color = 0;
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
// read model settings
funpackf(tfile, "Bf Bf Bf", &Triangles[i].gy[0], &Triangles[i].gy[1], &Triangles[i].gy[2]);
}
-
modelTexture.xsz = 0;
fclose(tfile);
bool Model::loadraw(const std::string& filename)
{
- FILE *tfile;
+ FILE* tfile;
long i;
short triangleNum;
type = rawtype;
color = 0;
- tfile = Folders::openMandatoryFile( Folders::getResourcePath(filename), "rb" );
+ tfile = Folders::openMandatoryFile(Folders::getResourcePath(filename), "rb");
// read model settings
Triangles.resize(triangleNum);
vArray = (GLfloat*)malloc(sizeof(GLfloat) * triangleNum * 24);
-
for (i = 0; i < vertexNum; i++) {
funpackf(tfile, "Bf Bf Bf", &vertex[i].x, &vertex[i].y, &vertex[i].z);
}
funpackf(tfile, "Bf Bf Bf", &Triangles[i].gy[0], &Triangles[i].gy[1], &Triangles[i].gy[2]);
}
-
fclose(tfile);
for (i = 0; i < vertexNum; i++) {
return true;
}
-
void Model::UniformTexCoords()
{
for (unsigned int i = 0; i < Triangles.size(); i++) {
UpdateVertexArray();
}
-
void Model::FlipTexCoords()
{
for (unsigned int i = 0; i < Triangles.size(); i++) {
boundingsphereradius = fast_sqrt(boundingsphereradius);
}
-
void Model::CalculateNormals(bool facenormalise)
{
Game::LoadingScreen();
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if (color) {
- glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+ glInterleavedArrays(GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
} else {
- glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+ glInterleavedArrays(GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
}
textureptr.bind();
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if (color) {
- glInterleavedArrays( GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+ glInterleavedArrays(GL_T2F_C3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
} else {
- glInterleavedArrays( GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
+ glInterleavedArrays(GL_T2F_N3F_V3F, 8 * sizeof(GLfloat), &vArray[0]);
}
texture.bind();
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glDrawArrays(GL_TRIANGLES, 0, Triangles.size() * 3);
if ((decals[i].type == blooddecal || decals[i].type == blooddecalfast || decals[i].type == blooddecalslow)) {
glColor4f(1, 1, 1, decals[i].opacity);
if (decals[i].alivetime < 4)
- glColor4f(1, 1, 1, decals[i].opacity*decals[i].alivetime*.25);
+ glColor4f(1, 1, 1, decals[i].opacity * decals[i].alivetime * .25);
if (decals[i].alivetime > 58)
glColor4f(1, 1, 1, decals[i].opacity * (60 - decals[i].alivetime) / 2);
}
}
}
-void Model::MakeDecal(decal_type atype, XYZ *where, float *size, float *opacity, float *rotation)
+void Model::MakeDecal(decal_type atype, XYZ* where, float* size, float* opacity, float* rotation)
{
if (decalstoggle) {
if (type != decalstype)
}
Model::Model()
- : vertexNum(0),
- type(nothing),
- owner(0),
- vertex(0),
- normals(0),
- vArray(0),
- color(0),
- boundingspherecenter(),
- boundingsphereradius(0),
- flat(false)
+ : vertexNum(0)
+ , type(nothing)
+ , owner(0)
+ , vertex(0)
+ , normals(0)
+ , vArray(0)
+ , color(0)
+ , boundingspherecenter()
+ , boundingsphereradius(0)
+ , flat(false)
{
memset(&modelTexture, 0, sizeof(modelTexture));
}
for (unsigned i = 0; i < sprites.size(); i++) {
if (lasttype != sprites[i]->type) {
switch (sprites[i]->type) {
- case cloudsprite:
- cloudtexture.bind();
- if (!blend) {
- blend = 1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- break;
- case breathsprite:
- case cloudimpactsprite:
- cloudimpacttexture.bind();
- if (!blend) {
- blend = 1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- break;
- case smoketype:
- smoketexture.bind();
- if (!blend) {
- blend = 1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- break;
- case bloodsprite:
- bloodtexture.bind();
- if (!blend) {
- blend = 1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- break;
- case splintersprite :
- if (lastspecial != sprites[i]->special) {
- if (sprites[i]->special == 0)
- splintertexture.bind();
- if (sprites[i]->special == 1)
- leaftexture.bind();
- if (sprites[i]->special == 2)
- snowflaketexture.bind();
- if (sprites[i]->special == 3)
- toothtexture.bind();
+ case cloudsprite:
+ cloudtexture.bind();
if (!blend) {
blend = 1;
glAlphaFunc(GL_GREATER, 0.0001);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
- }
- break;
- case snowsprite:
- snowflaketexture.bind();
- if (!blend) {
- blend = 1;
- glAlphaFunc(GL_GREATER, 0.0001);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
- break;
- case weaponshinesprite:
- shinetexture.bind();
- if (blend) {
- blend = 0;
- glAlphaFunc(GL_GREATER, 0.001);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- }
- break;
- case flamesprite:
- case weaponflamesprite:
- flametexture.bind();
- if (blend || lasttype == bloodflamesprite) {
- blend = 0;
- glAlphaFunc(GL_GREATER, 0.3);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- }
- break;
- case bloodflamesprite:
- bloodflametexture.bind();
- if (blend) {
- blend = 0;
- glAlphaFunc(GL_GREATER, 0.3);
- glBlendFunc(GL_ONE, GL_ZERO);
- }
- break;
+ break;
+ case breathsprite:
+ case cloudimpactsprite:
+ cloudimpacttexture.bind();
+ if (!blend) {
+ blend = 1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case smoketype:
+ smoketexture.bind();
+ if (!blend) {
+ blend = 1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case bloodsprite:
+ bloodtexture.bind();
+ if (!blend) {
+ blend = 1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case splintersprite:
+ if (lastspecial != sprites[i]->special) {
+ if (sprites[i]->special == 0)
+ splintertexture.bind();
+ if (sprites[i]->special == 1)
+ leaftexture.bind();
+ if (sprites[i]->special == 2)
+ snowflaketexture.bind();
+ if (sprites[i]->special == 3)
+ toothtexture.bind();
+ if (!blend) {
+ blend = 1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ }
+ break;
+ case snowsprite:
+ snowflaketexture.bind();
+ if (!blend) {
+ blend = 1;
+ glAlphaFunc(GL_GREATER, 0.0001);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ break;
+ case weaponshinesprite:
+ shinetexture.bind();
+ if (blend) {
+ blend = 0;
+ glAlphaFunc(GL_GREATER, 0.001);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ }
+ break;
+ case flamesprite:
+ case weaponflamesprite:
+ flametexture.bind();
+ if (blend || lasttype == bloodflamesprite) {
+ blend = 0;
+ glAlphaFunc(GL_GREATER, 0.3);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ }
+ break;
+ case bloodflamesprite:
+ bloodflametexture.bind();
+ if (blend) {
+ blend = 0;
+ glAlphaFunc(GL_GREATER, 0.3);
+ glBlendFunc(GL_ONE, GL_ZERO);
+ }
+ break;
}
}
if (sprites[i]->type == snowsprite)
glColor4f(sprites[i]->color[0], sprites[i]->color[1], sprites[i]->color[2], sprites[i]->opacity * distancemult);
} else {
if (distancemult >= 1)
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity);
else
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * distancemult);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity * distancemult);
}
lasttype = sprites[i]->type;
lastspecial = sprites[i]->special;
if (sprites[i]->type == smoketype || sprites[i]->type == snowsprite || sprites[i]->type == weaponshinesprite || sprites[i]->type == breathsprite) {
if (sprites[i]->alivetime < .3) {
if (distancemult >= 1)
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * sprites[i]->alivetime / .3);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity * sprites[i]->alivetime / .3);
if (distancemult < 1)
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->opacity * distancemult * sprites[i]->alivetime / .3);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->opacity * distancemult * sprites[i]->alivetime / .3);
}
}
if (sprites[i]->type == splintersprite && sprites[i]->special > 0 && sprites[i]->special != 3) {
if (sprites[i]->alivetime < .2) {
if (distancemult >= 1)
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], sprites[i]->alivetime / .2);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], sprites[i]->alivetime / .2);
else
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], distancemult * sprites[i]->alivetime / .2);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], distancemult * sprites[i]->alivetime / .2);
} else {
if (distancemult >= 1)
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], 1);
else
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], distancemult);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], distancemult);
}
}
if (sprites[i]->type == splintersprite && (sprites[i]->special == 0 || sprites[i]->special == 3)) {
if (distancemult >= 1)
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], 1);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], 1);
else
- glColor4f(sprites[i]->color[0]*lightcolor[0], sprites[i]->color[1]*lightcolor[1], sprites[i]->color[2]*lightcolor[2], distancemult);
+ glColor4f(sprites[i]->color[0] * lightcolor[0], sprites[i]->color[1] * lightcolor[1], sprites[i]->color[2] * lightcolor[2], distancemult);
}
glBegin(GL_TRIANGLES);
glTexCoord2f(1.0f, 1.0f);
- glVertex3f( .5 * sprites[i]->size, .5 * sprites[i]->size, 0.0f);
+ glVertex3f(.5 * sprites[i]->size, .5 * sprites[i]->size, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-.5 * sprites[i]->size, .5 * sprites[i]->size, 0.0f);
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( .5 * sprites[i]->size, -.5 * sprites[i]->size, 0.0f);
+ glVertex3f(.5 * sprites[i]->size, -.5 * sprites[i]->size, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-.5 * sprites[i]->size, -.5 * sprites[i]->size, 0.0f);
glTexCoord2f(1.0f, 0.0f);
- glVertex3f( .5 * sprites[i]->size, -.5 * sprites[i]->size, 0.0f);
+ glVertex3f(.5 * sprites[i]->size, -.5 * sprites[i]->size, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-.5 * sprites[i]->size, .5 * sprites[i]->size, 0.0f);
glEnd();
sprites[i]->rotation += multiplier * 360;
sprites[i]->position.y -= multiplier;
sprites[i]->position += windvector * multiplier;
- if (sprites[i]->position.y < tempviewer.y - 6) sprites[i]->position.y += 12;
- if (sprites[i]->position.y > tempviewer.y + 6) sprites[i]->position.y -= 12;
- if (sprites[i]->position.z < tempviewer.z - 6) sprites[i]->position.z += 12;
- if (sprites[i]->position.z > tempviewer.z + 6) sprites[i]->position.z -= 12;
- if (sprites[i]->position.x < tempviewer.x - 6) sprites[i]->position.x += 12;
- if (sprites[i]->position.x > tempviewer.x + 6) sprites[i]->position.x -= 12;
+ if (sprites[i]->position.y < tempviewer.y - 6)
+ sprites[i]->position.y += 12;
+ if (sprites[i]->position.y > tempviewer.y + 6)
+ sprites[i]->position.y -= 12;
+ if (sprites[i]->position.z < tempviewer.z - 6)
+ sprites[i]->position.z += 12;
+ if (sprites[i]->position.z > tempviewer.z + 6)
+ sprites[i]->position.z -= 12;
+ if (sprites[i]->position.x < tempviewer.x - 6)
+ sprites[i]->position.x += 12;
+ if (sprites[i]->position.x > tempviewer.x + 6)
+ sprites[i]->position.x -= 12;
}
if (sprites[i]->type == bloodsprite) {
bool spritehit = 0;
GLint stencilbits = 0;
switch (mode) {
- case stereoNone:
- case stereoAnaglyph:
- return true;
- break;
- case stereoHorizontalInterlaced:
- case stereoVerticalInterlaced:
- glGetIntegerv(GL_STENCIL_BITS, &stencilbits);
- if ( stencilbits < 1 ) {
- fprintf(stderr, "Failed to get a stencil buffer, interlaced stereo not available.\n");
+ case stereoNone:
+ case stereoAnaglyph:
+ return true;
+ break;
+ case stereoHorizontalInterlaced:
+ case stereoVerticalInterlaced:
+ glGetIntegerv(GL_STENCIL_BITS, &stencilbits);
+ if (stencilbits < 1) {
+ fprintf(stderr, "Failed to get a stencil buffer, interlaced stereo not available.\n");
+ return false;
+ } else {
+ fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits);
+ }
+ return true;
+ break;
+ default:
return false;
- } else {
- fprintf(stderr, "Stencil buffer has %i bits, good.\n", stencilbits);
- }
- return true;
- break;
- default:
- return false;
}
-
}
void InitStereo(StereoMode mode)
{
switch (mode) {
- default:
- case stereoNone:
- case stereoAnaglyph:
- glDisable(GL_STENCIL_TEST);
- return;
- case stereoHorizontalInterlaced:
- case stereoVerticalInterlaced:
- fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight);
-
- // Setup stencil buffer
- glDisable( GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDisable(GL_TEXTURE_2D);
-
- glEnable( GL_STENCIL_TEST);
- glClearStencil(0);
- glClear( GL_STENCIL_BUFFER_BIT );
- glStencilFunc(GL_ALWAYS, 0x1, 0x1);
- glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
-
- // Setup viewport
- glViewport(0, 0, kContextWidth, kContextHeight);
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
- glOrtho((GLdouble)0, (GLdouble)kContextWidth, (GLdouble)kContextHeight, 0, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
- glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
- glDisable(GL_LINE_SMOOTH);
-
- // Add 0.5 to the coordinates, because OpenGL considers a pixel should be
- // turned on when a line passes through the center of it.
- if ( mode == stereoHorizontalInterlaced ) {
- for (int y = 0; y < kContextHeight; y += 2) {
- glBegin(GL_LINES);
- glVertex3f(0.5, y + 0.5, 0);
- glVertex3f(kContextWidth + 0.5, y + 0.5, 0);
- glEnd();
+ default:
+ case stereoNone:
+ case stereoAnaglyph:
+ glDisable(GL_STENCIL_TEST);
+ return;
+ case stereoHorizontalInterlaced:
+ case stereoVerticalInterlaced:
+ fprintf(stderr, "Screen width is %i, height is %i\n", kContextWidth, kContextHeight);
+
+ // Setup stencil buffer
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_TEXTURE_2D);
+
+ glEnable(GL_STENCIL_TEST);
+ glClearStencil(0);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glStencilFunc(GL_ALWAYS, 0x1, 0x1);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+
+ // Setup viewport
+ glViewport(0, 0, kContextWidth, kContextHeight);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glOrtho((GLdouble)0, (GLdouble)kContextWidth, (GLdouble)kContextHeight, 0, -1, 1);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ glDisable(GL_LINE_SMOOTH);
+
+ // Add 0.5 to the coordinates, because OpenGL considers a pixel should be
+ // turned on when a line passes through the center of it.
+ if (mode == stereoHorizontalInterlaced) {
+ for (int y = 0; y < kContextHeight; y += 2) {
+ glBegin(GL_LINES);
+ glVertex3f(0.5, y + 0.5, 0);
+ glVertex3f(kContextWidth + 0.5, y + 0.5, 0);
+ glEnd();
+ }
+ } else {
+ for (int x = 0; x < kContextWidth; x += 2) {
+ glBegin(GL_LINES);
+ glVertex3f(x + 0.5, 0.5, 0);
+ glVertex3f(x + 0.5, kContextHeight + 0.5, 0);
+ glEnd();
+ }
}
- } else {
- for (int x = 0; x < kContextWidth; x += 2) {
- glBegin(GL_LINES);
- glVertex3f(x + 0.5, 0.5, 0);
- glVertex3f(x + 0.5, kContextHeight + 0.5, 0);
- glEnd();
- }
- }
- glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
- glPopMatrix();
- glMatrixMode(GL_PROJECTION);
- glPopMatrix();
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
- glStencilFunc(GL_NOTEQUAL, 0x01, 0x01);
- glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- glEnable( GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
- glEnable(GL_LIGHTING);
- glEnable(GL_TEXTURE_2D);
+ glStencilFunc(GL_NOTEQUAL, 0x01, 0x01);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_TEXTURE_2D);
}
-
}
const std::string StereoModeName(StereoMode mode)
{
switch (mode) {
- case stereoNone:
- return "None";
- break;
- case stereoAnaglyph:
- return "Anaglyph";
- break;
- case stereoHorizontalInterlaced:
- return "Horizontal interlacing";
- break;
- case stereoVerticalInterlaced:
- return "Vertical interlacing";
- break;
- case stereoHorizontalSplit:
- return "Horizontal split";
- break;
- case stereoVerticalSplit:
- return "Vertical split";
- break;
- case stereoOpenGL:
- return "OpenGL";
- break;
- default:
- return "(error)";
- break;
+ case stereoNone:
+ return "None";
+ break;
+ case stereoAnaglyph:
+ return "Anaglyph";
+ break;
+ case stereoHorizontalInterlaced:
+ return "Horizontal interlacing";
+ break;
+ case stereoVerticalInterlaced:
+ return "Vertical interlacing";
+ break;
+ case stereoHorizontalSplit:
+ return "Horizontal split";
+ break;
+ case stereoVerticalSplit:
+ return "Vertical split";
+ break;
+ case stereoOpenGL:
+ return "OpenGL";
+ break;
+ default:
+ return "(error)";
+ break;
}
}
cx = float((loop - 256) % 16) / 16.0f; // X Position Of Current Character
cy = float((loop - 256) / 16) / 16.0f; // Y Position Of Current Character
}
- glNewList(base + loop, GL_COMPILE); // Start Building A List
- glBegin(GL_QUADS); // Use A Quad For Each Character
- glTexCoord2f(cx, 1 - cy - 0.0625f + .001); // Texture Coord (Bottom Left)
- glVertex2i(0, 0); // Vertex Coord (Bottom Left)
+ glNewList(base + loop, GL_COMPILE); // Start Building A List
+ glBegin(GL_QUADS); // Use A Quad For Each Character
+ glTexCoord2f(cx, 1 - cy - 0.0625f + .001); // Texture Coord (Bottom Left)
+ glVertex2i(0, 0); // Vertex Coord (Bottom Left)
glTexCoord2f(cx + 0.0625f, 1 - cy - 0.0625f + .001); // Texture Coord (Bottom Right)
- glVertex2i(16, 0); // Vertex Coord (Bottom Right)
- glTexCoord2f(cx + 0.0625f, 1 - cy - .001); // Texture Coord (Top Right)
- glVertex2i(16, 16); // Vertex Coord (Top Right)
- glTexCoord2f(cx, 1 - cy - +.001); // Texture Coord (Top Left)
- glVertex2i(0, 16); // Vertex Coord (Top Left)
- glEnd(); // Done Building Our Quad (Character)
+ glVertex2i(16, 0); // Vertex Coord (Bottom Right)
+ glTexCoord2f(cx + 0.0625f, 1 - cy - .001); // Texture Coord (Top Right)
+ glVertex2i(16, 16); // Vertex Coord (Top Right)
+ glTexCoord2f(cx, 1 - cy - +.001); // Texture Coord (Top Left)
+ glVertex2i(0, 16); // Vertex Coord (Top Left)
+ glEnd(); // Done Building Our Quad (Character)
if (loop < 256)
glTranslated(10, 0, 0); // Move To The Right Of The Character
else
glTranslated(8, 0, 0); // Move To The Right Of The Character
- glEndList(); // Done Building The Display List
- } // Loop Until All 256 Are Built
+ glEndList(); // Done Building The Display List
+ } // Loop Until All 256 Are Built
}
void Text::_glPrint(float x, float y, const std::string& string, int set, float size, float width, float height, int start, int end, int offset) // Where The Printing Happens
if (set > 1) {
set = 1;
}
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
FontTexture.bind();
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glLoadIdentity();
glTranslated(x, y, 0);
glScalef(size, size, 1);
- glListBase(base - 32 + (128 * set) + offset); // Choose The Font Set (0 or 1)
+ glListBase(base - 32 + (128 * set) + offset); // Choose The Font Set (0 or 1)
glCallLists(end - start, GL_BYTE, &string[start]); // Write The Text To The Screen
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
void Text::glPrint(float x, float y, const std::string& string, int set, float size, float width, float height, int start, int end)
void Text::glPrintOutlined(float r, float g, float b, float a, float x, float y, const std::string& string, int set, float size, float width, float height, int start, int end)
{
glColor4f(0, 0, 0, a);
- glPrintOutline( x - 2 * size, y - 2 * size, string, set, size * 2.5 / 2, width, height, start, end);
+ glPrintOutline(x - 2 * size, y - 2 * size, string, set, size * 2.5 / 2, width, height, start, end);
glColor4f(r, g, b, a);
- glPrint( x, y, string, set, size, width, height, start, end);
+ glPrint(x, y, string, set, size, width, height, start, end);
}
Text::Text()
base = 0;
}
}
-
glBindTexture(GL_TEXTURE_2D, id);
}
-TextureRes::TextureRes(const string& _filename, bool _hasMipmap):
- id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(false),
- skinsize(0), data(NULL), datalen(0)
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap)
+ : id(0)
+ , filename(_filename)
+ , hasMipmap(_hasMipmap)
+ , isSkin(false)
+ , skinsize(0)
+ , data(NULL)
+ , datalen(0)
{
load();
}
-TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep):
- id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(true),
- skinsize(0), data(NULL), datalen(0)
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep)
+ : id(0)
+ , filename(_filename)
+ , hasMipmap(_hasMipmap)
+ , isSkin(true)
+ , skinsize(0)
+ , data(NULL)
+ , datalen(0)
{
load();
*skinsizep = skinsize;
float bonustime;
float bonusnum[100];
-const char *bonus_names[bonus_count] = {
+const char* bonus_names[bonus_count] = {
#define DECLARE_BONUS(id, name, ...) name,
#include "Bonuses.def"
#undef DECLARE_BONUS
};
-const char *award_names[award_count] = {
+const char* award_names[award_count] = {
#define DECLARE_AWARD(id, name) name,
#include "Awards.def"
#undef DECLARE_AWARD
#undef DECLARE_BONUS
};
-void
-award_bonus(int playerid, int bonusid, int alt_value)
+void award_bonus(int playerid, int bonusid, int alt_value)
{
if (playerid != 0)
return;
int numattacks;
int maxalarmed;
-int award_awards(int *awards)
+int award_awards(int* awards)
{
int numawards = 0;
if (damagetaken == 0 && Person::players[0]->bloodloss == 0) {
awards[numawards] = awardbrutal;
numawards++;
}
- if (numreversals > ((float)numattacks)*.8 && numreversals > 3) {
+ if (numreversals > ((float)numattacks) * .8 && numreversals > 3) {
awards[numawards] = awardaikido;
numawards++;
}
std::vector<std::string> ListCampaigns()
{
errno = 0;
- DIR *campaigns = opendir(Folders::getResourcePath("Campaigns").c_str());
- struct dirent *campaign = NULL;
+ DIR* campaigns = opendir(Folders::getResourcePath("Campaigns").c_str());
+ struct dirent* campaign = NULL;
if (!campaigns) {
perror(("Problem while loading campaigns from " + Folders::getResourcePath("Campaigns")).c_str());
exit(EXIT_FAILURE);
}
}
-CampaignLevel::CampaignLevel() :
- width(10),
- choosenext(1)
+CampaignLevel::CampaignLevel()
+ : width(10)
+ , choosenext(1)
{
location.x = 0;
location.y = 0;
}
-int CampaignLevel::getStartX() {
+int CampaignLevel::getStartX()
+{
return 30 + 120 + location.x * 400 / 512;
}
-int CampaignLevel::getStartY() {
+int CampaignLevel::getStartY()
+{
return 30 + 30 + (512 - location.y) * 400 / 512;
}
-int CampaignLevel::getEndX() {
+int CampaignLevel::getEndX()
+{
return getStartX() + width;
}
-int CampaignLevel::getEndY() {
+int CampaignLevel::getEndY()
+{
return getStartY() + width;
}
-XYZ CampaignLevel::getCenter() {
+XYZ CampaignLevel::getCenter()
+{
XYZ center;
center.x = getStartX() + width / 2;
center.y = getStartY() + width / 2;
return center;
}
-int CampaignLevel::getWidth() {
+int CampaignLevel::getWidth()
+{
return width;
}
-istream& CampaignLevel::operator<< (istream& is) {
+istream& CampaignLevel::operator<<(istream& is)
+{
is.ignore(256, ':');
is.ignore(256, ':');
is.ignore(256, ' ');
#include "Game.hpp"
#include "Objects/Person.hpp"
-#include "Utils/binio.h"
#include "Utils/Folders.hpp"
#include "Utils/Input.hpp"
+#include "Utils/binio.h"
extern int hostile;
}
}
-Dialog::Dialog(FILE* tfile) : gonethrough(0)
+Dialog::Dialog(FILE* tfile)
+ : gonethrough(0)
{
int numdialogscenes;
funpackf(tfile, "Bi", &numdialogscenes);
}
/* Load dialog from txt file, used by console */
-Dialog::Dialog(int type, std::string filename) : type(type)
+Dialog::Dialog(int type, std::string filename)
+ : type(type)
{
ifstream ipstream(Folders::getResourcePath(filename));
ipstream.ignore(256, ':');
ipstream.close();
}
-DialogScene::DialogScene(ifstream &ipstream)
+DialogScene::DialogScene(ifstream& ipstream)
{
ipstream.ignore(256, ':');
ipstream.ignore(256, ':');
bool special = (type > 9);
if ((!hostile || (type > 40) && (type < 50)) &&
- (playerId < Person::players.size()) &&
- (playerId > 0) &&
- ((gonethrough == 0) || !special) &&
- (special || Input::isKeyPressed(Game::attackkey))) {
+ (playerId < Person::players.size()) &&
+ (playerId > 0) &&
+ ((gonethrough == 0) || !special) &&
+ (special || Input::isKeyPressed(Game::attackkey))) {
if ((distsq(&Person::players[0]->coords, &Person::players[playerId]->coords) < 6) ||
- (Person::players[playerId]->howactive >= typedead1) ||
- (type > 40) && (type < 50)) {
+ (Person::players[playerId]->howactive >= typedead1) ||
+ (type > 40) && (type < 50)) {
whichdialogue = id;
play();
dialoguetime = 0;
int Hotspot::current = 0;
int Hotspot::killhotspot = 0;
-Hotspot::Hotspot() :
- position(),
- type(0),
- size(0)
+Hotspot::Hotspot()
+ : position()
+ , type(0)
+ , size(0)
{
}
-Hotspot::Hotspot(XYZ p, int t, float s) :
- position(p),
- type(t),
- size(s)
+Hotspot::Hotspot(XYZ p, int t, float s)
+ : position(p)
+ , type(t)
+ , size(s)
{
}
#include "MacCompatibility.hpp"
#include <cerrno>
-#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <ctime>
#ifdef WIN32
#include <windows.h>
#if PLATFORM_UNIX
#include <assert.h>
-#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <unistd.h>
typedef long long __int64;
typedef __int64 LARGE_INTEGER;
-static int QueryPerformanceFrequency(LARGE_INTEGER *liptr)
+static int QueryPerformanceFrequency(LARGE_INTEGER* liptr)
{
- assert(sizeof (__int64) == 8);
- assert(sizeof (LARGE_INTEGER) == 8);
+ assert(sizeof(__int64) == 8);
+ assert(sizeof(LARGE_INTEGER) == 8);
*liptr = 1000;
- return(1);
+ return (1);
}
-static int QueryPerformanceCounter(LARGE_INTEGER *liptr)
+static int QueryPerformanceCounter(LARGE_INTEGER* liptr)
{
struct timeval tv;
gettimeofday(&tv, NULL);
- *liptr = ( (((LARGE_INTEGER) tv.tv_sec) * 1000) +
- (((LARGE_INTEGER) tv.tv_usec) / 1000) );
- return(1);
+ *liptr = ((((LARGE_INTEGER)tv.tv_sec) * 1000) +
+ (((LARGE_INTEGER)tv.tv_usec) / 1000));
+ return (1);
}
#endif
class AppTime
{
-public:
- AppTime() {
+ public:
+ AppTime()
+ {
counterRate = 1;
baseCounter = 0;
- QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate);
- QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter);
+ QueryPerformanceFrequency((LARGE_INTEGER*)&counterRate);
+ QueryPerformanceCounter((LARGE_INTEGER*)&baseCounter);
}
__int64 counterRate; // LARGE_INTEGER type has no math functions so use int64
__int64 baseCounter;
AbsoluteTime UpTime()
{
__int64 counter;
- QueryPerformanceCounter( (LARGE_INTEGER*)&counter);
+ QueryPerformanceCounter((LARGE_INTEGER*)&counter);
counter -= g_appTime.baseCounter;
return time;
}
-
-Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b)
+Duration AbsoluteDeltaToDuration(AbsoluteTime& a, AbsoluteTime& b)
{
__int64 value = a.hi;
value <<= 32;
#include <math.h>
void FRUSTUM::
-GetFrustum()
+ GetFrustum()
{
static float projmatrix[16];
static float mvmatrix[16];
}
int FRUSTUM::
-CubeInFrustum(float x, float y, float z, float size)
+ CubeInFrustum(float x, float y, float z, float size)
{
static int c, c2;
}
int FRUSTUM::
-CubeInFrustum(float x, float y, float z, float size, float height)
+ CubeInFrustum(float x, float y, float z, float size, float height)
{
static int c, c2;
}
int FRUSTUM::
-SphereInFrustum(float x, float y, float z, float radius)
+ SphereInFrustum(float x, float y, float z, float radius)
{
- static int c2;
+ static int c2;
for (int i = 0; i < 6; i++) {
if (frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] > -1 * radius)
#include "Math/XYZ.hpp"
-bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3)
+bool PointInTriangle(XYZ* p, XYZ normal, XYZ* p1, XYZ* p2, XYZ* p3)
{
static float u0, u1, u2;
static float v0, v1, v2;
pointv[1] = p->y;
pointv[2] = p->z;
-
p1v[0] = p1->x;
p1v[1] = p1->y;
p1v[2] = p1->z;
normalv[1] = normal.y;
normalv[2] = normal.z;
-#define ABS(X) (((X)<0.f)?-(X):(X) )
-#define MAX(A, B) (((A)<(B))?(B):(A))
+#define ABS(X) (((X) < 0.f) ? -(X) : (X))
+#define MAX(A, B) (((A) < (B)) ? (B) : (A))
max = MAX(MAX(ABS(normalv[0]), ABS(normalv[1])), ABS(normalv[2]));
#undef MAX
if (max == ABS(normalv[0])) {
- i = 1; // y, z
+ i = 1; // y, z
j = 2;
}
if (max == ABS(normalv[1])) {
- i = 0; // x, z
+ i = 0; // x, z
j = 2;
}
if (max == ABS(normalv[2])) {
- i = 0; // x, y
+ i = 0; // x, y
j = 1;
}
#undef ABS
b = u0 / u2;
if (0.0f <= b && b <= 1.0f) {
a = (v0 - b * v2) / v1;
- if ((a >= 0.0f) && (( a + b ) <= 1.0f))
+ if ((a >= 0.0f) && ((a + b) <= 1.0f))
bInter = 1;
}
} else {
b = (v0 * u1 - u0 * v1) / (v2 * u1 - u2 * v1);
if (0.0f <= b && b <= 1.0f) {
a = (u0 - b * u2) / u1;
- if ((a >= 0.0f) && (( a + b ) <= 1.0f ))
+ if ((a >= 0.0f) && ((a + b) <= 1.0f))
bInter = 1;
}
}
return bInter;
}
-bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p)
+bool LineFacet(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ* p)
{
static float d;
static float denom, mu;
n.y = (pb.z - pa.z) * (pc.x - pa.x) - (pb.x - pa.x) * (pc.z - pa.z);
n.z = (pb.x - pa.x) * (pc.y - pa.y) - (pb.y - pa.y) * (pc.x - pa.x);
Normalise(&n);
- d = - n.x * pa.x - n.y * pa.y - n.z * pa.z;
+ d = -n.x * pa.x - n.y * pa.y - n.z * pa.z;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) // Line and plane don't intersect
return 0;
- mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
+ mu = -(d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
p->x = p1.x + mu * (p2.x - p1.x);
p->y = p1.y + mu * (p2.y - p1.y);
p->z = p1.z + mu * (p2.z - p1.z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) // Intersection not along line segment
return 0;
- if (!PointInTriangle( p, n, &pa, &pb, &pc)) {
+ if (!PointInTriangle(p, n, &pa, &pb, &pc)) {
return 0;
}
return 1;
}
-float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ *p)
+float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ* p)
{
static float d;
static float denom, mu;
n.y = (pb.z - pa.z) * (pc.x - pa.x) - (pb.x - pa.x) * (pc.z - pa.z);
n.z = (pb.x - pa.x) * (pc.y - pa.y) - (pb.y - pa.y) * (pc.x - pa.x);
Normalise(&n);
- d = - n.x * pa.x - n.y * pa.y - n.z * pa.z;
+ d = -n.x * pa.x - n.y * pa.y - n.z * pa.z;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) // Line and plane don't intersect
return 0;
- mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
+ mu = -(d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
p->x = p1.x + mu * (p2.x - p1.x);
p->y = p1.y + mu * (p2.y - p1.y);
p->z = p1.z + mu * (p2.z - p1.z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) // Intersection not along line segment
return 0;
- if (!PointInTriangle( p, n, &pa, &pb, &pc)) {
+ if (!PointInTriangle(p, n, &pa, &pb, &pc)) {
return 0;
}
return 1;
}
-float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ *p)
+float LineFacetd(XYZ p1, XYZ p2, XYZ pa, XYZ pb, XYZ pc, XYZ n, XYZ* p)
{
static float d;
static float denom, mu;
//Calculate the parameters for the plane
- d = - n.x * pa.x - n.y * pa.y - n.z * pa.z;
+ d = -n.x * pa.x - n.y * pa.y - n.z * pa.z;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) // Line and plane don't intersect
return 0;
- mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
+ mu = -(d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom;
p->x = p1.x + mu * (p2.x - p1.x);
p->y = p1.y + mu * (p2.y - p1.y);
p->z = p1.z + mu * (p2.z - p1.z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) // Intersection not along line segment
return 0;
- if (!PointInTriangle( p, n, &pa, &pb, &pc)) {
+ if (!PointInTriangle(p, n, &pa, &pb, &pc)) {
return 0;
}
return 1;
}
-float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *p)
+float LineFacetd(XYZ* p1, XYZ* p2, XYZ* pa, XYZ* pb, XYZ* pc, XYZ* p)
{
static float d;
static float denom, mu;
n.y = (pb->z - pa->z) * (pc->x - pa->x) - (pb->x - pa->x) * (pc->z - pa->z);
n.z = (pb->x - pa->x) * (pc->y - pa->y) - (pb->y - pa->y) * (pc->x - pa->x);
Normalise(&n);
- d = - n.x * pa->x - n.y * pa->y - n.z * pa->z;
-
+ d = -n.x * pa->x - n.y * pa->y - n.z * pa->z;
//Calculate the position on the line that intersects the plane
denom = n.x * (p2->x - p1->x) + n.y * (p2->y - p1->y) + n.z * (p2->z - p1->z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) // Line and plane don't intersect
return 0;
- mu = - (d + n.x * p1->x + n.y * p1->y + n.z * p1->z) / denom;
+ mu = -(d + n.x * p1->x + n.y * p1->y + n.z * p1->z) / denom;
p->x = p1->x + mu * (p2->x - p1->x);
p->y = p1->y + mu * (p2->y - p1->y);
p->z = p1->z + mu * (p2->z - p1->z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) // Intersection not along line segment
return 0;
- if (!PointInTriangle( p, n, pa, pb, pc)) {
+ if (!PointInTriangle(p, n, pa, pb, pc)) {
return 0;
}
return 1;
}
-float LineFacetd(XYZ *p1, XYZ *p2, XYZ *pa, XYZ *pb, XYZ *pc, XYZ *n, XYZ *p)
+float LineFacetd(XYZ* p1, XYZ* p2, XYZ* pa, XYZ* pb, XYZ* pc, XYZ* n, XYZ* p)
{
static float d;
static float denom, mu;
//Calculate the parameters for the plane
- d = - n->x * pa->x - n->y * pa->y - n->z * pa->z;
+ d = -n->x * pa->x - n->y * pa->y - n->z * pa->z;
//Calculate the position on the line that intersects the plane
denom = n->x * (p2->x - p1->x) + n->y * (p2->y - p1->y) + n->z * (p2->z - p1->z);
- if (fabs(denom) < 0.0000001) // Line and plane don't intersect
+ if (fabs(denom) < 0.0000001) // Line and plane don't intersect
return 0;
- mu = - (d + n->x * p1->x + n->y * p1->y + n->z * p1->z) / denom;
+ mu = -(d + n->x * p1->x + n->y * p1->y + n->z * p1->z) / denom;
p->x = p1->x + mu * (p2->x - p1->x);
p->y = p1->y + mu * (p2->y - p1->y);
p->z = p1->z + mu * (p2->z - p1->z);
- if (mu < 0 || mu > 1) // Intersection not along line segment
+ if (mu < 0 || mu > 1) // Intersection not along line segment
return 0;
- if (!PointInTriangle( p, *n, pa, pb, pc)) {
+ if (!PointInTriangle(p, *n, pa, pb, pc)) {
return 0;
}
return 1;
}
-
-
using namespace Game;
extern float multiplier;
-extern std::set<std::pair<int,int>> resolutions;
+extern std::set<std::pair<int, int>> resolutions;
extern int mainmenu;
extern std::vector<CampaignLevel> campaignlevels;
extern float musicvolume[4];
std::vector<MenuItem> Menu::items;
MenuItem::MenuItem(MenuItemType _type, int _id, const string& _text, Texture _texture,
- int _x, int _y, int _w, int _h, float _r, float _g, float _b,
- float _linestartsize, float _lineendsize):
- type(_type),
- id(_id),
- text(_text),
- texture(_texture),
- x(_x),
- y(_y),
- w(_w),
- h(_h),
- r(_r),
- g(_g),
- b(_b),
- effectfade(0),
- linestartsize(_linestartsize),
- lineendsize(_lineendsize)
+ int _x, int _y, int _w, int _h, float _r, float _g, float _b,
+ float _linestartsize, float _lineendsize)
+ : type(_type)
+ , id(_id)
+ , text(_text)
+ , texture(_texture)
+ , x(_x)
+ , y(_y)
+ , w(_w)
+ , h(_h)
+ , r(_r)
+ , g(_g)
+ , b(_b)
+ , effectfade(0)
+ , linestartsize(_linestartsize)
+ , lineendsize(_lineendsize)
{
if (type == MenuItem::BUTTON) {
if (w == -1) {
glEnable(GL_BLEND);
for (vector<MenuItem>::iterator it = items.begin(); it != items.end(); it++) {
switch (it->type) {
- case MenuItem::IMAGE:
- case MenuItem::IMAGEBUTTON:
- case MenuItem::MAPMARKER:
- glColor4f(it->r, it->g, it->b, 1);
- glPushMatrix();
- if (it->type == MenuItem::MAPMARKER) {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glTranslatef(2.5, -4.5, 0); //from old code
- } else {
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- }
- it->texture.bind();
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0);
- glVertex3f(it->x, it->y, 0);
- glTexCoord2f(1, 0);
- glVertex3f(it->x + it->w, it->y, 0);
- glTexCoord2f(1, 1);
- glVertex3f(it->x + it->w, it->y + it->h, 0);
- glTexCoord2f(0, 1);
- glVertex3f(it->x, it->y + it->h, 0);
- glEnd();
- if (it->type != MenuItem::IMAGE) {
- //mouseover highlight
- for (int i = 0; i < 10; i++) {
- if (1 - ((float)i) / 10 - (1 - it->effectfade) > 0) {
- glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade))*.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0);
- glVertex3f(it->x - ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
- glTexCoord2f(1, 0);
- glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
- glTexCoord2f(1, 1);
- glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
- glTexCoord2f(0, 1);
- glVertex3f(it->x - ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
- glEnd();
+ case MenuItem::IMAGE:
+ case MenuItem::IMAGEBUTTON:
+ case MenuItem::MAPMARKER:
+ glColor4f(it->r, it->g, it->b, 1);
+ glPushMatrix();
+ if (it->type == MenuItem::MAPMARKER) {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glTranslatef(2.5, -4.5, 0); //from old code
+ } else {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ }
+ it->texture.bind();
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex3f(it->x, it->y, 0);
+ glTexCoord2f(1, 0);
+ glVertex3f(it->x + it->w, it->y, 0);
+ glTexCoord2f(1, 1);
+ glVertex3f(it->x + it->w, it->y + it->h, 0);
+ glTexCoord2f(0, 1);
+ glVertex3f(it->x, it->y + it->h, 0);
+ glEnd();
+ if (it->type != MenuItem::IMAGE) {
+ //mouseover highlight
+ for (int i = 0; i < 10; i++) {
+ if (1 - ((float)i) / 10 - (1 - it->effectfade) > 0) {
+ glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade)) * .25);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0);
+ glVertex3f(it->x - ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
+ glTexCoord2f(1, 0);
+ glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y - ((float)i) * 1 / 2, 0);
+ glTexCoord2f(1, 1);
+ glVertex3f(it->x + it->w + ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
+ glTexCoord2f(0, 1);
+ glVertex3f(it->x - ((float)i) * 1 / 2, it->y + it->h + ((float)i) * 1 / 2, 0);
+ glEnd();
+ }
}
}
- }
- glPopMatrix();
- break;
- case MenuItem::LABEL:
- case MenuItem::BUTTON:
- glColor4f(it->r, it->g, it->b, 1);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- Game::text->glPrint(it->x, it->y, it->text.c_str(), 0, 1, 640, 480);
- if (it->type != MenuItem::LABEL) {
- //mouseover highlight
- glBlendFunc(GL_SRC_ALPHA, GL_ONE);
- for (int i = 0; i < 15; i++) {
- if (1 - ((float)i) / 15 - (1 - it->effectfade) > 0) {
- glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade))*.25);
- Game::text->glPrint(it->x - ((float)i), it->y, it->text.c_str(), 0, 1 + ((float)i) / 70, 640, 480);
+ glPopMatrix();
+ break;
+ case MenuItem::LABEL:
+ case MenuItem::BUTTON:
+ glColor4f(it->r, it->g, it->b, 1);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ Game::text->glPrint(it->x, it->y, it->text.c_str(), 0, 1, 640, 480);
+ if (it->type != MenuItem::LABEL) {
+ //mouseover highlight
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ for (int i = 0; i < 15; i++) {
+ if (1 - ((float)i) / 15 - (1 - it->effectfade) > 0) {
+ glColor4f(it->r, it->g, it->b, (1 - ((float)i) / 10 - (1 - it->effectfade)) * .25);
+ Game::text->glPrint(it->x - ((float)i), it->y, it->text.c_str(), 0, 1 + ((float)i) / 70, 640, 480);
+ }
}
}
- }
- break;
- case MenuItem::MAPLABEL:
- Game::text->glPrintOutlined(0.9, 0, 0, 1, it->x, it->y, it->text.c_str(), 0, 0.6, 640, 480);
- break;
- case MenuItem::MAPLINE: {
- XYZ linestart;
- linestart.x = it->x;
- linestart.y = it->y;
- linestart.z = 0;
- XYZ lineend;
- lineend.x = it->x + it->w;
- lineend.y = it->y + it->h;
- lineend.z = 0;
- XYZ offset = lineend - linestart;
- XYZ fac = offset;
- Normalise(&fac);
- offset = DoRotation(offset, 0, 0, 90);
- Normalise(&offset);
-
- linestart += fac * 4 * it->linestartsize;
- lineend -= fac * 4 * it->lineendsize;
-
- glDisable(GL_TEXTURE_2D);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(it->r, it->g, it->b, 1);
- glPushMatrix();
- glTranslatef(2, -5, 0); //from old code
- glBegin(GL_QUADS);
- glVertex3f(linestart.x - offset.x * it->linestartsize, linestart.y - offset.y * it->linestartsize, 0.0f);
- glVertex3f(linestart.x + offset.x * it->linestartsize, linestart.y + offset.y * it->linestartsize, 0.0f);
- glVertex3f(lineend.x + offset.x * it->lineendsize, lineend.y + offset.y * it->lineendsize, 0.0f);
- glVertex3f(lineend.x - offset.x * it->lineendsize, lineend.y - offset.y * it->lineendsize, 0.0f);
- glEnd();
- glPopMatrix();
- glEnable(GL_TEXTURE_2D);
- }
- break;
- default:
- case MenuItem::NONE:
- break;
+ break;
+ case MenuItem::MAPLABEL:
+ Game::text->glPrintOutlined(0.9, 0, 0, 1, it->x, it->y, it->text.c_str(), 0, 0.6, 640, 480);
+ break;
+ case MenuItem::MAPLINE: {
+ XYZ linestart;
+ linestart.x = it->x;
+ linestart.y = it->y;
+ linestart.z = 0;
+ XYZ lineend;
+ lineend.x = it->x + it->w;
+ lineend.y = it->y + it->h;
+ lineend.z = 0;
+ XYZ offset = lineend - linestart;
+ XYZ fac = offset;
+ Normalise(&fac);
+ offset = DoRotation(offset, 0, 0, 90);
+ Normalise(&offset);
+
+ linestart += fac * 4 * it->linestartsize;
+ lineend -= fac * 4 * it->lineendsize;
+
+ glDisable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(it->r, it->g, it->b, 1);
+ glPushMatrix();
+ glTranslatef(2, -5, 0); //from old code
+ glBegin(GL_QUADS);
+ glVertex3f(linestart.x - offset.x * it->linestartsize, linestart.y - offset.y * it->linestartsize, 0.0f);
+ glVertex3f(linestart.x + offset.x * it->linestartsize, linestart.y + offset.y * it->linestartsize, 0.0f);
+ glVertex3f(lineend.x + offset.x * it->lineendsize, lineend.y + offset.y * it->lineendsize, 0.0f);
+ glVertex3f(lineend.x - offset.x * it->lineendsize, lineend.y - offset.y * it->lineendsize, 0.0f);
+ glEnd();
+ glPopMatrix();
+ glEnable(GL_TEXTURE_2D);
+ } break;
+ default:
+ case MenuItem::NONE:
+ break;
}
}
}
}
setText(0, sbuf);
setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off");
- if (newdetail == 0) setText(1, "Detail: Low");
- if (newdetail == 1) setText(1, "Detail: Medium");
- if (newdetail == 2) setText(1, "Detail: High");
- if (bloodtoggle == 0) setText(2, "Blood: Off");
- if (bloodtoggle == 1) setText(2, "Blood: On, low detail");
- if (bloodtoggle == 2) setText(2, "Blood: On, high detail (slower)");
+ if (newdetail == 0)
+ setText(1, "Detail: Low");
+ if (newdetail == 1)
+ setText(1, "Detail: Medium");
+ if (newdetail == 2)
+ setText(1, "Detail: High");
+ if (bloodtoggle == 0)
+ setText(2, "Blood: Off");
+ if (bloodtoggle == 1)
+ setText(2, "Blood: On, low detail");
+ if (bloodtoggle == 2)
+ setText(2, "Blood: On, high detail (slower)");
setText(4, ismotionblur ? "Blur Effects: Enabled (less compatible)" : "Blur Effects: Disabled (more compatible)");
setText(5, decalstoggle ? "Decals: Enabled (slower)" : "Decals: Disabled");
setText(6, musictoggle ? "Music: Enabled" : "Music: Disabled");
void Menu::updateControlsMenu()
{
- setText(0, (string)"Forwards: " + (keyselect == 0 ? "_" : Input::keyToChar(forwardkey)));
- setText(1, (string)"Back: " + (keyselect == 1 ? "_" : Input::keyToChar(backkey)));
- setText(2, (string)"Left: " + (keyselect == 2 ? "_" : Input::keyToChar(leftkey)));
- setText(3, (string)"Right: " + (keyselect == 3 ? "_" : Input::keyToChar(rightkey)));
- setText(4, (string)"Crouch: " + (keyselect == 4 ? "_" : Input::keyToChar(crouchkey)));
- setText(5, (string)"Jump: " + (keyselect == 5 ? "_" : Input::keyToChar(jumpkey)));
- setText(6, (string)"Draw: " + (keyselect == 6 ? "_" : Input::keyToChar(drawkey)));
- setText(7, (string)"Throw: " + (keyselect == 7 ? "_" : Input::keyToChar(throwkey)));
- setText(8, (string)"Attack: " + (keyselect == 8 ? "_" : Input::keyToChar(attackkey)));
+ setText(0, (string) "Forwards: " + (keyselect == 0 ? "_" : Input::keyToChar(forwardkey)));
+ setText(1, (string) "Back: " + (keyselect == 1 ? "_" : Input::keyToChar(backkey)));
+ setText(2, (string) "Left: " + (keyselect == 2 ? "_" : Input::keyToChar(leftkey)));
+ setText(3, (string) "Right: " + (keyselect == 3 ? "_" : Input::keyToChar(rightkey)));
+ setText(4, (string) "Crouch: " + (keyselect == 4 ? "_" : Input::keyToChar(crouchkey)));
+ setText(5, (string) "Jump: " + (keyselect == 5 ? "_" : Input::keyToChar(jumpkey)));
+ setText(6, (string) "Draw: " + (keyselect == 6 ? "_" : Input::keyToChar(drawkey)));
+ setText(7, (string) "Throw: " + (keyselect == 7 ? "_" : Input::keyToChar(throwkey)));
+ setText(8, (string) "Attack: " + (keyselect == 8 ? "_" : Input::keyToChar(attackkey)));
if (devtools) {
- setText(9, (string)"Console: " + (keyselect == 9 ? "_" : Input::keyToChar(consolekey)));
+ setText(9, (string) "Console: " + (keyselect == 9 ? "_" : Input::keyToChar(consolekey)));
}
}
{
clearMenu();
switch (mainmenu) {
- case 1:
- case 2:
- addImage(0, Mainmenuitems[0], 150, 480 - 128, 256, 128);
- addButtonImage(1, Mainmenuitems[mainmenu == 1 ? 1 : 5], 18, 480 - 152 - 32, 128, 32);
- addButtonImage(2, Mainmenuitems[2], 18, 480 - 228 - 32, 112, 32);
- addButtonImage(3, Mainmenuitems[mainmenu == 1 ? 3 : 6], 18, 480 - 306 - 32, mainmenu == 1 ? 68 : 132, 32);
- break;
- case 3:
- addButton( 0, "", 10 + 20, 440);
- addButton(14, "", 10 + 400, 440);
- addButton( 1, "", 10 + 60, 405);
- addButton( 2, "", 10 + 70, 370);
- addButton( 4, "", 10 , 335);
- addButton( 5, "", 10 + 60, 300);
- addButton( 6, "", 10 + 70, 265);
- addButton( 9, "", 10 , 230);
- addButton(10, "", 20 , 195);
- addButton(11, "", 10 + 60, 160);
- addButton(13, "", 30 , 125);
- addButton( 7, "-Configure Controls-", 10 + 15, 90);
- addButton(12, "-Configure Stereo -", 10 + 15, 55);
- addButton(8, "Back", 10, 10);
- updateSettingsMenu();
- break;
- case 4:
- addButton(0, "", 10 , 400);
- addButton(1, "", 10 + 40, 360);
- addButton(2, "", 10 + 40, 320);
- addButton(3, "", 10 + 30, 280);
- addButton(4, "", 10 + 20, 240);
- addButton(5, "", 10 + 40, 200);
- addButton(6, "", 10 + 40, 160);
- addButton(7, "", 10 + 30, 120);
- addButton(8, "", 10 + 20, 80);
- if (devtools) {
- addButton(9, "", 10 + 10, 40);
- }
- addButton(devtools ? 10 : 9, "Back", 10, 10);
- updateControlsMenu();
- break;
- case 5: {
- LoadCampaign();
- addLabel(-1, Account::active().getName(), 5, 400);
- addButton(1, "Tutorial", 5, 300);
- addButton(2, "Challenge", 5, 240);
- addButton(3, "Delete User", 400, 10);
- addButton(4, "Main Menu", 5, 10);
- addButton(5, "Change User", 5, 180);
- addButton(6, "Campaign : " + Account::active().getCurrentCampaign(), 200, 420);
-
- //show campaign map
- //with (2,-5) offset from old code
- addImage(-1, Mainmenuitems[7], 150 + 2, 60 - 5, 400, 400);
- //show levels
- int numlevels = Account::active().getCampaignChoicesMade();
- numlevels += numlevels > 0 ? campaignlevels[numlevels - 1].nextlevel.size() : 1;
- for (int i = 0; i < numlevels; i++) {
- XYZ midpoint = campaignlevels[i].getCenter();
- float itemsize = campaignlevels[i].getWidth();
- const bool active = (i >= Account::active().getCampaignChoicesMade());
- if (!active) {
- itemsize /= 2;
+ case 1:
+ case 2:
+ addImage(0, Mainmenuitems[0], 150, 480 - 128, 256, 128);
+ addButtonImage(1, Mainmenuitems[mainmenu == 1 ? 1 : 5], 18, 480 - 152 - 32, 128, 32);
+ addButtonImage(2, Mainmenuitems[2], 18, 480 - 228 - 32, 112, 32);
+ addButtonImage(3, Mainmenuitems[mainmenu == 1 ? 3 : 6], 18, 480 - 306 - 32, mainmenu == 1 ? 68 : 132, 32);
+ break;
+ case 3:
+ addButton(0, "", 10 + 20, 440);
+ addButton(14, "", 10 + 400, 440);
+ addButton(1, "", 10 + 60, 405);
+ addButton(2, "", 10 + 70, 370);
+ addButton(4, "", 10, 335);
+ addButton(5, "", 10 + 60, 300);
+ addButton(6, "", 10 + 70, 265);
+ addButton(9, "", 10, 230);
+ addButton(10, "", 20, 195);
+ addButton(11, "", 10 + 60, 160);
+ addButton(13, "", 30, 125);
+ addButton(7, "-Configure Controls-", 10 + 15, 90);
+ addButton(12, "-Configure Stereo -", 10 + 15, 55);
+ addButton(8, "Back", 10, 10);
+ updateSettingsMenu();
+ break;
+ case 4:
+ addButton(0, "", 10, 400);
+ addButton(1, "", 10 + 40, 360);
+ addButton(2, "", 10 + 40, 320);
+ addButton(3, "", 10 + 30, 280);
+ addButton(4, "", 10 + 20, 240);
+ addButton(5, "", 10 + 40, 200);
+ addButton(6, "", 10 + 40, 160);
+ addButton(7, "", 10 + 30, 120);
+ addButton(8, "", 10 + 20, 80);
+ if (devtools) {
+ addButton(9, "", 10 + 10, 40);
}
+ addButton(devtools ? 10 : 9, "Back", 10, 10);
+ updateControlsMenu();
+ break;
+ case 5: {
+ LoadCampaign();
+ addLabel(-1, Account::active().getName(), 5, 400);
+ addButton(1, "Tutorial", 5, 300);
+ addButton(2, "Challenge", 5, 240);
+ addButton(3, "Delete User", 400, 10);
+ addButton(4, "Main Menu", 5, 10);
+ addButton(5, "Change User", 5, 180);
+ addButton(6, "Campaign : " + Account::active().getCurrentCampaign(), 200, 420);
+
+ //show campaign map
+ //with (2,-5) offset from old code
+ addImage(-1, Mainmenuitems[7], 150 + 2, 60 - 5, 400, 400);
+ //show levels
+ int numlevels = Account::active().getCampaignChoicesMade();
+ numlevels += numlevels > 0 ? campaignlevels[numlevels - 1].nextlevel.size() : 1;
+ for (int i = 0; i < numlevels; i++) {
+ XYZ midpoint = campaignlevels[i].getCenter();
+ float itemsize = campaignlevels[i].getWidth();
+ const bool active = (i >= Account::active().getCampaignChoicesMade());
+ if (!active) {
+ itemsize /= 2;
+ }
- if (i >= 1) {
- XYZ start = campaignlevels[i - 1].getCenter();
- addMapLine(start.x, start.y, midpoint.x - start.x, midpoint.y - start.y, 0.5, active ? 1 : 0.5, active ? 1 : 0.5, 0, 0);
- }
- addMapMarker(NB_CAMPAIGN_MENU_ITEM + i, Mapcircletexture,
- midpoint.x - itemsize / 2, midpoint.y - itemsize / 2, itemsize, itemsize, active ? 1 : 0.5, 0, 0);
+ if (i >= 1) {
+ XYZ start = campaignlevels[i - 1].getCenter();
+ addMapLine(start.x, start.y, midpoint.x - start.x, midpoint.y - start.y, 0.5, active ? 1 : 0.5, active ? 1 : 0.5, 0, 0);
+ }
+ addMapMarker(NB_CAMPAIGN_MENU_ITEM + i, Mapcircletexture,
+ midpoint.x - itemsize / 2, midpoint.y - itemsize / 2, itemsize, itemsize, active ? 1 : 0.5, 0, 0);
- if (active) {
- addMapLabel(-2, campaignlevels[i].description,
- campaignlevels[i].getStartX() + 10,
- campaignlevels[i].getStartY() - 4);
+ if (active) {
+ addMapLabel(-2, campaignlevels[i].description,
+ campaignlevels[i].getStartX() + 10,
+ campaignlevels[i].getStartY() - 4);
+ }
}
- }
- }
- break;
- case 6:
- addLabel(-1, "Are you sure you want to delete this user?", 10, 400);
- addButton(1, "Yes", 10, 360);
- addButton(2, "No", 10, 320);
- break;
- case 7:
- if (Account::getNbAccounts() < 8)
- addButton(0, "New User", 10, 400);
- else
- addLabel(0, "No More Users", 10, 400);
- addLabel(-2, "", 20, 400);
- addButton(Account::getNbAccounts() + 1, "Back", 10, 10);
- for (int i = 0; i < Account::getNbAccounts(); i++) {
- addButton(i + 1, Account::get(i).getName(), 10, 340 - 20 * (i + 1));
- }
- break;
- case 8:
- addButton(0, "Easier", 10, 400);
- addButton(1, "Difficult", 10, 360);
- addButton(2, "Insane", 10, 320);
- break;
- case 9:
- for (int i = 0; i < numchallengelevels; i++) {
- string name = "Level ";
- name += to_string(i + 1);
- if (name.size() < 17) {
- name.append((17 - name.size()), ' ');
+ } break;
+ case 6:
+ addLabel(-1, "Are you sure you want to delete this user?", 10, 400);
+ addButton(1, "Yes", 10, 360);
+ addButton(2, "No", 10, 320);
+ break;
+ case 7:
+ if (Account::getNbAccounts() < 8)
+ addButton(0, "New User", 10, 400);
+ else
+ addLabel(0, "No More Users", 10, 400);
+ addLabel(-2, "", 20, 400);
+ addButton(Account::getNbAccounts() + 1, "Back", 10, 10);
+ for (int i = 0; i < Account::getNbAccounts(); i++) {
+ addButton(i + 1, Account::get(i).getName(), 10, 340 - 20 * (i + 1));
}
- name += to_string(int(Account::active().getHighScore(i)));
- if (name.size() < 32) {
- name.append((32 - name.size()), ' ');
+ break;
+ case 8:
+ addButton(0, "Easier", 10, 400);
+ addButton(1, "Difficult", 10, 360);
+ addButton(2, "Insane", 10, 320);
+ break;
+ case 9:
+ for (int i = 0; i < numchallengelevels; i++) {
+ string name = "Level ";
+ name += to_string(i + 1);
+ if (name.size() < 17) {
+ name.append((17 - name.size()), ' ');
+ }
+ name += to_string(int(Account::active().getHighScore(i)));
+ if (name.size() < 32) {
+ name.append((32 - name.size()), ' ');
+ }
+ int fasttime = (int)round(Account::active().getFastTime(i));
+ name += to_string(int((fasttime - fasttime % 60) / 60));
+ name += ":";
+ if (fasttime % 60 < 10)
+ name += "0";
+ name += to_string(fasttime % 60);
+
+ addButton(i, name, 10, 400 - i * 25, i > Account::active().getProgress() ? 0.5 : 1, 0, 0);
}
- int fasttime = (int)round(Account::active().getFastTime(i));
- name += to_string(int((fasttime - fasttime % 60) / 60));
- name += ":";
- if (fasttime % 60 < 10)
- name += "0";
- name += to_string(fasttime % 60);
-
- addButton(i, name, 10, 400 - i * 25, i > Account::active().getProgress() ? 0.5 : 1, 0, 0);
- }
- addButton(-1, " High Score Best Time", 10, 440);
- addButton(numchallengelevels, "Back", 10, 10);
- break;
- case 10: {
- addLabel(0, "Congratulations!", 220, 330);
- addLabel(1, "You have avenged your family and", 140, 300);
- addLabel(2, "restored peace to the island of Lugaru.", 110, 270);
- addButton(3, "Back", 10, 10);
- addLabel(4, string("Your score: ") + to_string((int)Account::active().getCampaignScore()), 190, 200);
- addLabel(5, string("Highest score: ") + to_string((int)Account::active().getCampaignHighScore()), 190, 180);
- }
- break;
- case 18:
- addButton(0, "", 70, 400);
- addButton(1, "", 10, 360);
- addButton(2, "", 40, 320);
- addButton(3, "Back", 10, 10);
- updateStereoConfigMenu();
- break;
+ addButton(-1, " High Score Best Time", 10, 440);
+ addButton(numchallengelevels, "Back", 10, 10);
+ break;
+ case 10: {
+ addLabel(0, "Congratulations!", 220, 330);
+ addLabel(1, "You have avenged your family and", 140, 300);
+ addLabel(2, "restored peace to the island of Lugaru.", 110, 270);
+ addButton(3, "Back", 10, 10);
+ addLabel(4, string("Your score: ") + to_string((int)Account::active().getCampaignScore()), 190, 200);
+ addLabel(5, string("Highest score: ") + to_string((int)Account::active().getCampaignHighScore()), 190, 180);
+ } break;
+ case 18:
+ addButton(0, "", 70, 400);
+ addButton(1, "", 10, 360);
+ addButton(2, "", 40, 320);
+ addButton(3, "Back", 10, 10);
+ updateStereoConfigMenu();
+ break;
}
}
}
//go back
switch (mainmenu) {
- case 3:
- case 5:
- mainmenu = gameon ? 2 : 1;
- break;
- case 4:
- case 18:
- mainmenu = 3;
- break;
- case 6:
- case 7:
- case 9:
- case 10:
- mainmenu = 5;
- break;
+ case 3:
+ case 5:
+ mainmenu = gameon ? 2 : 1;
+ break;
+ case 4:
+ case 18:
+ mainmenu = 3;
+ break;
+ case 6:
+ case 7:
+ case 9:
+ case 10:
+ mainmenu = 5;
+ break;
}
}
static int oldmainmenu = mainmenu;
if (Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus
- set<pair<int,int>>::iterator newscreenresolution;
+ set<pair<int, int>>::iterator newscreenresolution;
switch (mainmenu) {
- case 1:
- case 2:
- switch (selected) {
case 1:
- if (gameon) { //resume
- mainmenu = 0;
- pause_sound(stream_menutheme);
- resume_stream(leveltheme);
- } else { //new game
- fireSound(firestartsound);
- flash();
- mainmenu = (Account::hasActive() ? 5 : 7);
- selected = -1;
+ case 2:
+ switch (selected) {
+ case 1:
+ if (gameon) { //resume
+ mainmenu = 0;
+ pause_sound(stream_menutheme);
+ resume_stream(leveltheme);
+ } else { //new game
+ fireSound(firestartsound);
+ flash();
+ mainmenu = (Account::hasActive() ? 5 : 7);
+ selected = -1;
+ }
+ break;
+ case 2: //options
+ fireSound();
+ flash();
+ mainmenu = 3;
+ if (newdetail > 2)
+ newdetail = detail;
+ if (newdetail < 0)
+ newdetail = detail;
+ if (newscreenwidth > 3000)
+ newscreenwidth = screenwidth;
+ if (newscreenwidth < 0)
+ newscreenwidth = screenwidth;
+ if (newscreenheight > 3000)
+ newscreenheight = screenheight;
+ if (newscreenheight < 0)
+ newscreenheight = screenheight;
+ break;
+ case 3:
+ fireSound();
+ flash();
+ if (gameon) { //end game
+ gameon = 0;
+ mainmenu = 1;
+ } else { //quit
+ tryquit = 1;
+ pause_sound(stream_menutheme);
+ }
+ break;
}
break;
- case 2: //options
- fireSound();
- flash();
- mainmenu = 3;
- if (newdetail > 2)
- newdetail = detail;
- if (newdetail < 0)
- newdetail = detail;
- if (newscreenwidth > 3000)
- newscreenwidth = screenwidth;
- if (newscreenwidth < 0)
- newscreenwidth = screenwidth;
- if (newscreenheight > 3000)
- newscreenheight = screenheight;
- if (newscreenheight < 0)
- newscreenheight = screenheight;
- break;
case 3:
fireSound();
- flash();
- if (gameon) { //end game
- gameon = 0;
- mainmenu = 1;
- } else { //quit
- tryquit = 1;
- pause_sound(stream_menutheme);
+ switch (selected) {
+ case 0:
+ newscreenresolution = resolutions.find(make_pair(newscreenwidth, newscreenheight));
+ /* Next one (end() + 1 is also end() so the ++ is safe even if it was not found) */
+ newscreenresolution++;
+ if (newscreenresolution == resolutions.end()) {
+ /* It was the last one (or not found), go back to the beginning */
+ newscreenresolution = resolutions.begin();
+ }
+ newscreenwidth = newscreenresolution->first;
+ newscreenheight = newscreenresolution->second;
+ break;
+ case 1:
+ newdetail++;
+ if (newdetail > 2)
+ newdetail = 0;
+ break;
+ case 2:
+ bloodtoggle++;
+ if (bloodtoggle > 2)
+ bloodtoggle = 0;
+ break;
+ case 4:
+ ismotionblur = !ismotionblur;
+ break;
+ case 5:
+ decalstoggle = !decalstoggle;
+ break;
+ case 6:
+ musictoggle = !musictoggle;
+ if (musictoggle) {
+ emit_stream_np(stream_menutheme);
+ } else {
+ pause_sound(leveltheme);
+ pause_sound(stream_fighttheme);
+ pause_sound(stream_menutheme);
+
+ for (int i = 0; i < 4; i++) {
+ oldmusicvolume[i] = 0;
+ musicvolume[i] = 0;
+ }
+ }
+ break;
+ case 7: // controls
+ flash();
+ mainmenu = 4;
+ selected = -1;
+ keyselect = -1;
+ break;
+ case 8:
+ flash();
+ SaveSettings();
+ mainmenu = gameon ? 2 : 1;
+ break;
+ case 9:
+ invertmouse = !invertmouse;
+ break;
+ case 10:
+ usermousesensitivity += .2;
+ if (usermousesensitivity > 2)
+ usermousesensitivity = .2;
+ break;
+ case 11:
+ volume += .1f;
+ if (volume > 1.0001f)
+ volume = 0;
+ OPENAL_SetSFXMasterVolume((int)(volume * 255));
+ break;
+ case 12:
+ flash();
+ newstereomode = stereomode;
+ mainmenu = 18;
+ keyselect = -1;
+ break;
+ case 13:
+ showdamagebar = !showdamagebar;
+ break;
+ case 14:
+ toggleFullscreen();
+ break;
}
- break;
- }
- break;
- case 3:
- fireSound();
- switch (selected) {
- case 0:
- newscreenresolution = resolutions.find(make_pair(newscreenwidth, newscreenheight));
- /* Next one (end() + 1 is also end() so the ++ is safe even if it was not found) */
- newscreenresolution++;
- if (newscreenresolution == resolutions.end()) {
- /* It was the last one (or not found), go back to the beginning */
- newscreenresolution = resolutions.begin();
- }
- newscreenwidth = newscreenresolution->first;
- newscreenheight = newscreenresolution->second;
- break;
- case 1:
- newdetail++;
- if (newdetail > 2)
- newdetail = 0;
- break;
- case 2:
- bloodtoggle++;
- if (bloodtoggle > 2)
- bloodtoggle = 0;
+ updateSettingsMenu();
break;
case 4:
- ismotionblur = !ismotionblur;
+ if (!waiting) {
+ fireSound();
+ if (selected < (devtools ? 10 : 9) && keyselect == -1)
+ keyselect = selected;
+ if (keyselect != -1)
+ setKeySelected();
+ if (selected == (devtools ? 10 : 9)) {
+ flash();
+ mainmenu = 3;
+ }
+ }
+ updateControlsMenu();
break;
case 5:
- decalstoggle = !decalstoggle;
+ fireSound();
+ flash();
+ if ((selected - NB_CAMPAIGN_MENU_ITEM >= Account::active().getCampaignChoicesMade())) {
+ startbonustotal = 0;
+
+ loading = 2;
+ loadtime = 0;
+ targetlevel = 7;
+ if (firstLoadDone) {
+ TickOnceAfter();
+ } else {
+ LoadStuff();
+ }
+ whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
+ actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
+ visibleloading = true;
+ stillloading = 1;
+ LoadLevel(campaignlevels[actuallevel].mapname.c_str());
+ campaign = 1;
+ mainmenu = 0;
+ gameon = 1;
+ pause_sound(stream_menutheme);
+ }
+ switch (selected) {
+ case 1:
+ startbonustotal = 0;
+
+ loading = 2;
+ loadtime = 0;
+ targetlevel = -1;
+ if (firstLoadDone) {
+ TickOnceAfter();
+ } else {
+ LoadStuff();
+ }
+ LoadLevel(-1);
+
+ mainmenu = 0;
+ gameon = 1;
+ pause_sound(stream_menutheme);
+ break;
+ case 2:
+ mainmenu = 9;
+ break;
+ case 3:
+ mainmenu = 6;
+ break;
+ case 4:
+ mainmenu = (gameon ? 2 : 1);
+ break;
+ case 5:
+ mainmenu = 7;
+ break;
+ case 6:
+ vector<string> campaigns = ListCampaigns();
+ vector<string>::iterator c;
+ if ((c = find(campaigns.begin(), campaigns.end(), Account::active().getCurrentCampaign())) == campaigns.end()) {
+ if (!campaigns.empty())
+ Account::active().setCurrentCampaign(campaigns.front());
+ } else {
+ c++;
+ if (c == campaigns.end())
+ c = campaigns.begin();
+ Account::active().setCurrentCampaign(*c);
+ }
+ Load();
+ break;
+ }
break;
case 6:
- musictoggle = !musictoggle;
- if (musictoggle) {
- emit_stream_np(stream_menutheme);
- } else {
- pause_sound(leveltheme);
- pause_sound(stream_fighttheme);
- pause_sound(stream_menutheme);
-
- for (int i = 0; i < 4; i++) {
- oldmusicvolume[i] = 0;
- musicvolume[i] = 0;
- }
+ fireSound();
+ if (selected == 1) {
+ flash();
+ Account::destroyActive();
+ mainmenu = 7;
+ } else if (selected == 2) {
+ flash();
+ mainmenu = 5;
}
break;
- case 7: // controls
- flash();
- mainmenu = 4;
- selected = -1;
- keyselect = -1;
+ case 7:
+ fireSound();
+ if (selected == 0 && Account::getNbAccounts() < 8) {
+ entername = 1;
+ } else if (selected < Account::getNbAccounts() + 1) {
+ flash();
+ mainmenu = 5;
+ Account::setActive(selected - 1);
+ } else if (selected == Account::getNbAccounts() + 1) {
+ flash();
+ if (Account::hasActive()) {
+ mainmenu = 5;
+ } else {
+ mainmenu = 1;
+ }
+ newusername.clear();
+ newuserselected = 0;
+ entername = 0;
+ }
break;
case 8:
+ fireSound();
flash();
- SaveSettings();
- mainmenu = gameon ? 2 : 1;
+ if (selected <= 2)
+ Account::active().setDifficulty(selected);
+ mainmenu = 5;
break;
case 9:
- invertmouse = !invertmouse;
- break;
- case 10:
- usermousesensitivity += .2;
- if (usermousesensitivity > 2)
- usermousesensitivity = .2;
- break;
- case 11:
- volume += .1f;
- if (volume > 1.0001f)
- volume = 0;
- OPENAL_SetSFXMasterVolume((int)(volume * 255));
- break;
- case 12:
- flash();
- newstereomode = stereomode;
- mainmenu = 18;
- keyselect = -1;
- break;
- case 13:
- showdamagebar = !showdamagebar;
- break;
- case 14:
- toggleFullscreen();
- break;
- }
- updateSettingsMenu();
- break;
- case 4:
- if (!waiting) {
- fireSound();
- if (selected < (devtools ? 10 : 9) && keyselect == -1)
- keyselect = selected;
- if (keyselect != -1)
- setKeySelected();
- if (selected == (devtools ? 10 : 9)) {
+ if (selected < numchallengelevels && selected <= Account::active().getProgress()) {
+ fireSound();
flash();
- mainmenu = 3;
- }
- }
- updateControlsMenu();
- break;
- case 5:
- fireSound();
- flash();
- if ((selected - NB_CAMPAIGN_MENU_ITEM >= Account::active().getCampaignChoicesMade())) {
- startbonustotal = 0;
-
- loading = 2;
- loadtime = 0;
- targetlevel = 7;
- if (firstLoadDone) {
- TickOnceAfter();
- } else {
- LoadStuff();
- }
- whichchoice = selected - NB_CAMPAIGN_MENU_ITEM - Account::active().getCampaignChoicesMade();
- actuallevel = (Account::active().getCampaignChoicesMade() > 0 ? campaignlevels[Account::active().getCampaignChoicesMade() - 1].nextlevel[whichchoice] : 0);
- visibleloading = true;
- stillloading = 1;
- LoadLevel(campaignlevels[actuallevel].mapname.c_str());
- campaign = 1;
- mainmenu = 0;
- gameon = 1;
- pause_sound(stream_menutheme);
- }
- switch (selected) {
- case 1:
- startbonustotal = 0;
- loading = 2;
- loadtime = 0;
- targetlevel = -1;
- if (firstLoadDone) {
- TickOnceAfter();
- } else {
- LoadStuff();
- }
- LoadLevel(-1);
+ startbonustotal = 0;
- mainmenu = 0;
- gameon = 1;
- pause_sound(stream_menutheme);
- break;
- case 2:
- mainmenu = 9;
- break;
- case 3:
- mainmenu = 6;
- break;
- case 4:
- mainmenu = (gameon ? 2 : 1);
- break;
- case 5:
- mainmenu = 7;
- break;
- case 6:
- vector<string> campaigns = ListCampaigns();
- vector<string>::iterator c;
- if ((c = find(campaigns.begin(), campaigns.end(), Account::active().getCurrentCampaign())) == campaigns.end()) {
- if (!campaigns.empty())
- Account::active().setCurrentCampaign(campaigns.front());
- } else {
- c++;
- if (c == campaigns.end())
- c = campaigns.begin();
- Account::active().setCurrentCampaign(*c);
+ loading = 2;
+ loadtime = 0;
+ targetlevel = selected;
+ if (firstLoadDone) {
+ TickOnceAfter();
+ } else {
+ LoadStuff();
+ }
+ LoadLevel(selected);
+ campaign = 0;
+
+ mainmenu = 0;
+ gameon = 1;
+ pause_sound(stream_menutheme);
}
- Load();
- break;
- }
- break;
- case 6:
- fireSound();
- if (selected == 1) {
- flash();
- Account::destroyActive();
- mainmenu = 7;
- } else if (selected == 2) {
- flash();
- mainmenu = 5;
- }
- break;
- case 7:
- fireSound();
- if (selected == 0 && Account::getNbAccounts() < 8) {
- entername = 1;
- } else if (selected < Account::getNbAccounts() + 1) {
- flash();
- mainmenu = 5;
- Account::setActive(selected - 1);
- } else if (selected == Account::getNbAccounts() + 1) {
- flash();
- if (Account::hasActive()) {
+ if (selected == numchallengelevels) {
+ fireSound();
+ flash();
mainmenu = 5;
- } else {
- mainmenu = 1;
}
- newusername.clear();
- newuserselected = 0;
- entername = 0;
- }
- break;
- case 8:
- fireSound();
- flash();
- if (selected <= 2)
- Account::active().setDifficulty(selected);
- mainmenu = 5;
- break;
- case 9:
- if (selected < numchallengelevels && selected <= Account::active().getProgress()) {
- fireSound();
- flash();
-
- startbonustotal = 0;
-
- loading = 2;
- loadtime = 0;
- targetlevel = selected;
- if (firstLoadDone) {
- TickOnceAfter();
- } else {
- LoadStuff();
+ break;
+ case 10:
+ if (selected == 3) {
+ fireSound();
+ flash();
+ mainmenu = 5;
}
- LoadLevel(selected);
- campaign = 0;
-
- mainmenu = 0;
- gameon = 1;
- pause_sound(stream_menutheme);
- }
- if (selected == numchallengelevels) {
- fireSound();
- flash();
- mainmenu = 5;
- }
- break;
- case 10:
- if (selected == 3) {
- fireSound();
- flash();
- mainmenu = 5;
- }
- break;
- case 18:
- if (selected == 1)
- stereoseparation += 0.001;
- else {
- fireSound();
- if (selected == 0) {
- newstereomode = (StereoMode)(newstereomode + 1);
- while (!CanInitStereo(newstereomode)) {
- printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode).c_str(), newstereomode);
+ break;
+ case 18:
+ if (selected == 1)
+ stereoseparation += 0.001;
+ else {
+ fireSound();
+ if (selected == 0) {
newstereomode = (StereoMode)(newstereomode + 1);
- if (newstereomode >= stereoCount)
- newstereomode = stereoNone;
+ while (!CanInitStereo(newstereomode)) {
+ printf("Failed to initialize mode %s (%i)\n", StereoModeName(newstereomode).c_str(), newstereomode);
+ newstereomode = (StereoMode)(newstereomode + 1);
+ if (newstereomode >= stereoCount)
+ newstereomode = stereoNone;
+ }
+ } else if (selected == 2) {
+ stereoreverse = !stereoreverse;
+ } else if (selected == 3) {
+ flash();
+ mainmenu = 3;
+
+ stereomode = newstereomode;
+ InitStereo(stereomode);
}
- } else if (selected == 2) {
- stereoreverse = !stereoreverse;
- } else if (selected == 3) {
- flash();
- mainmenu = 3;
-
- stereomode = newstereomode;
- InitStereo(stereomode);
}
- }
- updateStereoConfigMenu();
- break;
+ updateStereoConfigMenu();
+ break;
}
}
if (entername) {
inputText(newusername, &newuserselected);
- if (!waiting) { // the input as finished
+ if (!waiting) { // the input as finished
if (!newusername.empty()) { // with enter
Account::add(string(newusername));
if (oldmainmenu != mainmenu)
Load();
oldmainmenu = mainmenu;
-
}
int setKeySelected_thread(void*)
while (scancode == -1) {
SDL_WaitEvent(&evenement);
switch (evenement.type) {
- case SDL_KEYDOWN:
- scancode = evenement.key.keysym.scancode;
- break;
- case SDL_MOUSEBUTTONDOWN:
- scancode = SDL_NUM_SCANCODES + evenement.button.button;
- break;
- default:
- break;
+ case SDL_KEYDOWN:
+ scancode = evenement.key.keysym.scancode;
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ scancode = SDL_NUM_SCANCODES + evenement.button.button;
+ break;
+ default:
+ break;
}
}
if (scancode != SDL_SCANCODE_ESCAPE) {
fireSound();
switch (keyselect) {
- case 0:
- forwardkey = scancode;
- break;
- case 1:
- backkey = scancode;
- break;
- case 2:
- leftkey = scancode;
- break;
- case 3:
- rightkey = scancode;
- break;
- case 4:
- crouchkey = scancode;
- break;
- case 5:
- jumpkey = scancode;
- break;
- case 6:
- drawkey = scancode;
- break;
- case 7:
- throwkey = scancode;
- break;
- case 8:
- attackkey = scancode;
- break;
- case 9:
- consolekey = scancode;
- break;
- default:
- break;
+ case 0:
+ forwardkey = scancode;
+ break;
+ case 1:
+ backkey = scancode;
+ break;
+ case 2:
+ leftkey = scancode;
+ break;
+ case 3:
+ rightkey = scancode;
+ break;
+ case 4:
+ crouchkey = scancode;
+ break;
+ case 5:
+ jumpkey = scancode;
+ break;
+ case 6:
+ drawkey = scancode;
+ break;
+ case 7:
+ throwkey = scancode;
+ break;
+ case 8:
+ attackkey = scancode;
+ break;
+ case 9:
+ consolekey = scancode;
+ break;
+ default:
+ break;
}
}
keyselect = -1;
waiting = true;
printf("launch thread\n");
SDL_Thread* thread = SDL_CreateThread(setKeySelected_thread, NULL, NULL);
- if ( thread == NULL ) {
+ if (thread == NULL) {
fprintf(stderr, "Unable to create thread: %s\n", SDL_GetError());
waiting = false;
return;
//Functions
-Object::Object() :
- position(),
- type(boxtype),
- yaw(0),
- pitch(0),
- rotx(0),
- rotxvel(0),
- roty(0),
- rotyvel(0),
- possible(false),
- model(),
- displaymodel(),
- friction(0),
- scale(0),
- messedwith(0),
- checked(0),
- shadowed(0),
- occluded(0),
- onfire(false),
- flamedelay(0)
+Object::Object()
+ : position()
+ , type(boxtype)
+ , yaw(0)
+ , pitch(0)
+ , rotx(0)
+ , rotxvel(0)
+ , roty(0)
+ , rotyvel(0)
+ , possible(false)
+ , model()
+ , displaymodel()
+ , friction(0)
+ , scale(0)
+ , messedwith(0)
+ , checked(0)
+ , shadowed(0)
+ , occluded(0)
+ , onfire(false)
+ , flamedelay(0)
{
}
-Object::Object(object_type _type, XYZ _position, float _yaw, float _pitch, float _scale) : Object()
+Object::Object(object_type _type, XYZ _position, float _yaw, float _pitch, float _scale)
+ : Object()
{
scale = _scale;
type = _type;
yaw = _yaw;
pitch = _pitch;
- switch(type) {
+ switch (type) {
case boxtype:
model.loaddecal("Models/Box.solid");
friction = 1.5;
{
messedwith -= multiplier;
if (rotxvel || rotx) {
- if (rotx > 0) rotxvel -= multiplier * 8 * fabs(rotx);
- if (rotx < 0) rotxvel += multiplier * 8 * fabs(rotx);
- if (rotx > 0) rotxvel -= multiplier * 4;
- if (rotx < 0) rotxvel += multiplier * 4;
- if (rotxvel > 0) rotxvel -= multiplier * 4;
- if (rotxvel < 0) rotxvel += multiplier * 4;
+ if (rotx > 0)
+ rotxvel -= multiplier * 8 * fabs(rotx);
+ if (rotx < 0)
+ rotxvel += multiplier * 8 * fabs(rotx);
+ if (rotx > 0)
+ rotxvel -= multiplier * 4;
+ if (rotx < 0)
+ rotxvel += multiplier * 4;
+ if (rotxvel > 0)
+ rotxvel -= multiplier * 4;
+ if (rotxvel < 0)
+ rotxvel += multiplier * 4;
if (fabs(rotx) < multiplier * 4)
rotx = 0;
if (fabs(rotxvel) < multiplier * 4)
rotx += rotxvel * multiplier * 4;
}
if (rotyvel || roty) {
- if (roty > 0) rotyvel -= multiplier * 8 * fabs(roty);
- if (roty < 0) rotyvel += multiplier * 8 * fabs(roty);
- if (roty > 0) rotyvel -= multiplier * 4;
- if (roty < 0) rotyvel += multiplier * 4;
- if (rotyvel > 0) rotyvel -= multiplier * 4;
- if (rotyvel < 0) rotyvel += multiplier * 4;
+ if (roty > 0)
+ rotyvel -= multiplier * 8 * fabs(roty);
+ if (roty < 0)
+ rotyvel += multiplier * 8 * fabs(roty);
+ if (roty > 0)
+ rotyvel -= multiplier * 4;
+ if (roty < 0)
+ rotyvel += multiplier * 4;
+ if (rotyvel > 0)
+ rotyvel -= multiplier * 4;
+ if (rotyvel < 0)
+ rotyvel += multiplier * 4;
if (fabs(roty) < multiplier * 4)
roty = 0;
if (fabs(rotyvel) < multiplier * 4)
if (!hidden) {
if (detail == 2 && distance > viewdistance * viewdistance / 4 && environment == desertenvironment)
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, blurness);
else
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
if (distance > 1)
distance = 1;
}
}
-void Object::SphereCheckPossible(XYZ *p1, float radius)
+void Object::SphereCheckPossible(XYZ* p1, float radius)
{
int whichpatchx = p1->x / (terrain.size / subdivision * terrain.scale);
int whichpatchz = p1->z / (terrain.size / subdivision * terrain.scale);
objects[i]->draw();
}
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
for (unsigned i = 0; i < objects.size(); i++) {
objects[i]->drawSecondPass();
}
if (environment == desertenvironment) {
- glTexEnvf( GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0 );
+ glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0);
}
glEnable(GL_ALPHA_TEST);
SetUpLight(&light, 0);
for (unsigned int i = 0; i < objects.size(); i++) {
if (checkcollide(startpoint, endpoint, i, minx, miny, minz, maxx, maxy, maxz) != -1) {
- return (int) i;
+ return (int)i;
}
}
return what;
}
} else {
- if ( objects[what]->position.x > minx - objects[what]->model.boundingsphereradius &&
- objects[what]->position.x < maxx + objects[what]->model.boundingsphereradius &&
- objects[what]->position.y > miny - objects[what]->model.boundingsphereradius &&
- objects[what]->position.y < maxy + objects[what]->model.boundingsphereradius &&
- objects[what]->position.z > minz - objects[what]->model.boundingsphereradius &&
- objects[what]->position.z < maxz + objects[what]->model.boundingsphereradius) {
- if ( objects[what]->type != treeleavestype &&
- objects[what]->type != bushtype &&
- objects[what]->type != firetype) {
+ if (objects[what]->position.x > minx - objects[what]->model.boundingsphereradius &&
+ objects[what]->position.x < maxx + objects[what]->model.boundingsphereradius &&
+ objects[what]->position.y > miny - objects[what]->model.boundingsphereradius &&
+ objects[what]->position.y < maxy + objects[what]->model.boundingsphereradius &&
+ objects[what]->position.z > minz - objects[what]->model.boundingsphereradius &&
+ objects[what]->position.z < maxz + objects[what]->model.boundingsphereradius) {
+ if (objects[what]->type != treeleavestype &&
+ objects[what]->type != bushtype &&
+ objects[what]->type != firetype) {
colviewer = startpoint;
coltarget = endpoint;
if (objects[what]->model.LineCheck(&colviewer, &coltarget, &colpoint, &objects[what]->position, &objects[what]->yaw) != -1) {
//~ Object::~Objects()
//~ {
- //~ boxtextureptr.destroy();
- //~ treetextureptr.destroy();
- //~ bushtextureptr.destroy();
- //~ rocktextureptr.destroy();
+//~ boxtextureptr.destroy();
+//~ treetextureptr.destroy();
+//~ bushtextureptr.destroy();
+//~ rocktextureptr.destroy();
//~ }
#include "Objects/Person.hpp"
#include "Animation/Animation.hpp"
-#include "Audio/openal_wrapper.hpp"
#include "Audio/Sounds.hpp"
+#include "Audio/openal_wrapper.hpp"
#include "Game.hpp"
#include "Level/Awards.hpp"
#include "Level/Dialog.hpp"
-#include "Utils/Folders.hpp"
#include "Tutorial.hpp"
+#include "Utils/Folders.hpp"
extern float multiplier;
extern Terrain terrain;
std::vector<std::shared_ptr<Person>> Person::players(1, std::shared_ptr<Person>(new Person()));
-Person::Person() :
- whichpatchx(0),
- whichpatchz(0),
- animCurrent(bounceidleanim),
- animTarget(bounceidleanim),
- frameCurrent(0),
- frameTarget(1),
- oldanimCurrent(0),
- oldanimTarget(0),
- oldframeCurrent(0),
- oldframeTarget(0),
- howactive(typeactive),
- parriedrecently(0),
- superruntoggle(false),
- lastattack(0), lastattack2(0), lastattack3(0),
- currentoffset(), targetoffset(), offset(),
- target(0),
- transspeed(0),
-
- realoldcoords(),
- oldcoords(),
- coords(),
- velocity(),
-
- proportionhead(),
- proportionlegs(),
- proportionarms(),
- proportionbody(),
-
- unconscioustime(0),
-
- immobile(false),
-
- velspeed(0),
- targetyaw(0),
- targetrot(0),
- rot(0),
- oldrot(0),
- lookyaw(0),
- lookpitch(0),
- yaw(0),
- pitch(0),
- lowyaw(0),
- tilt(0),
- targettilt(0),
- tilt2(0),
- targettilt2(0),
- rabbitkickenabled(false),
-
- bloodloss(0),
- bleeddelay(0),
- skiddelay(0),
- skiddingdelay(0),
- deathbleeding(0),
- tempdeltav(0),
-
- damagetolerance(200),
- damage(0),
- permanentdamage(0),
- superpermanentdamage(0),
- lastcollide(0),
- dead(0),
-
- jumppower(5),
- onground(false),
-
- wentforweapon(0),
-
- calcrot(false),
-
- facing(),
-
- bleeding(0),
- bleedx(0), bleedy(0),
- direction(0),
- texupdatedelay(0),
-
- headyaw(0), headpitch(0),
- targetheadyaw(0), targetheadpitch(0),
-
- onterrain(false),
- pause(false),
-
- grabdelay(0),
-
- victim(nullptr),
- hasvictim(false),
-
- updatedelay(0),
- normalsupdatedelay(0),
-
- jumpstart(false),
- forwardkeydown(false),
- forwardstogglekeydown(false),
- rightkeydown(false),
- leftkeydown(false),
- backkeydown(false),
- jumpkeydown(false),
- jumptogglekeydown(false),
- crouchkeydown(false),
- crouchtogglekeydown(false),
- drawkeydown(false),
- drawtogglekeydown(false),
- throwkeydown(false),
- throwtogglekeydown(false),
- attackkeydown(false),
- feint(false),
- lastfeint(false),
- headless(false),
-
- crouchkeydowntime(0),
- jumpkeydowntime(0),
- freefall(false),
-
- turnspeed(0),
-
- aitype(passivetype),
- aiupdatedelay(0),
- losupdatedelay(0),
- ally(0),
- collide(0),
- collided(-10),
- avoidcollided(0),
- loaded(false),
- whichdirection(false),
- whichdirectiondelay(0),
- avoidsomething(false),
- avoidwhere(),
- blooddimamount(0),
-
- staggerdelay(0),
- blinkdelay(0),
- twitchdelay(0),
- twitchdelay2(0),
- twitchdelay3(0),
- lefthandmorphness(0),
- righthandmorphness(0),
- headmorphness(0),
- chestmorphness(0),
- tailmorphness(0),
- targetlefthandmorphness(0),
- targetrighthandmorphness(0),
- targetheadmorphness(1),
- targetchestmorphness(0),
- targettailmorphness(0),
- lefthandmorphstart(0), lefthandmorphend(0),
- righthandmorphstart(0), righthandmorphend(0),
- headmorphstart(0), headmorphend(0),
- chestmorphstart(0), chestmorphend(0),
- tailmorphstart(0), tailmorphend(0),
-
- weaponmissdelay(0),
- highreversaldelay(0),
- lowreversaldelay(0),
-
- creature(rabbittype),
-
- id(0),
-
- skeleton(),
-
- speed(0),
- scale(-1),
- power(0),
- speedmult(0),
-
- protectionhead(0),
- protectionhigh(0),
- protectionlow(0),
- armorhead(0),
- armorhigh(0),
- armorlow(0),
- metalhead(false),
- metalhigh(false),
- metallow(false),
-
- numclothes(0),
-
- landhard(false),
- bled(false),
- spurt(false),
- onfire(false),
- onfiredelay(0),
- burnt(0),
-
- flamedelay(0),
-
- playerdetail(0),
-
- num_weapons(0),
- weaponactive(-1),
- weaponstuck(-1),
- weaponstuckwhere(0),
-
- numwaypoints(0),
- pausetime(0),
-
- headtarget(),
- interestdelay(0),
-
- finalfinaltarget(),
- finaltarget(),
- finalpathfindpoint(0),
- targetpathfindpoint(0),
- lastpathfindpoint(0),
- lastpathfindpoint2(0),
- lastpathfindpoint3(0),
- lastpathfindpoint4(0),
-
- waypoint(0),
-
- lastseen(),
- lastseentime(0),
- lastchecktime(0),
- stunned(0),
- surprised(0),
- runninghowlong(0),
- occluded(0),
- lastoccluded(0),
- laststanding(0),
- escapednum(0),
-
- speechdelay(0),
- neckspurtdelay(0),
- neckspurtparticledelay(0),
- neckspurtamount(0),
-
- whichskin(0),
- rabbitkickragdoll(false),
-
- tempanimation(),
+Person::Person()
+ : whichpatchx(0)
+ , whichpatchz(0)
+ , animCurrent(bounceidleanim)
+ , animTarget(bounceidleanim)
+ , frameCurrent(0)
+ , frameTarget(1)
+ , oldanimCurrent(0)
+ , oldanimTarget(0)
+ , oldframeCurrent(0)
+ , oldframeTarget(0)
+ , howactive(typeactive)
+ , parriedrecently(0)
+ , superruntoggle(false)
+ , lastattack(0)
+ , lastattack2(0)
+ , lastattack3(0)
+ , currentoffset()
+ , targetoffset()
+ , offset()
+ , target(0)
+ , transspeed(0)
+ ,
+
+ realoldcoords()
+ , oldcoords()
+ , coords()
+ , velocity()
+ ,
+
+ proportionhead()
+ , proportionlegs()
+ , proportionarms()
+ , proportionbody()
+ ,
+
+ unconscioustime(0)
+ ,
+
+ immobile(false)
+ ,
+
+ velspeed(0)
+ , targetyaw(0)
+ , targetrot(0)
+ , rot(0)
+ , oldrot(0)
+ , lookyaw(0)
+ , lookpitch(0)
+ , yaw(0)
+ , pitch(0)
+ , lowyaw(0)
+ , tilt(0)
+ , targettilt(0)
+ , tilt2(0)
+ , targettilt2(0)
+ , rabbitkickenabled(false)
+ ,
+
+ bloodloss(0)
+ , bleeddelay(0)
+ , skiddelay(0)
+ , skiddingdelay(0)
+ , deathbleeding(0)
+ , tempdeltav(0)
+ ,
+
+ damagetolerance(200)
+ , damage(0)
+ , permanentdamage(0)
+ , superpermanentdamage(0)
+ , lastcollide(0)
+ , dead(0)
+ ,
+
+ jumppower(5)
+ , onground(false)
+ ,
+
+ wentforweapon(0)
+ ,
+
+ calcrot(false)
+ ,
+
+ facing()
+ ,
+
+ bleeding(0)
+ , bleedx(0)
+ , bleedy(0)
+ , direction(0)
+ , texupdatedelay(0)
+ ,
+
+ headyaw(0)
+ , headpitch(0)
+ , targetheadyaw(0)
+ , targetheadpitch(0)
+ ,
+
+ onterrain(false)
+ , pause(false)
+ ,
+
+ grabdelay(0)
+ ,
+
+ victim(nullptr)
+ , hasvictim(false)
+ ,
+
+ updatedelay(0)
+ , normalsupdatedelay(0)
+ ,
+
+ jumpstart(false)
+ , forwardkeydown(false)
+ , forwardstogglekeydown(false)
+ , rightkeydown(false)
+ , leftkeydown(false)
+ , backkeydown(false)
+ , jumpkeydown(false)
+ , jumptogglekeydown(false)
+ , crouchkeydown(false)
+ , crouchtogglekeydown(false)
+ , drawkeydown(false)
+ , drawtogglekeydown(false)
+ , throwkeydown(false)
+ , throwtogglekeydown(false)
+ , attackkeydown(false)
+ , feint(false)
+ , lastfeint(false)
+ , headless(false)
+ ,
+
+ crouchkeydowntime(0)
+ , jumpkeydowntime(0)
+ , freefall(false)
+ ,
+
+ turnspeed(0)
+ ,
+
+ aitype(passivetype)
+ , aiupdatedelay(0)
+ , losupdatedelay(0)
+ , ally(0)
+ , collide(0)
+ , collided(-10)
+ , avoidcollided(0)
+ , loaded(false)
+ , whichdirection(false)
+ , whichdirectiondelay(0)
+ , avoidsomething(false)
+ , avoidwhere()
+ , blooddimamount(0)
+ ,
+
+ staggerdelay(0)
+ , blinkdelay(0)
+ , twitchdelay(0)
+ , twitchdelay2(0)
+ , twitchdelay3(0)
+ , lefthandmorphness(0)
+ , righthandmorphness(0)
+ , headmorphness(0)
+ , chestmorphness(0)
+ , tailmorphness(0)
+ , targetlefthandmorphness(0)
+ , targetrighthandmorphness(0)
+ , targetheadmorphness(1)
+ , targetchestmorphness(0)
+ , targettailmorphness(0)
+ , lefthandmorphstart(0)
+ , lefthandmorphend(0)
+ , righthandmorphstart(0)
+ , righthandmorphend(0)
+ , headmorphstart(0)
+ , headmorphend(0)
+ , chestmorphstart(0)
+ , chestmorphend(0)
+ , tailmorphstart(0)
+ , tailmorphend(0)
+ ,
+
+ weaponmissdelay(0)
+ , highreversaldelay(0)
+ , lowreversaldelay(0)
+ ,
+
+ creature(rabbittype)
+ ,
+
+ id(0)
+ ,
+
+ skeleton()
+ ,
+
+ speed(0)
+ , scale(-1)
+ , power(0)
+ , speedmult(0)
+ ,
+
+ protectionhead(0)
+ , protectionhigh(0)
+ , protectionlow(0)
+ , armorhead(0)
+ , armorhigh(0)
+ , armorlow(0)
+ , metalhead(false)
+ , metalhigh(false)
+ , metallow(false)
+ ,
+
+ numclothes(0)
+ ,
+
+ landhard(false)
+ , bled(false)
+ , spurt(false)
+ , onfire(false)
+ , onfiredelay(0)
+ , burnt(0)
+ ,
+
+ flamedelay(0)
+ ,
+
+ playerdetail(0)
+ ,
+
+ num_weapons(0)
+ , weaponactive(-1)
+ , weaponstuck(-1)
+ , weaponstuckwhere(0)
+ ,
+
+ numwaypoints(0)
+ , pausetime(0)
+ ,
+
+ headtarget()
+ , interestdelay(0)
+ ,
+
+ finalfinaltarget()
+ , finaltarget()
+ , finalpathfindpoint(0)
+ , targetpathfindpoint(0)
+ , lastpathfindpoint(0)
+ , lastpathfindpoint2(0)
+ , lastpathfindpoint3(0)
+ , lastpathfindpoint4(0)
+ ,
+
+ waypoint(0)
+ ,
+
+ lastseen()
+ , lastseentime(0)
+ , lastchecktime(0)
+ , stunned(0)
+ , surprised(0)
+ , runninghowlong(0)
+ , occluded(0)
+ , lastoccluded(0)
+ , laststanding(0)
+ , escapednum(0)
+ ,
+
+ speechdelay(0)
+ , neckspurtdelay(0)
+ , neckspurtparticledelay(0)
+ , neckspurtamount(0)
+ ,
+
+ whichskin(0)
+ , rabbitkickragdoll(false)
+ ,
+
+ tempanimation()
+ ,
jumpclimb(false)
{
}
/* Read a person in tfile. Throws an error if it’s not valid */
-Person::Person(FILE *tfile, int mapvers, unsigned i) : Person()
+Person::Person(FILE* tfile, int mapvers, unsigned i)
+ : Person()
{
id = i;
funpackf(tfile, "Bi Bi Bf Bf Bf Bi", &whichskin, &creature, &coords.x, &coords.y, &coords.z, &num_weapons);
"Models/Body7.solid",
"Models/BodyLow.solid",
"Models/Belt.solid",
- clothes
- );
+ clothes);
} else {
skeleton.Load(
"Skeleton/BasicFigureWolf",
"Models/Wolf7.solid",
"Models/WolfLow.solid",
"Models/Belt.solid",
- clothes
- );
+ clothes);
}
skeleton.drawmodel.textureptr.load(creatureskin[creature][whichskin], 1, &skeleton.skinText[0], &skeleton.skinsize);
*/
void Person::CheckKick()
{
- if (!(hasvictim
- && (animTarget == rabbitkickanim
- && victim
- && victim != this->shared_from_this()
- && frameCurrent >= 2
- && animCurrent == rabbitkickanim)
- && distsq(&coords, &victim->coords) < 1.2
- && !victim->skeleton.free))
+ if (!(hasvictim && (animTarget == rabbitkickanim && victim && victim != this->shared_from_this() && frameCurrent >= 2 && animCurrent == rabbitkickanim) && distsq(&coords, &victim->coords) < 1.2 && !victim->skeleton.free))
return;
if (Animation::animations[victim->animTarget].height != lowheight) {
return talkidleanim;
if (hasvictim && (victim != this->shared_from_this())) {
if ((!victim->dead && victim->aitype != passivetype &&
- victim->aitype != searchtype && aitype != passivetype && aitype != searchtype &&
- victim->id < Person::players.size())) {
+ victim->aitype != searchtype && aitype != passivetype && aitype != searchtype &&
+ victim->id < Person::players.size())) {
if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) {
if (creature == rabbittype)
return fightidleanim;
}
if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype)
return hurtidleanim;
- if (howactive == typesitting) return sitanim;
- if (howactive == typesittingwall) return sitwallanim;
- if (howactive == typesleeping) return sleepanim;
- if (howactive == typedead1) return dead1anim;
- if (howactive == typedead2) return dead2anim;
- if (howactive == typedead3) return dead3anim;
- if (howactive == typedead4) return dead4anim;
- if (creature == rabbittype) return bounceidleanim;
- if (creature == wolftype) return wolfidle;
+ if (howactive == typesitting)
+ return sitanim;
+ if (howactive == typesittingwall)
+ return sitwallanim;
+ if (howactive == typesleeping)
+ return sleepanim;
+ if (howactive == typedead1)
+ return dead1anim;
+ if (howactive == typedead2)
+ return dead2anim;
+ if (howactive == typedead3)
+ return dead3anim;
+ if (howactive == typedead4)
+ return dead4anim;
+ if (creature == rabbittype)
+ return bounceidleanim;
+ if (creature == wolftype)
+ return wolfidle;
return 0;
}
bloodvel.z = 10;
bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
- Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
}
if (Random() % 2 == 0) // 50% chance
if (skeleton.free) {
Sprite::MakeSprite(splintersprite, jointPos(head) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
} else {
- Sprite::MakeSprite(splintersprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
+ Sprite::MakeSprite(splintersprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
}
Sprite::setLastSpriteSpecial(3); // sets it to teeth
}
bleedx /= realtexdetail;
direction = abs(Random() % 2) * 2 - 1;
}
-
}
if (bleeding > 2)
bleeding = 2;
bloodvel.z = 10;
bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
- Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
}
}
offsetx = 20;
}
-
int startx = 512;
int starty = 512;
int endx = 0;
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx) startx = i;
- if (j < starty) starty = j;
- if (i > endx) endx = i;
- if (j > endy) endy = j;
+ if (i < startx)
+ startx = i;
+ if (j < starty)
+ starty = j;
+ if (i > endx)
+ endx = i;
+ if (j > endy)
+ endy = j;
}
}
}
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx) startx = i;
- if (j < starty) starty = j;
- if (i > endx) endx = i;
- if (j > endy) endy = j;
+ if (i < startx)
+ startx = i;
+ if (j < starty)
+ starty = j;
+ if (i > endx)
+ endx = i;
+ if (j > endy)
+ endy = j;
}
}
}
starty += offsety;
endy += offsety;
- if (startx < 0) startx = 0;
- if (starty < 0) starty = 0;
- if (endx > 512 - 1) endx = 512 - 1;
- if (endy > 512 - 1) endy = 512 - 1;
- if (endx < startx) endx = startx;
- if (endy < starty) endy = starty;
+ if (startx < 0)
+ startx = 0;
+ if (starty < 0)
+ starty = 0;
+ if (endx > 512 - 1)
+ endx = 512 - 1;
+ if (endy > 512 - 1)
+ endy = 512 - 1;
+ if (endx < startx)
+ endx = startx;
+ if (endy < starty)
+ endy = starty;
startx /= realtexdetail;
starty /= realtexdetail;
if (bleedy > skeleton.skinsize - 1)
bleedy = skeleton.skinsize - 1;
direction = abs(Random() % 2) * 2 - 1;
-
}
bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
deathbleeding += bleeding;
bary.y /= total;
bary.z /= total;
-
gxx.x = skeleton.drawmodel.Triangles[whichtri].gx[0];
gxx.y = skeleton.drawmodel.Triangles[whichtri].gx[1];
gxx.z = skeleton.drawmodel.Triangles[whichtri].gx[2];
bloodvel.z = 10;
bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
- Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
+ Sprite::MakeSprite(bloodflamesprite, DoRotation((jointPos(head) + jointPos(neck)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .3, 1);
}
}
}
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx) startx = i;
- if (j < starty) starty = j;
- if (i > endx) endx = i;
- if (j > endy) endy = j;
+ if (i < startx)
+ startx = i;
+ if (j < starty)
+ starty = j;
+ if (i > endx)
+ endx = i;
+ if (j > endy)
+ endy = j;
}
}
}
for (i = 0; i < 512; i++) {
for (j = 0; j < 512; j++) {
if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
- if (i < startx) startx = i;
- if (j < starty) starty = j;
- if (i > endx) endx = i;
- if (j > endy) endy = j;
+ if (i < startx)
+ startx = i;
+ if (j < starty)
+ starty = j;
+ if (i > endx)
+ endx = i;
+ if (j > endy)
+ endy = j;
}
}
}
starty += offsety;
endy += offsety;
- if (startx < 0) startx = 0;
- if (starty < 0) starty = 0;
- if (endx > 512 - 1) endx = 512 - 1;
- if (endy > 512 - 1) endy = 512 - 1;
- if (endx < startx) endx = startx;
- if (endy < starty) endy = starty;
+ if (startx < 0)
+ startx = 0;
+ if (starty < 0)
+ starty = 0;
+ if (endx > 512 - 1)
+ endx = 512 - 1;
+ if (endy > 512 - 1)
+ endy = 512 - 1;
+ if (endx < startx)
+ endx = startx;
+ if (endy < starty)
+ endy = starty;
startx /= realtexdetail;
starty /= realtexdetail;
return 1;
}
-
-
/* EFFECT
* guessing this performs a reversal
*/
void Person::Reverse()
{
- if (!((victim->aitype == playercontrolled
- || hostiletime > 1
- || staggerdelay <= 0)
- && victim->animTarget != jumpupanim
- && victim->animTarget != jumpdownanim
- && (!Tutorial::active || cananger)
- && hostile))
+ if (!((victim->aitype == playercontrolled || hostiletime > 1 || staggerdelay <= 0) && victim->animTarget != jumpupanim && victim->animTarget != jumpdownanim && (!Tutorial::active || cananger) && hostile))
return;
- if (normaldotproduct (victim->facing, victim->coords - coords) > 0
- && (victim->id != 0 || difficulty >= 2)
- && (creature != wolftype || victim->creature == wolftype))
+ if (normaldotproduct(victim->facing, victim->coords - coords) > 0 && (victim->id != 0 || difficulty >= 2) && (creature != wolftype || victim->creature == wolftype))
return;
if (animTarget == sweepanim) {
for (unsigned i = 0; i < Person::players.size(); i++) {
Person::players[i]->wentforweapon = 0;
}
-
-
}
}
if (hasvictim)
targetheadyaw = (float)((int)((0 - yaw - targetheadyaw + 180) * 100) % 36000) / 100;
targetheadpitch = (float)((int)(targetheadpitch * 100) % 36000) / 100;
- while (targetheadyaw > 180)targetheadyaw -= 360;
- while (targetheadyaw < -180)targetheadyaw += 360;
+ while (targetheadyaw > 180)
+ targetheadyaw -= 360;
+ while (targetheadyaw < -180)
+ targetheadyaw += 360;
if (targetheadyaw > 160)
targetheadpitch = targetheadpitch * -1;
freefall = 1;
skeleton.freefall = 1;
- if (!isnormal(velocity.x)) velocity.x = 0;
- if (!isnormal(velocity.y)) velocity.y = 0;
- if (!isnormal(velocity.z)) velocity.z = 0;
- if (!isnormal(yaw)) yaw = 0;
- if (!isnormal(coords.x)) coords = 0;
- if (!isnormal(tilt)) tilt = 0;
- if (!isnormal(tilt2)) tilt2 = 0;
+ if (!isnormal(velocity.x))
+ velocity.x = 0;
+ if (!isnormal(velocity.y))
+ velocity.y = 0;
+ if (!isnormal(velocity.z))
+ velocity.z = 0;
+ if (!isnormal(yaw))
+ yaw = 0;
+ if (!isnormal(coords.x))
+ coords = 0;
+ if (!isnormal(tilt))
+ tilt = 0;
+ if (!isnormal(tilt2))
+ tilt2 = 0;
for (unsigned i = 0; i < skeleton.joints.size(); i++) {
skeleton.joints[i].delay = 0;
skeleton.joints[i].locked = 0;
skeleton.joints[i].position = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
- if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = DoRotation(skeleton.joints[i].position, 0, yaw, 0);
- if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = coords;
+ if (!isnormal(skeleton.joints[i].position.x))
+ skeleton.joints[i].position = DoRotation(skeleton.joints[i].position, 0, yaw, 0);
+ if (!isnormal(skeleton.joints[i].position.x))
+ skeleton.joints[i].position = coords;
skeleton.joints[i].position.y += .1;
skeleton.joints[i].oldposition = skeleton.joints[i].position;
skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords;
}
}
-
-
/* EFFECT
*/
void Person::FootLand(bodypart whichfoot, float opacity)
if (!crouchkeydown && velocity.y >= -15)
landhard = 0;
}
- if ((animCurrent == jumpupanim || animTarget == jumpdownanim)/*&&velocity.y<40*/ && !isFlip() && (!isLanding() && !isLandhard()) && ((crouchkeydown && !crouchtogglekeydown))) {
+ if ((animCurrent == jumpupanim || animTarget == jumpdownanim) /*&&velocity.y<40*/ && !isFlip() && (!isLanding() && !isLandhard()) && ((crouchkeydown && !crouchtogglekeydown))) {
XYZ targfacing;
targfacing = 0;
targfacing.z = 1;
crouchtogglekeydown = 1;
}
-
if (Animation::animations[animTarget].attack || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim) {
if (detail)
normalsupdatedelay = 0;
FootLand(rightfoot, 1);
FootLand(leftfoot, 1);
}
-
}
if (terrain.getOpacity(coords.x, coords.z) >= .2) {
if (targetFrame().label == 1)
if (Animation::animations[animTarget].attack != neutral) {
unsigned r = abs(Random() % 4);
if (creature == rabbittype) {
- if (r == 0) whichsound = rabbitattacksound;
- if (r == 1) whichsound = rabbitattack2sound;
- if (r == 2) whichsound = rabbitattack3sound;
- if (r == 3) whichsound = rabbitattack4sound;
+ if (r == 0)
+ whichsound = rabbitattacksound;
+ if (r == 1)
+ whichsound = rabbitattack2sound;
+ if (r == 2)
+ whichsound = rabbitattack3sound;
+ if (r == 3)
+ whichsound = rabbitattack4sound;
}
if (creature == wolftype) {
- if (r == 0) whichsound = barksound;
- if (r == 1) whichsound = bark2sound;
- if (r == 2) whichsound = bark3sound;
- if (r == 3) whichsound = barkgrowlsound;
+ if (r == 0)
+ whichsound = barksound;
+ if (r == 1)
+ whichsound = bark2sound;
+ if (r == 2)
+ whichsound = bark3sound;
+ if (r == 3)
+ whichsound = barkgrowlsound;
}
speechdelay = .3;
}
}
}
-
-
if ((!wasLanding() && !wasLandhard()) && animCurrent != getIdle() && (isLanding() || isLandhard())) {
FootLand(leftfoot, 1);
FootLand(rightfoot, 1);
}
}
-
if ((animCurrent == walljumprightkickanim && animTarget == walljumprightkickanim) || (animCurrent == walljumpleftkickanim && animTarget == walljumpleftkickanim)) {
XYZ rotatetarget = DoRotation(skeleton.forward, 0, yaw, 0);
Normalise(&rotatetarget);
if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && frameTarget == 3 && (jumpkeydown || attackkeydown || id != 0))
dojumpattack = 1;
if (hasvictim)
- if (distsq(&victim->coords, &/*Person::players[i]->*/coords) < 5 && victim->aitype == gethelptype && (attackkeydown) && !victim->skeleton.free && victim->isRun() && victim->runninghowlong >= 1)
+ if (distsq(&victim->coords, &/*Person::players[i]->*/ coords) < 5 && victim->aitype == gethelptype && (attackkeydown) && !victim->skeleton.free && victim->isRun() && victim->runninghowlong >= 1)
dojumpattack = 1;
if (!hostile)
dojumpattack = 0;
staggerdelay = .5;
if (!victim->dead)
staggerdelay = 1.2;
-
-
}
}
//victim->skeleton.joints[i].velocity=0;
}
emit_sound_at(fleshstabsound, coords, 128);
-
}
if (whichtri != -1 || weapons[weaponids[weaponactive]].bloody) {
weapons[weaponids[weaponactive]].blooddrip += 5;
}
}
-
if (animTarget == winduppunchanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 2) {
escapednum = 0;
if (animTarget == knifeslashstartanim && Animation::animations[animTarget].frames[frameCurrent].label == 5) {
if (hasvictim)
- if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 &&/*Animation::animations[victim->animTarget].height!=lowheight&&*/victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
+ if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 && /*Animation::animations[victim->animTarget].height!=lowheight&&*/ victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
escapednum = 0;
if (!Tutorial::active) {
victim->DoBloodBig(1.5 / victim->armorhigh, 225);
}
}
-
XYZ aim;
victim->Puff(righthand);
victim->target = 0;
for (unsigned i = 0; i < Person::players.size(); i++) {
Person::players[i]->wentforweapon = 0;
}
-
}
}
}
victim->DoBloodBig(2 / victim->armorhigh, 170);
}
}
-
}
}
}
SolidHitBonus(id);
-
}
}
}
}
}
-
-
if (animTarget == swordslashreversalanim && Animation::animations[animTarget].frames[frameCurrent].label == 7) {
escapednum = 0;
victim->RagDoll(1);
Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .2, 1);
Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .2, 1);
-
}
victim->bloodloss += 10000;
victim->velocity = 0;
}
}
-
//Animation end
if (frameTarget > int(Animation::animations[animCurrent].frames.size()) - 1) {
frameTarget = 0;
skeleton.muscles[i].newrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
skeleton.muscles[i].newrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
- if (skeleton.muscles[i].newrotate3 > skeleton.muscles[i].oldrotate3 + 180) skeleton.muscles[i].newrotate3 -= 360;
- if (skeleton.muscles[i].newrotate3 < skeleton.muscles[i].oldrotate3 - 180) skeleton.muscles[i].newrotate3 += 360;
- if (skeleton.muscles[i].newrotate2 > skeleton.muscles[i].oldrotate2 + 180) skeleton.muscles[i].newrotate2 -= 360;
- if (skeleton.muscles[i].newrotate2 < skeleton.muscles[i].oldrotate2 - 180) skeleton.muscles[i].newrotate2 += 360;
- if (skeleton.muscles[i].newrotate1 > skeleton.muscles[i].oldrotate1 + 180) skeleton.muscles[i].newrotate1 -= 360;
- if (skeleton.muscles[i].newrotate1 < skeleton.muscles[i].oldrotate1 - 180) skeleton.muscles[i].newrotate1 += 360;
+ if (skeleton.muscles[i].newrotate3 > skeleton.muscles[i].oldrotate3 + 180)
+ skeleton.muscles[i].newrotate3 -= 360;
+ if (skeleton.muscles[i].newrotate3 < skeleton.muscles[i].oldrotate3 - 180)
+ skeleton.muscles[i].newrotate3 += 360;
+ if (skeleton.muscles[i].newrotate2 > skeleton.muscles[i].oldrotate2 + 180)
+ skeleton.muscles[i].newrotate2 -= 360;
+ if (skeleton.muscles[i].newrotate2 < skeleton.muscles[i].oldrotate2 - 180)
+ skeleton.muscles[i].newrotate2 += 360;
+ if (skeleton.muscles[i].newrotate1 > skeleton.muscles[i].oldrotate1 + 180)
+ skeleton.muscles[i].newrotate1 -= 360;
+ if (skeleton.muscles[i].newrotate1 < skeleton.muscles[i].oldrotate1 - 180)
+ skeleton.muscles[i].newrotate1 += 360;
}
}
}
if (skeleton.free) {
bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0);
bloodvel += DoRotation(jointVel(head), ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
- Sprite::MakeSprite(bloodsprite, (jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5)*scale + coords, bloodvel, 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, (jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5) * scale + coords, bloodvel, 1, 1, 1, .05, .9);
} else {
bloodvel.z = 5 * neckspurtamount;
bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0) * scale;
- Sprite::MakeSprite(bloodsprite, DoRotation(jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, .9);
+ Sprite::MakeSprite(bloodsprite, DoRotation(jointPos(neck) + (jointPos(neck) - jointPos(head)) / 5, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .05, .9);
}
neckspurtparticledelay = .05;
}
Sprite::MakeSprite(bloodsprite, jointPos(abdomen) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
} else {
bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
- Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(abdomen) + jointPos(abdomen)) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
+ Sprite::MakeSprite(bloodsprite, DoRotation((jointPos(abdomen) + jointPos(abdomen)) / 2, 0, yaw, 0) * scale + coords, bloodvel, 1, 1, 1, .05, 1);
}
}
}
righthandmorphness = 0;
targetrighthandmorphness = 1;
righthandmorphend = 1;
- if (Random() % 2 == 0)twitchdelay3 = (float)(abs(Random() % 40)) / 5;
+ if (Random() % 2 == 0)
+ twitchdelay3 = (float)(abs(Random() % 40)) / 5;
}
if (righthandmorphstart == 1 && righthandmorphend == 1) {
righthandmorphness = 0;
targetheadmorphness = 1;
}
-
if (howactive > typesleeping) {
XYZ headpoint;
headpoint = coords;
}
}
-
-
if ((id == 0 || distsq(&coords, &viewer) < 50) && autoslomo) {
slomo = 1;
slomodelay = .2;
targettilt2 = asin(terrainnormal.y) * 180 / 3.14 * -1;
-
if (skeleton.forward.y < 0) {
animTarget = getupfrombackanim;
frameTarget = 0;
targetyaw += 45;
}
if (backkeydown) {
- if ( !leftkeydown && !rightkeydown)
+ if (!leftkeydown && !rightkeydown)
targetyaw += 180;
}
targetyaw += 180;
}
if (skeleton.freefall == 0)
freefall = 0;
-
}
if (aitype != passivetype || skeleton.free == 1)
if (findLengthfast(&velocity) > .1)
for (unsigned int i = 0; i < Object::objects.size(); i++) {
if (Object::objects[i]->type == firetype)
- if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 49) {
+ if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 49) {
if (onfire) {
if (!Object::objects[i]->onfire) {
emit_sound_at(firestartsound, Object::objects[i]->position);
}
}
if (Object::objects[i]->type == bushtype)
- if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 49) {
+ if (distsqflat(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 12 && distsq(&coords, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 49) {
if (onfire) {
if (!Object::objects[i]->onfire) {
emit_sound_at(firestartsound, Object::objects[i]->position);
tempcoord = DoRotation(tempcoord, -Object::objects[i]->pitch, 0, 0);
tempcoord += Object::objects[i]->position;
}
- if (distsqflat(&tempcoord, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 8 && distsq(&tempcoord, &Object::objects[i]->position) < Object::objects[i]->scale*Object::objects[i]->scale * 300 && tempcoord.y > Object::objects[i]->position.y + 3 * Object::objects[i]->scale) {
+ if (distsqflat(&tempcoord, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 8 && distsq(&tempcoord, &Object::objects[i]->position) < Object::objects[i]->scale * Object::objects[i]->scale * 300 && tempcoord.y > Object::objects[i]->position.y + 3 * Object::objects[i]->scale) {
if (Object::objects[i]->messedwith <= 0) {
XYZ tempvel;
XYZ pos;
}
if (animTarget == spinkickanim ||
- animTarget == staffspinhitreversalanim ||
- animTarget == staffspinhitreversedanim ||
- animTarget == staffhitreversalanim ||
- animTarget == staffhitreversedanim ||
- animTarget == hurtidleanim ||
- animTarget == winduppunchanim ||
- animTarget == swordslashreversalanim ||
- animTarget == swordslashreversedanim ||
- animTarget == knifeslashreversalanim ||
- animTarget == knifeslashreversedanim ||
- animTarget == knifethrowanim ||
- animTarget == knifefollowanim ||
- animTarget == knifefollowedanim ||
- animTarget == killanim ||
- animTarget == dropkickanim ||
- animTarget == upunchanim ||
- animTarget == knifeslashstartanim ||
- animTarget == swordslashanim ||
- animTarget == staffhitanim ||
- animTarget == staffspinhitanim ||
- animTarget == staffgroundsmashanim ||
- animTarget == spinkickreversalanim ||
- animTarget == sweepreversalanim ||
- animTarget == lowkickanim ||
- animTarget == sweepreversedanim ||
- animTarget == rabbitkickreversalanim ||
- animTarget == rabbitkickreversedanim ||
- animTarget == jumpreversalanim ||
- animTarget == jumpreversedanim) {
+ animTarget == staffspinhitreversalanim ||
+ animTarget == staffspinhitreversedanim ||
+ animTarget == staffhitreversalanim ||
+ animTarget == staffhitreversedanim ||
+ animTarget == hurtidleanim ||
+ animTarget == winduppunchanim ||
+ animTarget == swordslashreversalanim ||
+ animTarget == swordslashreversedanim ||
+ animTarget == knifeslashreversalanim ||
+ animTarget == knifeslashreversedanim ||
+ animTarget == knifethrowanim ||
+ animTarget == knifefollowanim ||
+ animTarget == knifefollowedanim ||
+ animTarget == killanim ||
+ animTarget == dropkickanim ||
+ animTarget == upunchanim ||
+ animTarget == knifeslashstartanim ||
+ animTarget == swordslashanim ||
+ animTarget == staffhitanim ||
+ animTarget == staffspinhitanim ||
+ animTarget == staffgroundsmashanim ||
+ animTarget == spinkickreversalanim ||
+ animTarget == sweepreversalanim ||
+ animTarget == lowkickanim ||
+ animTarget == sweepreversedanim ||
+ animTarget == rabbitkickreversalanim ||
+ animTarget == rabbitkickreversedanim ||
+ animTarget == jumpreversalanim ||
+ animTarget == jumpreversedanim) {
//close hands and yell
if (righthandmorphend != 1 &&
- righthandmorphness == targetrighthandmorphness) {
+ righthandmorphness == targetrighthandmorphness) {
righthandmorphness = 0;
righthandmorphend = 1;
targetrighthandmorphness = 1;
}
if (lefthandmorphend != 1 &&
- lefthandmorphness == targetlefthandmorphness) {
+ lefthandmorphness == targetlefthandmorphness) {
lefthandmorphness = 0;
lefthandmorphend = 1;
targetlefthandmorphness = 1;
Normalise(&facing);
if (isRun() ||
- animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) {
+ animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) {
if (onterrain)
targettilt2 = -facing.y * 20;
else
velocity = flatfacing * velspeed;
}
-
if ((animTarget == bounceidleanim || animCurrent == hurtidleanim) && (animCurrent == fightidleanim || animCurrent == knifefightidleanim)) {
velocity -= facing * multiplier * speed * 700 * scale;
velspeed = findLength(&velocity);
velspeed = findLength(&velocity);
}
-
if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
velocity.y += gravity * multiplier;
}
}
if (animTarget == jumpdownanim || isFlip()) {
- if (isFlip())jumppower = -4;
+ if (isFlip())
+ jumppower = -4;
animTarget = getLanding();
emit_sound_at(landsound, coords, 128.);
onterrain = 1;
}
-
if (isIdle() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || isStop() || animTarget == removeknifeanim || animTarget == crouchremoveknifeanim || isLanding() || isCrouch() || Animation::animations[animTarget].attack || (animTarget == rollanim && targetFrame().label == 6)) {
velspeed = findLength(&velocity);
velocity.y = 0;
}
}
-
/* EFFECT
* inverse kinematics helper function
*/
-void IKHelper(Person *p, float interp)
+void IKHelper(Person* p, float interp)
{
XYZ point, change, change2;
float heightleft, heightright;
if ((dead != 2 || skeleton.free != 2) && updatedelay <= 0) {
if (!isSleeping() && !isSitting()) {
// TODO: give these meaningful names
- const bool cond1 = (isIdle() || isCrouch() || isLanding() || isLandhard()
- || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim);
- const bool cond2 = (wasIdle() || wasCrouch() || wasLanding() || wasLandhard()
- || animCurrent == drawrightanim || animCurrent == drawleftanim || animCurrent == crouchdrawrightanim);
+ const bool cond1 = (isIdle() || isCrouch() || isLanding() || isLandhard() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim);
+ const bool cond2 = (wasIdle() || wasCrouch() || wasLanding() || wasLandhard() || animCurrent == drawrightanim || animCurrent == drawleftanim || animCurrent == crouchdrawrightanim);
if (onterrain && (cond1 && cond2) && !skeleton.free) {
IKHelper(this, 1);
if (!skeleton.free)
glRotatef(tilt, 0, 0, 1);
-
glTranslatef(mid.x, mid.y, mid.z);
skeleton.muscles[i].lastrotate1 = skeleton.muscles[i].rotate1;
if (playerdetail || skeleton.free == 3) {
for (unsigned j = 0; j < skeleton.muscles[i].vertices.size(); j++) {
- XYZ &v0 = skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]];
- XYZ &v1 = skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]];
+ XYZ& v0 = skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]];
+ XYZ& v1 = skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (p1 == abdomen || p2 == abdomen)
}
if (!playerdetail || skeleton.free == 3) {
for (unsigned j = 0; j < skeleton.muscles[i].verticeslow.size(); j++) {
- XYZ &v0 = skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]];
+ XYZ& v0 = skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (p1 == abdomen || p2 == abdomen)
glRotatef(-skeleton.muscles[i].lastrotate3, 0, 1, 0);
for (unsigned j = 0; j < skeleton.muscles[i].verticesclothes.size(); j++) {
- XYZ &v0 = skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]];
+ XYZ& v0 = skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]];
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
if (p1 == abdomen || p2 == abdomen)
glBegin(GL_POINTS);
if (playerdetail) {
for (int i = 0; i < skeleton.drawmodel.vertexNum; i++) {
- XYZ &v0 = skeleton.drawmodel.vertex[i];
+ XYZ& v0 = skeleton.drawmodel.vertex[i];
glVertex3f(v0.x, v0.y, v0.z);
}
}
if (playerdetail) {
for (unsigned int i = 0; i < skeleton.drawmodel.Triangles.size(); i++) {
- const XYZ &v0 = skeleton.drawmodel.getTriangleVertex(i, 0);
- const XYZ &v1 = skeleton.drawmodel.getTriangleVertex(i, 1);
- const XYZ &v2 = skeleton.drawmodel.getTriangleVertex(i, 2);
+ const XYZ& v0 = skeleton.drawmodel.getTriangleVertex(i, 0);
+ const XYZ& v1 = skeleton.drawmodel.getTriangleVertex(i, 1);
+ const XYZ& v2 = skeleton.drawmodel.getTriangleVertex(i, 2);
glVertex3f(v0.x, v0.y, v0.z);
glVertex3f(v1.x, v1.y, v1.z);
glVertex3f(v1.x, v1.y, v1.z);
}
}
-
if (Tutorial::active && id != 0) {
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
return 0;
}
-
/* FUNCTION?
*/
-int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
+int Person::SphereCheck(XYZ* p1, float radius, XYZ* p, XYZ* move, float* rotate, Model* model)
{
static float distance;
static float olddistance;
distance = abs((model->Triangles[j].facenormal.x * p1->x) + (model->Triangles[j].facenormal.y * p1->y) + (model->Triangles[j].facenormal.z * p1->z) - ((model->Triangles[j].facenormal.x * model->vertex[model->Triangles[j].vertex[0]].x) + (model->Triangles[j].facenormal.y * model->vertex[model->Triangles[j].vertex[0]].y) + (model->Triangles[j].facenormal.z * model->vertex[model->Triangles[j].vertex[0]].z)));
if (distance < radius) {
point = *p1 - model->Triangles[j].facenormal * distance;
- if (PointInTriangle( &point, model->Triangles[j].facenormal, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]]))
+ if (PointInTriangle(&point, model->Triangles[j].facenormal, &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]]))
intersecting = 1;
if (!intersecting)
intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
intersecting = 0;
start = *p1;
start.y -= radius / 4;
- XYZ &v0 = model->vertex[model->Triangles[j].vertex[0]];
- XYZ &v1 = model->vertex[model->Triangles[j].vertex[1]];
- XYZ &v2 = model->vertex[model->Triangles[j].vertex[2]];
- distance = abs((model->Triangles[j].facenormal.x * start.x)
- + (model->Triangles[j].facenormal.y * start.y)
- + (model->Triangles[j].facenormal.z * start.z)
- - ((model->Triangles[j].facenormal.x * v0.x)
- + (model->Triangles[j].facenormal.y * v0.y)
- + (model->Triangles[j].facenormal.z * v0.z)));
+ XYZ& v0 = model->vertex[model->Triangles[j].vertex[0]];
+ XYZ& v1 = model->vertex[model->Triangles[j].vertex[1]];
+ XYZ& v2 = model->vertex[model->Triangles[j].vertex[2]];
+ distance = abs((model->Triangles[j].facenormal.x * start.x) + (model->Triangles[j].facenormal.y * start.y) + (model->Triangles[j].facenormal.z * start.z) - ((model->Triangles[j].facenormal.x * v0.x) + (model->Triangles[j].facenormal.y * v0.y) + (model->Triangles[j].facenormal.z * v0.z)));
if (distance < radius * .5) {
point = start - model->Triangles[j].facenormal * distance;
- if (PointInTriangle( &point, model->Triangles[j].facenormal, &v0, &v1, &v2))
+ if (PointInTriangle(&point, model->Triangles[j].facenormal, &v0, &v1, &v2))
intersecting = 1;
if (!intersecting)
intersecting = sphere_line_intersection(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, p1->x, p1->y, p1->z, radius / 2);
connected = 0;
if (Game::numpathpointconnect[j])
for (int k = 0; k < Game::numpathpointconnect[j]; k++) {
- if (Game::pathpointconnect[j][k] == last)connected = 1;
+ if (Game::pathpointconnect[j][k] == last)
+ connected = 1;
}
if (!connected)
if (Game::numpathpointconnect[last])
for (int k = 0; k < Game::numpathpointconnect[last]; k++) {
- if (Game::pathpointconnect[last][k] == j)connected = 1;
+ if (Game::pathpointconnect[last][k] == j)
+ connected = 1;
}
if (connected)
if (closest == -1 || Random() % 2 == 0) {
float tintg = clothestintg[clothesId];
float tintb = clothestintb[clothesId];
- if (tintr > 1) tintr = 1;
- if (tintg > 1) tintg = 1;
- if (tintb > 1) tintb = 1;
+ if (tintr > 1)
+ tintr = 1;
+ if (tintg > 1)
+ tintg = 1;
+ if (tintb > 1)
+ tintb = 1;
- if (tintr < 0) tintr = 0;
- if (tintg < 0) tintg = 0;
- if (tintb < 0) tintb = 0;
+ if (tintr < 0)
+ tintr = 0;
+ if (tintg < 0)
+ tintg = 0;
+ if (tintb < 0)
+ tintb = 0;
int bytesPerPixel = texture.bpp / 8;
pause = 0;
if (distsqflat(&Person::players[0]->coords, &coords) < 30 &&
- Person::players[0]->coords.y > coords.y + 2 &&
- !Person::players[0]->onterrain)
+ Person::players[0]->coords.y > coords.y + 2 &&
+ !Person::players[0]->onterrain)
pause = 1;
//pathfinding
DistancePointLine(&finalfinaltarget, &Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]], &tempdist, &colpoint);
if (sq(tempdist) < closestdistance)
if (findDistance(&colpoint, &Game::pathpoint[j]) + findDistance(&colpoint, &Game::pathpoint[Game::pathpointconnect[j][k]]) <
- findDistance(&Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]]) + .1) {
+ findDistance(&Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]]) + .1) {
closestdistance = sq(tempdist);
closest = j;
finaltarget = colpoint;
}
}
finalpathfindpoint = closest;
-
}
if (targetpathfindpoint == -1) {
float closestdistance;
for (int j = 0; j < Game::numpathpoints; j++)
if (j != lastpathfindpoint)
for (int k = 0; k < Game::numpathpointconnect[j]; k++) {
- DistancePointLine(&coords, &Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]], &tempdist, &colpoint );
+ DistancePointLine(&coords, &Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]], &tempdist, &colpoint);
if (sq(tempdist) < closestdistance) {
if (findDistance(&colpoint, &Game::pathpoint[j]) + findDistance(&colpoint, &Game::pathpoint[Game::pathpointconnect[j][k]]) <
- findDistance(&Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]]) + .1) {
+ findDistance(&Game::pathpoint[j], &Game::pathpoint[Game::pathpointconnect[j][k]]) + .1) {
closestdistance = sq(tempdist);
closest = j;
}
} else {
for (int j = 0; j < Game::numpathpoints; j++)
if (j != lastpathfindpoint &&
- j != lastpathfindpoint2 &&
- j != lastpathfindpoint3 &&
- j != lastpathfindpoint4) {
+ j != lastpathfindpoint2 &&
+ j != lastpathfindpoint3 &&
+ j != lastpathfindpoint4) {
bool connected = 0;
if (Game::numpathpointconnect[j])
for (int k = 0; k < Game::numpathpointconnect[j]; k++)
lastpathfindpoint4 = lastpathfindpoint3;
targetpathfindpoint = -1;
}
- if ( distsqflat(&coords, &finalfinaltarget) <
- distsqflat(&coords, &finaltarget) ||
- distsqflat(&coords, &finaltarget) < .6 * sq(scale * 5) ||
- lastpathfindpoint == finalpathfindpoint) {
+ if (distsqflat(&coords, &finalfinaltarget) <
+ distsqflat(&coords, &finaltarget) ||
+ distsqflat(&coords, &finaltarget) < .6 * sq(scale * 5) ||
+ lastpathfindpoint == finalpathfindpoint) {
aitype = passivetype;
}
jumpkeydown = 1;
if ((!Tutorial::active || cananger) &&
- hostile &&
- !Person::players[0]->dead &&
- distsq(&coords, &Person::players[0]->coords) < 400 &&
- occluded < 25) {
+ hostile &&
+ !Person::players[0]->dead &&
+ distsq(&coords, &Person::players[0]->coords) < 400 &&
+ occluded < 25) {
if (distsq(&coords, &Person::players[0]->coords) < 12 &&
- Animation::animations[Person::players[0]->animTarget].height != lowheight &&
- !Game::editorenabled &&
- (Person::players[0]->coords.y < coords.y + 5 || Person::players[0]->onterrain))
+ Animation::animations[Person::players[0]->animTarget].height != lowheight &&
+ !Game::editorenabled &&
+ (Person::players[0]->coords.y < coords.y + 5 || Person::players[0]->onterrain))
aitype = attacktypecutoff;
if (distsq(&coords, &Person::players[0]->coords) < 30 &&
- Animation::animations[Person::players[0]->animTarget].height == highheight &&
- !Game::editorenabled)
+ Animation::animations[Person::players[0]->animTarget].height == highheight &&
+ !Game::editorenabled)
aitype = attacktypecutoff;
if (losupdatedelay < 0 && !Game::editorenabled && occluded < 2) {
if (distsq(&coords, &Person::players[j]->coords) < 400)
if (normaldotproduct(facing, Person::players[j]->coords - coords) > 0)
if (Person::players[j]->coords.y < coords.y + 5 || Person::players[j]->onterrain)
- if (!Person::players[j]->isWallJump() && -1 == Object::checkcollide(
- DoRotation(jointPos(head), 0, yaw, 0)
- *scale + coords,
- DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0)
- *Person::players[j]->scale + Person::players[j]->coords) ||
- (Person::players[j]->animTarget == hanganim &&
- normaldotproduct(Person::players[j]->facing, coords - Person::players[j]->coords) < 0)) {
+ if (!Person::players[j]->isWallJump() && -1 == Object::checkcollide(DoRotation(jointPos(head), 0, yaw, 0) * scale + coords, DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0) * Person::players[j]->scale + Person::players[j]->coords) ||
+ (Person::players[j]->animTarget == hanganim &&
+ normaldotproduct(Person::players[j]->facing, coords - Person::players[j]->coords) < 0)) {
aitype = searchtype;
lastchecktime = 12;
lastseen = Person::players[j]->coords;
waypoint++;
if (waypoint > numwaypoints - 1)
waypoint = 0;
-
}
}
if ((collided > .8 && jumppower >= 5))
jumpkeydown = 1;
-
//hearing sounds
if (!Game::editorenabled) {
if (howactive <= typesleeping)
if (numenvsounds > 0 && (!Tutorial::active || cananger) && hostile)
for (int j = 0; j < numenvsounds; j++) {
float vol = howactive == typesleeping ? envsoundvol[j] - 14 : envsoundvol[j];
- if (vol > 0 && distsq(&coords, &envsound[j]) <
- 2 * (vol + vol * (creature == rabbittype) * 3))
+ if (vol > 0 && distsq(&coords, &envsound[j]) < 2 * (vol + vol * (creature == rabbittype) * 3))
aitype = attacktypecutoff;
}
}
if (howactive < typesleeping &&
- ((!Tutorial::active || cananger) && hostile) &&
- !Person::players[0]->dead &&
- distsq(&coords, &Person::players[0]->coords) < 400 &&
- occluded < 25) {
+ ((!Tutorial::active || cananger) && hostile) &&
+ !Person::players[0]->dead &&
+ distsq(&coords, &Person::players[0]->coords) < 400 &&
+ occluded < 25) {
if (distsq(&coords, &Person::players[0]->coords) < 12 &&
- Animation::animations[Person::players[0]->animTarget].height != lowheight && !Game::editorenabled)
+ Animation::animations[Person::players[0]->animTarget].height != lowheight && !Game::editorenabled)
aitype = attacktypecutoff;
if (distsq(&coords, &Person::players[0]->coords) < 30 &&
- Animation::animations[Person::players[0]->animTarget].height == highheight && !Game::editorenabled)
+ Animation::animations[Person::players[0]->animTarget].height == highheight && !Game::editorenabled)
aitype = attacktypecutoff;
//wolf smell
if (distsq(&coords, &Person::players[j]->coords) < 400)
if (normaldotproduct(facing, Person::players[j]->coords - coords) > 0)
if ((-1 == Object::checkcollide(
- DoRotation(jointPos(head), 0, yaw, 0)*
- scale + coords,
- DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0)*
- Person::players[j]->scale + Person::players[j]->coords) &&
- !Person::players[j]->isWallJump()) ||
- (Person::players[j]->animTarget == hanganim &&
- normaldotproduct(Person::players[j]->facing, coords - Person::players[j]->coords) < 0)) {
+ DoRotation(jointPos(head), 0, yaw, 0) *
+ scale +
+ coords,
+ DoRotation(Person::players[j]->jointPos(head), 0, Person::players[j]->yaw, 0) *
+ Person::players[j]->scale +
+ Person::players[j]->coords) &&
+ !Person::players[j]->isWallJump()) ||
+ (Person::players[j]->animTarget == hanganim &&
+ normaldotproduct(Person::players[j]->facing, coords - Person::players[j]->coords) < 0)) {
lastseentime -= .2;
if (j == 0 && Animation::animations[Person::players[j]->animTarget].height == lowheight)
lastseentime -= .4;
}
if (!Person::players[0]->dead &&
- losupdatedelay < 0 &&
- !Game::editorenabled &&
- occluded < 2 &&
- ((!Tutorial::active || cananger) && hostile)) {
+ losupdatedelay < 0 &&
+ !Game::editorenabled &&
+ occluded < 2 &&
+ ((!Tutorial::active || cananger) && hostile)) {
losupdatedelay = .2;
if (distsq(&coords, &Person::players[0]->coords) < 4 && Animation::animations[animTarget].height != lowheight) {
aitype = attacktypecutoff;
if (distsq(&coords, &Person::players[0]->coords) < 400)
if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0)
if ((Object::checkcollide(
- DoRotation(jointPos(head), 0, yaw, 0)*
- scale + coords,
- DoRotation(Person::players[0]->jointPos(head), 0, Person::players[0]->yaw, 0)*
- Person::players[0]->scale + Person::players[0]->coords) == -1) ||
- (Person::players[0]->animTarget == hanganim && normaldotproduct(
- Person::players[0]->facing, coords - Person::players[0]->coords) < 0)) {
+ DoRotation(jointPos(head), 0, yaw, 0) *
+ scale +
+ coords,
+ DoRotation(Person::players[0]->jointPos(head), 0, Person::players[0]->yaw, 0) *
+ Person::players[0]->scale +
+ Person::players[0]->coords) == -1) ||
+ (Person::players[0]->animTarget == hanganim && normaldotproduct(Person::players[0]->facing, coords - Person::players[0]->coords) < 0)) {
/* //TODO: changed j to 0 on a whim, make sure this is correct
(Person::players[j]->animTarget==hanganim&&normaldotproduct(
Person::players[j]->facing,coords-Person::players[j]->coords)<0)
float closestdist = -1;
for (unsigned k = 0; k < Person::players.size(); k++) {
if ((k != id) && (k != 0) && !Person::players[k]->dead &&
- (Person::players[k]->howactive < typedead1) &&
- !Person::players[k]->skeleton.free &&
- (Person::players[k]->aitype == passivetype)) {
+ (Person::players[k]->howactive < typedead1) &&
+ !Person::players[k]->skeleton.free &&
+ (Person::players[k]->aitype == passivetype)) {
float distance = distsq(&coords, &Person::players[k]->coords);
if (closestdist == -1 || distance < closestdist) {
closestdist = distance;
lastseentime = 12;
}
-
lastchecktime = 12;
XYZ facing = coords;
//no available ally, run back to player
if (ally <= 0 ||
- Person::players[ally]->skeleton.free ||
- Person::players[ally]->aitype != passivetype ||
- lastseentime <= 0) {
+ Person::players[ally]->skeleton.free ||
+ Person::players[ally]->aitype != passivetype ||
+ lastseentime <= 0) {
aitype = searchtype;
lastseentime = 12;
}
if (!Person::players[0]->dead)
if (ally >= 0) {
if (weapons[ally].owner != -1 ||
- distsq(&coords, &weapons[ally].position) > 16) {
+ distsq(&coords, &weapons[ally].position) > 16) {
aitype = attacktypecutoff;
lastseentime = 1;
}
aiupdatedelay = .05;
forwardkeydown = 1;
-
if (avoidcollided > .8 && !jumpkeydown && collided < .8) {
if (!avoidsomething)
targetyaw += 90 * (whichdirection * 2 - 1);
throwkeydown = 1;
crouchkeydown = 0;
if (animTarget != crouchremoveknifeanim &&
- animTarget != removeknifeanim)
+ animTarget != removeknifeanim)
throwtogglekeydown = 0;
drawkeydown = 0;
}
//dodge or reverse rabbit kicks, knife throws, flips
if (damage < damagetolerance * 2 / 3)
if ((Person::players[0]->animTarget == rabbitkickanim ||
- Person::players[0]->animTarget == knifethrowanim ||
- (Person::players[0]->isFlip() &&
- normaldotproduct(Person::players[0]->facing, Person::players[0]->coords - coords) < 0)) &&
- !Person::players[0]->skeleton.free &&
- (aiupdatedelay < .1)) {
+ Person::players[0]->animTarget == knifethrowanim ||
+ (Person::players[0]->isFlip() &&
+ normaldotproduct(Person::players[0]->facing, Person::players[0]->coords - coords) < 0)) &&
+ !Person::players[0]->skeleton.free &&
+ (aiupdatedelay < .1)) {
attackkeydown = 0;
if (isIdle())
crouchkeydown = 1;
}
//get confused by flips
if (Person::players[0]->isFlip() &&
- !Person::players[0]->skeleton.free &&
- Person::players[0]->animTarget != walljumprightkickanim &&
- Person::players[0]->animTarget != walljumpleftkickanim) {
+ !Person::players[0]->skeleton.free &&
+ Person::players[0]->animTarget != walljumprightkickanim &&
+ Person::players[0]->animTarget != walljumpleftkickanim) {
if (distsq(&Person::players[0]->coords, &coords) < 25)
if ((1 - damage / damagetolerance) > .5)
stunned = 1;
if (damage < damagetolerance / 2)
if (Animation::animations[animTarget].height != highheight)
if (damage < damagetolerance * .5 &&
- ((Person::players[0]->animTarget == walljumprightkickanim ||
- Person::players[0]->animTarget == walljumpleftkickanim) &&
- ((aiupdatedelay < .15 &&
- difficulty == 2) ||
- (aiupdatedelay < .08 &&
- difficulty != 2)))) {
+ ((Person::players[0]->animTarget == walljumprightkickanim ||
+ Person::players[0]->animTarget == walljumpleftkickanim) &&
+ ((aiupdatedelay < .15 &&
+ difficulty == 2) ||
+ (aiupdatedelay < .08 &&
+ difficulty != 2)))) {
crouchkeydown = 1;
}
//walked off a ledge (?)
}
//lose sight of player in the air (?)
if (Person::players[0]->coords.y > coords.y + 5 &&
- Animation::animations[Person::players[0]->animTarget].height != highheight &&
- !Person::players[0]->onterrain) {
+ Animation::animations[Person::players[0]->animTarget].height != highheight &&
+ !Person::players[0]->onterrain) {
aitype = pathfindtype;
finalfinaltarget = waypoints[waypoint];
finalpathfindpoint = -1;
}
//it's time to think (?)
if (aiupdatedelay < 0 &&
- !Animation::animations[animTarget].attack &&
- animTarget != staggerbackhighanim &&
- animTarget != staggerbackhardanim &&
- animTarget != backhandspringanim &&
- animTarget != dodgebackanim) {
+ !Animation::animations[animTarget].attack &&
+ animTarget != staggerbackhighanim &&
+ animTarget != staggerbackhardanim &&
+ animTarget != backhandspringanim &&
+ animTarget != dodgebackanim) {
//draw weapon
if (weaponactive == -1 && num_weapons > 0)
drawkeydown = Random() % 2;
XYZ rotatetarget = Person::players[0]->coords + Person::players[0]->velocity;
XYZ targetpoint = Person::players[0]->coords;
if (distsq(&Person::players[0]->coords, &coords) <
- distsq(&rotatetarget, &coords))
+ distsq(&rotatetarget, &coords))
targetpoint += Person::players[0]->velocity *
findDistance(&Person::players[0]->coords, &coords) / findLength(&velocity);
targetyaw = roughDirectionTo(coords, targetpoint);
//TODO: wat
if (aitype != playercontrolled &&
- (isIdle() ||
- isCrouch() ||
- isRun())) {
+ (isIdle() ||
+ isCrouch() ||
+ isRun())) {
int target = -2;
for (unsigned j = 0; j < Person::players.size(); j++)
if (j != id && !Person::players[j]->skeleton.free &&
- Person::players[j]->hasvictim &&
- (Tutorial::active && reversaltrain ||
- Random() % 2 == 0 && difficulty == 2 ||
- Random() % 4 == 0 && difficulty == 1 ||
- Random() % 8 == 0 && difficulty == 0 ||
- Person::players[j]->lastattack2 == Person::players[j]->animTarget &&
+ Person::players[j]->hasvictim &&
+ (Tutorial::active && reversaltrain ||
+ Random() % 2 == 0 && difficulty == 2 ||
+ Random() % 4 == 0 && difficulty == 1 ||
+ Random() % 8 == 0 && difficulty == 0 ||
+ Person::players[j]->lastattack2 == Person::players[j]->animTarget &&
Person::players[j]->lastattack3 == Person::players[j]->animTarget &&
(Random() % 2 == 0 || difficulty == 2) ||
- (isIdle() || isRun()) &&
+ (isIdle() || isRun()) &&
Person::players[j]->weaponactive != -1 ||
- Person::players[j]->animTarget == swordslashanim &&
+ Person::players[j]->animTarget == swordslashanim &&
weaponactive != -1 ||
- Person::players[j]->animTarget == staffhitanim ||
- Person::players[j]->animTarget == staffspinhitanim))
+ Person::players[j]->animTarget == staffhitanim ||
+ Person::players[j]->animTarget == staffspinhitanim))
if (distsq(&Person::players[j]->coords, &Person::players[j]->victim->coords) < 4 &&
- Person::players[j]->victim == Person::players[id] &&
- (Person::players[j]->animTarget == sweepanim ||
- Person::players[j]->animTarget == spinkickanim ||
- Person::players[j]->animTarget == staffhitanim ||
- Person::players[j]->animTarget == staffspinhitanim ||
- Person::players[j]->animTarget == winduppunchanim ||
- Person::players[j]->animTarget == upunchanim ||
- Person::players[j]->animTarget == wolfslapanim ||
- Person::players[j]->animTarget == knifeslashstartanim ||
- Person::players[j]->animTarget == swordslashanim &&
+ Person::players[j]->victim == Person::players[id] &&
+ (Person::players[j]->animTarget == sweepanim ||
+ Person::players[j]->animTarget == spinkickanim ||
+ Person::players[j]->animTarget == staffhitanim ||
+ Person::players[j]->animTarget == staffspinhitanim ||
+ Person::players[j]->animTarget == winduppunchanim ||
+ Person::players[j]->animTarget == upunchanim ||
+ Person::players[j]->animTarget == wolfslapanim ||
+ Person::players[j]->animTarget == knifeslashstartanim ||
+ Person::players[j]->animTarget == swordslashanim &&
(distsq(&Person::players[j]->coords, &coords) < 2 ||
weaponactive != -1))) {
if (target >= 0) {
if (collided < 1)
jumpkeydown = 0;
if (collided > .8 && jumppower >= 5 ||
- distsq(&coords, &Person::players[0]->coords) > 400 &&
+ distsq(&coords, &Person::players[0]->coords) > 400 &&
onterrain &&
creature == rabbittype)
jumpkeydown = 1;
if (normaldotproduct(facing, Person::players[0]->coords - coords) > 0)
Person::players[0]->jumpkeydown = 0;
if (Person::players[0]->animTarget == jumpdownanim &&
- distsq(&Person::players[0]->coords, &coords) < 40)
+ distsq(&Person::players[0]->coords, &coords) < 40)
crouchkeydown = 1;
if (jumpkeydown)
attackkeydown = 0;
if (!canattack)
attackkeydown = 0;
-
XYZ facing = coords;
XYZ flatfacing = Person::players[0]->coords;
facing.y += jointPos(head).y * scale;
if (!pause)
lastseentime -= .2;
if (lastseentime <= 0 &&
- (creature != wolftype ||
- weaponstuck == -1)) {
+ (creature != wolftype ||
+ weaponstuck == -1)) {
aitype = searchtype;
lastchecktime = 12;
lastseen = Person::players[0]->coords;
}
}
if (Animation::animations[Person::players[0]->animTarget].height == highheight &&
- (aitype == attacktypecutoff ||
- aitype == searchtype))
+ (aitype == attacktypecutoff ||
+ aitype == searchtype))
if (Person::players[0]->coords.y > terrain.getHeight(Person::players[0]->coords.x, Person::players[0]->coords.z) + 10) {
XYZ test = Person::players[0]->coords;
test.y -= 40;
}
//stunned
if (aitype == passivetype && !(numwaypoints > 1) ||
- stunned > 0 ||
- pause && damage > superpermanentdamage) {
+ stunned > 0 ||
+ pause && damage > superpermanentdamage) {
if (pause)
lastseentime = 1;
targetyaw = yaw;
throwkeydown = 0;
}
-
XYZ facing;
facing = 0;
facing.z = -1;
#include "Objects/Weapons.hpp"
#include "Animation/Animation.hpp"
-#include "Audio/openal_wrapper.hpp"
#include "Audio/Sounds.hpp"
+#include "Audio/openal_wrapper.hpp"
#include "Game.hpp"
#include "Level/Awards.hpp"
#include "Tutorial.hpp"
Model Weapon::staffmodel;
Texture Weapon::stafftextureptr;
-Weapon::Weapon(int t, int o) : owner(o)
+Weapon::Weapon(int t, int o)
+ : owner(o)
{
setType(t);
bloody = 0;
footvel = 0;
footpoint = DoRotation((Person::players[j]->jointPos(abdomen) + Person::players[j]->jointPos(neck)) / 2, 0, Person::players[j]->yaw, 0) * Person::players[j]->scale + Person::players[j]->coords;
if (owner == -1 && distsqflat(&position, &Person::players[j]->coords) < 1.5 &&
- distsq(&position, &Person::players[j]->coords) < 4 && Person::players[j]->weaponstuck == -1 &&
- !Person::players[j]->skeleton.free && (int(j) != oldowner)) {
+ distsq(&position, &Person::players[j]->coords) < 4 && Person::players[j]->weaponstuck == -1 &&
+ !Person::players[j]->skeleton.free && (int(j) != oldowner)) {
if ((Person::players[j]->aitype != attacktypecutoff || abs(Random() % 6) == 0 || (Person::players[j]->animTarget != backhandspringanim && Person::players[j]->animTarget != rollanim && Person::players[j]->animTarget != flipanim && Random() % 2 == 0)) && !missed) {
- if ( (Person::players[j]->creature == wolftype && Random() % 3 != 0 && Person::players[j]->weaponactive == -1 && (Person::players[j]->isIdle() || Person::players[j]->isRun() || Person::players[j]->animTarget == walkanim)) ||
- (Person::players[j]->creature == rabbittype && Random() % 2 == 0 && Person::players[j]->aitype == attacktypecutoff && Person::players[j]->weaponactive == -1)) {
+ if ((Person::players[j]->creature == wolftype && Random() % 3 != 0 && Person::players[j]->weaponactive == -1 && (Person::players[j]->isIdle() || Person::players[j]->isRun() || Person::players[j]->animTarget == walkanim)) ||
+ (Person::players[j]->creature == rabbittype && Random() % 2 == 0 && Person::players[j]->aitype == attacktypecutoff && Person::players[j]->weaponactive == -1)) {
emit_sound_at(knifedrawsound, Person::players[j]->coords, 128.);
Person::players[j]->animTarget = removeknifeanim;
if (temppoint1.x > temppoint2.x)
rotation1 = 360 - rotation1;
}
-
}
//Sword physics
position = newpoint1;
tippoint = newpoint2;
-
//Object collisions
whichpatchx = (position.x) / (terrain.size / subdivision * terrain.scale);
whichpatchz = (position.z) / (terrain.size / subdivision * terrain.scale);
point[0] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 0), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
point[1] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 1), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
point[2] = DoRotation(Object::objects[k]->model.getTriangleVertex(whichhit, 2), 0, Object::objects[k]->yaw, 0) + Object::objects[k]->position;
- if (DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance, &colpoint )) {
+ if (DistancePointLine(&closestswordpoint, &point[0], &point[1], &distance, &colpoint)) {
if (distance < closestdistance || closestdistance == -1) {
closestpoint = colpoint;
closestdistance = distance;
}
}
- if (DistancePointLine(&closestswordpoint, &point[1], &point[2], &distance, &colpoint )) {
+ if (DistancePointLine(&closestswordpoint, &point[1], &point[2], &distance, &colpoint)) {
if (distance < closestdistance || closestdistance == -1) {
closestpoint = colpoint;
closestdistance = distance;
}
}
- if (DistancePointLine(&closestswordpoint, &point[2], &point[0], &distance, &colpoint )) {
+ if (DistancePointLine(&closestswordpoint, &point[2], &point[0], &distance, &colpoint)) {
if (distance < closestdistance || closestdistance == -1) {
closestpoint = colpoint;
closestdistance = distance;
}
}
if (closestdistance != -1 && isnormal(closestdistance)) {
- if (DistancePointLine(&closestpoint, &position, &tippoint, &distance, &colpoint )) {
+ if (DistancePointLine(&closestpoint, &position, &tippoint, &distance, &colpoint)) {
closestswordpoint = colpoint;
velocity += (closestpoint - closestswordpoint);
tipvelocity += (closestpoint - closestswordpoint);
whichsound = footstepsound + abs(Random() % 2);
}
emit_sound_at(whichsound, position,
- findLengthfast(&bounceness)
- * (terrain.getOpacity(position.x, position.z) > .2 ? 128. : 32.));
+ findLengthfast(&bounceness) * (terrain.getOpacity(position.x, position.z) > .2 ? 128. : 32.));
if (terrain.getOpacity(position.x, position.z) < .2) {
XYZ terrainlight;
whichsound = footstepsound + abs(Random() % 2);
}
emit_sound_at(whichsound, tippoint,
- findLengthfast(&bounceness)
- * (terrain.getOpacity(tippoint.x, tippoint.z) > .2 ? 128. : 32.));
+ findLengthfast(&bounceness) * (terrain.getOpacity(tippoint.x, tippoint.z) > .2 ? 128. : 32.));
if (terrain.getOpacity(tippoint.x, tippoint.z) < .2) {
XYZ terrainlight;
whichsound = footstepsound + abs(Random() % 2);
}
emit_sound_at(whichsound, mid,
- findLengthfast(&bounceness)
- * (terrain.getOpacity(position.x, position.z) > .2
- ? 128.
- : 32.));
+ findLengthfast(&bounceness) * (terrain.getOpacity(position.x, position.z) > .2
+ ? 128.
+ : 32.));
}
position += (mid - oldmid) * 20;
}
whichsound = footstepsound + abs(Random() % 2);
}
emit_sound_at(whichsound, mid,
- findLengthfast(&bounceness)
- * (terrain.getOpacity(position.x, position.z) > .2
- ? 128.
- : 32.));
+ findLengthfast(&bounceness) * (terrain.getOpacity(position.x, position.z) > .2
+ ? 128.
+ : 32.));
}
tippoint += (mid - oldmid) * 20;
}
static GLfloat M[16];
if ((frustum.SphereInFrustum(position.x, position.y, position.z, 1) &&
- distsq(&viewer, &position) < viewdistance * viewdistance)) {
+ distsq(&viewer, &position) < viewdistance * viewdistance)) {
bool draw = false;
if (owner == -1) {
draw = true;
Person::players[owner]->animTarget == swordgroundstabanim ||
Person::players[owner]->animTarget == knifethrowanim) &&
Person::players[owner]->animTarget == lastdrawnanim &&
- !Person::players[owner]->skeleton.free
- ) {
+ !Person::players[owner]->skeleton.free) {
drawhowmany = 10;
} else {
drawhowmany = 1;
glEnable(GL_LIGHTING);
switch (type) {
- case knife:
- if (!bloody || !bloodtoggle)
- throwingknifemodel.drawdifftex(knifetextureptr);
- if (bloodtoggle) {
- if (bloody == 1)
- throwingknifemodel.drawdifftex(lightbloodknifetextureptr);
- if (bloody == 2)
- throwingknifemodel.drawdifftex(bloodknifetextureptr);
- }
- break;
- case sword:
- if (!bloody || !bloodtoggle)
- swordmodel.drawdifftex(swordtextureptr);
- if (bloodtoggle) {
- if (bloody == 1)
- swordmodel.drawdifftex(lightbloodswordtextureptr);
- if (bloody == 2)
- swordmodel.drawdifftex(bloodswordtextureptr);
- }
- break;
- case staff:
- staffmodel.drawdifftex(stafftextureptr);
- break;
+ case knife:
+ if (!bloody || !bloodtoggle)
+ throwingknifemodel.drawdifftex(knifetextureptr);
+ if (bloodtoggle) {
+ if (bloody == 1)
+ throwingknifemodel.drawdifftex(lightbloodknifetextureptr);
+ if (bloody == 2)
+ throwingknifemodel.drawdifftex(bloodknifetextureptr);
+ }
+ break;
+ case sword:
+ if (!bloody || !bloodtoggle)
+ swordmodel.drawdifftex(swordtextureptr);
+ if (bloodtoggle) {
+ if (bloody == 1)
+ swordmodel.drawdifftex(lightbloodswordtextureptr);
+ if (bloody == 2)
+ swordmodel.drawdifftex(bloodswordtextureptr);
+ }
+ break;
+ case staff:
+ staffmodel.drawdifftex(stafftextureptr);
+ break;
}
glPopMatrix();
*/
#include "Tutorial.hpp"
-#include "Game.hpp"
#include "Audio/Sounds.hpp"
#include "Audio/openal_wrapper.hpp"
+#include "Game.hpp"
#include "Level/Awards.hpp"
#include "Objects/Person.hpp"
#include "Utils/Input.hpp"
Sprite::MakeSprite(breathsprite, temp, temp2, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
}
}
- }
- break;
+ } break;
case 15:
case 16:
case 17:
w.physics = 1;
weapons.push_back(w);
- }
- break;
+ } break;
case 40:
case 41:
case 43:
Person::players[1]->num_weapons = 1;
Person::players[1]->weaponids[0] = 0;
- }
- break;
+ } break;
case 48:
canattack = 0;
cananger = 0;
Person::players[1]->weaponactive = -1;
weapons.clear();
- }
- break;
+ } break;
case 51:
maxtime = 80000;
break;
switch (stage) {
case 0:
default:
- break;
+ break;
case 1:
string = "Welcome to the Lugaru training level!";
break;
break;
case 4:
string = std::string("Try using the ") +
- Input::keyToChar(Game::forwardkey) + ", " +
- Input::keyToChar(Game::leftkey) + ", " +
- Input::keyToChar(Game::backkey) + " and " +
- Input::keyToChar(Game::rightkey) + " keys to move around.";
+ Input::keyToChar(Game::forwardkey) + ", " +
+ Input::keyToChar(Game::leftkey) + ", " +
+ Input::keyToChar(Game::backkey) + " and " +
+ Input::keyToChar(Game::rightkey) + " keys to move around.";
string2 = "All movement is relative to the camera.";
break;
case 5:
opacity = 0;
}
- Game::text->glPrintOutlined(1, 1, 1, opacity, screenwidth / 2 - 7.6 * string.size()*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
- Game::text->glPrintOutlined(1, 1, 1, opacity, screenwidth / 2 - 7.6 * string2.size()*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
- Game::text->glPrintOutlined(1, 1, 1, opacity, screenwidth / 2 - 7.6 * string3.size()*screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 40 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
+ Game::text->glPrintOutlined(1, 1, 1, opacity, screenwidth / 2 - 7.6 * string.size() * screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
+ Game::text->glPrintOutlined(1, 1, 1, opacity, screenwidth / 2 - 7.6 * string2.size() * screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 20 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
+ Game::text->glPrintOutlined(1, 1, 1, opacity, screenwidth / 2 - 7.6 * string3.size() * screenwidth / 1024, screenheight / 16 + screenheight * 4 / 5 - 40 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight);
string = "Press 'tab' to skip to the next item.";
string2 = "Press escape at any time to";
string3 = "pause or exit the tutorial.";
- Game::text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string.size()*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
- Game::text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string2.size()*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10 - 20 * .8 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
- Game::text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string3.size()*screenwidth / 1024 * .8, 0 + screenheight * 1 / 10 - 40 * .8 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
+ Game::text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string.size() * screenwidth / 1024 * .8, 0 + screenheight * 1 / 10, string, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
+ Game::text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string2.size() * screenwidth / 1024 * .8, 0 + screenheight * 1 / 10 - 20 * .8 * screenwidth / 1024, string2, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
+ Game::text->glPrintOutlined(0.5, 0.5, 0.5, 1, screenwidth / 2 - 7.6 * string3.size() * screenwidth / 1024 * .8, 0 + screenheight * 1 / 10 - 40 * .8 * screenwidth / 1024, string3, 1, 1.5 * screenwidth / 1024 * .8, screenwidth, screenheight);
}
void Tutorial::DoStuff(float multiplier)
oldtemp2 = temp2;
if (stage >= 51) {
if (distsq(&temp, &Person::players[0]->coords) >= distsq(&temp, &temp2) - 1 || distsq(&temp3, &Person::players[0]->coords) < 4) {
- OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
+ OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu...
OPENAL_SetFrequency(OPENAL_ALL);
emit_stream_np(stream_menutheme);
vector<Account> Account::accounts;
int Account::i_active = -1;
-Account::Account(const string& name) : name(name), campaignProgress()
+Account::Account(const string& name)
+ : name(name)
+ , campaignProgress()
{
difficulty = 0;
progress = 0;
setCurrentCampaign("main");
}
-Account::Account(FILE* tfile) : Account("")
+Account::Account(FILE* tfile)
+ : Account("")
{
funpackf(tfile, "Bi", &difficulty);
funpackf(tfile, "Bi", &progress);
string campaignName = "";
int t;
char c;
- funpackf(tfile, "Bi", &t);
+ funpackf(tfile, "Bi", &t);
for (int j = 0; j < t; j++) {
- funpackf(tfile, "Bb", &c);
+ funpackf(tfile, "Bb", &c);
campaignName.append(1, c);
}
funpackf(tfile, "Bf", &(campaignProgress[campaignName].time));
currentCampaign = "";
int t;
char c;
- funpackf(tfile, "Bi", &t);
+ funpackf(tfile, "Bi", &t);
for (int i = 0; i < t; i++) {
- funpackf(tfile, "Bb", &c);
+ funpackf(tfile, "Bb", &c);
currentCampaign.append(1, c);
}
funpackf(tfile, "Bf", &(fasttime[i]));
}
for (int i = 0; i < 60; i++) {
- funpackf(tfile, "Bb", &(unlocked[i]));
+ funpackf(tfile, "Bb", &(unlocked[i]));
}
int temp;
char ctemp;
- funpackf(tfile, "Bi", &temp);
+ funpackf(tfile, "Bi", &temp);
for (int i = 0; i < temp; i++) {
- funpackf(tfile, "Bb", &ctemp);
+ funpackf(tfile, "Bb", &ctemp);
name.append(1, ctemp);
}
if (name.empty()) {
map<string, CampaignProgress>::const_iterator it;
for (it = campaignProgress.begin(); it != campaignProgress.end(); ++it) {
- fpackf(tfile, "Bi", it->first.size());
+ fpackf(tfile, "Bi", it->first.size());
for (unsigned j = 0; j < it->first.size(); j++) {
- fpackf(tfile, "Bb", it->first[j]);
+ fpackf(tfile, "Bb", it->first[j]);
}
fpackf(tfile, "Bf", it->second.time);
fpackf(tfile, "Bf", it->second.score);
fpackf(tfile, "Bf", fasttime[j]);
}
for (unsigned j = 0; j < 60; j++) {
- fpackf(tfile, "Bb", unlocked[j]);
+ fpackf(tfile, "Bb", unlocked[j]);
}
- fpackf(tfile, "Bi", name.size());
+ fpackf(tfile, "Bi", name.size());
for (unsigned j = 0; j < name.size(); j++) {
- fpackf(tfile, "Bb", name[j]);
+ fpackf(tfile, "Bb", name[j]);
}
}
void Account::loadFile(string filename)
{
- FILE *tfile;
+ FILE* tfile;
int numaccounts;
int iactive;
errno = 0;
- tfile = fopen(filename.c_str(), "rb" );
+ tfile = fopen(filename.c_str(), "rb");
if (tfile) {
funpackf(tfile, "Bi", &numaccounts);
void Account::saveFile(string filename)
{
- FILE *tfile;
+ FILE* tfile;
errno = 0;
- tfile = fopen(filename.c_str(), "wb" );
+ tfile = fopen(filename.c_str(), "wb");
if (tfile) {
fpackf(tfile, "Bi", getNbAccounts());
fpackf(tfile, "Bi", i_active);
{
errno = 0;
ifstream ipstream(Folders::getConfigFilePath(), std::ios::in);
- if ( ipstream.fail() ) {
+ if (ipstream.fail()) {
perror(("Couldn't read config file " + Folders::getConfigFilePath()).c_str());
return false;
}
printf("Loading config\n");
while (!ipstream.eof()) {
- ipstream.getline( setting, sizeof(setting) );
+ ipstream.getline(setting, sizeof(setting));
// skip blank lines
// assume lines starting with spaces are all blank
- if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
+ if (strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t')
continue;
//~ printf("setting : %s\n",setting);
- if ( ipstream.eof() || ipstream.fail() ) {
+ if (ipstream.eof() || ipstream.fail()) {
fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting);
ipstream.close();
return false;
}
-
- if ( !strncmp(setting, "Screenwidth", 11) ) {
+ if (!strncmp(setting, "Screenwidth", 11)) {
ipstream >> kContextWidth;
- } else if ( !strncmp(setting, "Screenheight", 12) ) {
+ } else if (!strncmp(setting, "Screenheight", 12)) {
ipstream >> kContextHeight;
- } else if ( !strncmp(setting, "Fullscreen", 10) ) {
+ } else if (!strncmp(setting, "Fullscreen", 10)) {
ipstream >> fullscreen;
- } else if ( !strncmp(setting, "Mouse sensitivity", 17) ) {
+ } else if (!strncmp(setting, "Mouse sensitivity", 17)) {
ipstream >> usermousesensitivity;
- } else if ( !strncmp(setting, "Blur", 4) ) {
+ } else if (!strncmp(setting, "Blur", 4)) {
ipstream >> ismotionblur;
- } else if ( !strncmp(setting, "Overall Detail", 14) ) {
+ } else if (!strncmp(setting, "Overall Detail", 14)) {
ipstream >> detail;
- } else if ( !strncmp(setting, "Floating jump", 13) ) {
+ } else if (!strncmp(setting, "Floating jump", 13)) {
ipstream >> floatjump;
- } else if ( !strncmp(setting, "Mouse jump", 10) ) {
+ } else if (!strncmp(setting, "Mouse jump", 10)) {
ipstream >> mousejump;
- } else if ( !strncmp(setting, "Ambient sound", 13) ) {
+ } else if (!strncmp(setting, "Ambient sound", 13)) {
ipstream >> ambientsound;
- } else if ( !strncmp(setting, "Blood", 5) ) {
+ } else if (!strncmp(setting, "Blood", 5)) {
ipstream >> bloodtoggle;
- } else if ( !strncmp(setting, "Auto slomo", 10) ) {
+ } else if (!strncmp(setting, "Auto slomo", 10)) {
ipstream >> autoslomo;
- } else if ( !strncmp(setting, "Foliage", 7) ) {
+ } else if (!strncmp(setting, "Foliage", 7)) {
ipstream >> foliage;
- } else if ( !strncmp(setting, "Music", 5) ) {
+ } else if (!strncmp(setting, "Music", 5)) {
ipstream >> musictoggle;
- } else if ( !strncmp(setting, "Trilinear", 9) ) {
+ } else if (!strncmp(setting, "Trilinear", 9)) {
ipstream >> trilinear;
- } else if ( !strncmp(setting, "Decals", 6) ) {
+ } else if (!strncmp(setting, "Decals", 6)) {
ipstream >> decalstoggle;
- } else if ( !strncmp(setting, "Invert mouse", 12) ) {
+ } else if (!strncmp(setting, "Invert mouse", 12)) {
ipstream >> invertmouse;
- } else if ( !strncmp(setting, "Gamespeed", 9) ) {
+ } else if (!strncmp(setting, "Gamespeed", 9)) {
ipstream >> gamespeed;
oldgamespeed = gamespeed;
if (oldgamespeed == 0) {
gamespeed = 1;
oldgamespeed = 1;
}
- } else if ( !strncmp(setting, "Damage effects", 14) ) {
+ } else if (!strncmp(setting, "Damage effects", 14)) {
ipstream >> damageeffects;
- } else if ( !strncmp(setting, "Text", 4) ) {
+ } else if (!strncmp(setting, "Text", 4)) {
ipstream >> texttoggle;
- } else if ( !strncmp(setting, "Devtools", 8) ) {
+ } else if (!strncmp(setting, "Devtools", 8)) {
ipstream >> devtools;
- } else if ( !strncmp(setting, "Show Points", 11) ) {
+ } else if (!strncmp(setting, "Show Points", 11)) {
ipstream >> showpoints;
- } else if ( !strncmp(setting, "Always Blur", 11) ) {
+ } else if (!strncmp(setting, "Always Blur", 11)) {
ipstream >> alwaysblur;
- } else if ( !strncmp(setting, "Immediate mode ", 15) ) {
+ } else if (!strncmp(setting, "Immediate mode ", 15)) {
ipstream >> immediate;
- } else if ( !strncmp(setting, "Velocity blur", 13) ) {
+ } else if (!strncmp(setting, "Velocity blur", 13)) {
ipstream >> velocityblur;
- } else if ( !strncmp(setting, "Volume", 6) ) {
+ } else if (!strncmp(setting, "Volume", 6)) {
ipstream >> volume;
- } else if ( !strncmp(setting, "Forward key", 11) ) {
+ } else if (!strncmp(setting, "Forward key", 11)) {
ipstream >> forwardkey;
- } else if ( !strncmp(setting, "Back key", 8) ) {
+ } else if (!strncmp(setting, "Back key", 8)) {
ipstream >> backkey;
- } else if ( !strncmp(setting, "Left key", 8) ) {
+ } else if (!strncmp(setting, "Left key", 8)) {
ipstream >> leftkey;
- } else if ( !strncmp(setting, "Right key", 9) ) {
+ } else if (!strncmp(setting, "Right key", 9)) {
ipstream >> rightkey;
- } else if ( !strncmp(setting, "Jump key", 8) ) {
+ } else if (!strncmp(setting, "Jump key", 8)) {
ipstream >> jumpkey;
- } else if ( !strncmp(setting, "Crouch key", 10) ) {
+ } else if (!strncmp(setting, "Crouch key", 10)) {
ipstream >> crouchkey;
- } else if ( !strncmp(setting, "Draw key", 8) ) {
+ } else if (!strncmp(setting, "Draw key", 8)) {
ipstream >> drawkey;
- } else if ( !strncmp(setting, "Throw key", 9) ) {
+ } else if (!strncmp(setting, "Throw key", 9)) {
ipstream >> throwkey;
- } else if ( !strncmp(setting, "Attack key", 10) ) {
+ } else if (!strncmp(setting, "Attack key", 10)) {
ipstream >> attackkey;
- } else if ( !strncmp(setting, "Console key", 11) ) {
+ } else if (!strncmp(setting, "Console key", 11)) {
ipstream >> consolekey;
- } else if ( !strncmp(setting, "Damage bar", 10) ) {
+ } else if (!strncmp(setting, "Damage bar", 10)) {
ipstream >> showdamagebar;
- } else if ( !strncmp(setting, "StereoMode", 10) ) {
+ } else if (!strncmp(setting, "StereoMode", 10)) {
int i;
ipstream >> i;
stereomode = (StereoMode)i;
- } else if ( !strncmp(setting, "StereoSeparation", 16) ) {
+ } else if (!strncmp(setting, "StereoSeparation", 16)) {
ipstream >> stereoseparation;
- } else if ( !strncmp(setting, "StereoReverse", 13) ) {
+ } else if (!strncmp(setting, "StereoReverse", 13)) {
ipstream >> stereoreverse;
} else {
ipstream >> string;
fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);
}
- if ( ipstream.fail() ) {
+ if (ipstream.fail()) {
fprintf(stderr, "Error reading config file: EOF reached when trying to read value for setting '%s'.\n", setting);
ipstream.close();
return false;
}
- if ( ipstream.bad() ) {
+ if (ipstream.bad()) {
fprintf(stderr, "Error reading config file: Failed to read value for setting '%s'.\n", setting);
ipstream.close();
return false;
#include "Folders.hpp"
-#include <cstring>
-#include <cstdlib>
#include <cerrno>
+#include <cstdlib>
+#include <cstring>
#include <unistd.h>
#if PLATFORM_UNIX
#ifdef _WIN32
char path[MAX_PATH];
// %APPDATA% (%USERPROFILE%\Application Data)
- if(SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_APPDATA, nullptr, 0, path))) {
+ if (SUCCEEDED(SHGetFolderPathA(nullptr, CSIDL_APPDATA, nullptr, 0, path))) {
userDataPath = std::string(path) + "/Lugaru/";
} else {
return dataDir;
#if PLATFORM_LINUX
/* Generic code for XDG ENVVAR test and fallback */
-std::string Folders::getGenericDirectory(const char* ENVVAR, const std::string& fallback) {
+std::string Folders::getGenericDirectory(const char* ENVVAR, const std::string& fallback)
+{
const char* path = getenv(ENVVAR);
std::string ret;
if ((path != NULL) && (strlen(path) != 0)) {
#if PLATFORM_UNIX
const char* Folders::getHomeDirectory()
{
- const char *homedir = getenv("HOME");
+ const char* homedir = getenv("HOME");
if (homedir != NULL)
return homedir;
- struct passwd *pw = getpwuid(getuid());
+ struct passwd* pw = getpwuid(getuid());
if (pw != NULL)
return pw->pw_dir;
return NULL;
}
#endif
-bool Folders::makeDirectory(const std::string& path) {
+bool Folders::makeDirectory(const std::string& path)
+{
#ifdef _WIN32
int status = CreateDirectory(path.c_str(), NULL);
return ((status != 0) || (GetLastError() == ERROR_ALREADY_EXISTS));
extern int kContextWidth;
extern int kContextHeight;
-static bool load_png(const char * fname, ImageRec & tex);
-static bool load_jpg(const char * fname, ImageRec & tex);
-static bool save_screenshot_png(const char * fname);
+static bool load_png(const char* fname, ImageRec& tex);
+static bool load_jpg(const char* fname, ImageRec& tex);
+static bool save_screenshot_png(const char* fname);
ImageRec::ImageRec()
{
- data = ( GLubyte* )malloc( 1024 * 1024 * 4 );
+ data = (GLubyte*)malloc(1024 * 1024 * 4);
}
ImageRec::~ImageRec()
data = NULL;
}
-bool load_image(const char *file_name, ImageRec &tex)
+bool load_image(const char* file_name, ImageRec& tex)
{
Game::LoadingScreen();
- if ( tex.data == NULL ) {
+ if (tex.data == NULL) {
return false;
}
- const char *ptr = strrchr((char *)file_name, '.');
+ const char* ptr = strrchr((char*)file_name, '.');
if (ptr) {
if (strcasecmp(ptr + 1, "png") == 0) {
return load_png(file_name, tex);
return false;
}
-bool save_screenshot(const char *file_name)
+bool save_screenshot(const char* file_name)
{
- const char *ptr = strrchr((char *)file_name, '.');
+ const char* ptr = strrchr((char*)file_name, '.');
if (ptr) {
if (strcasecmp(ptr + 1, "png") == 0) {
return save_screenshot_png((Folders::getScreenshotDir() + '/' + file_name).c_str());
return false;
}
-struct my_error_mgr {
+struct my_error_mgr
+{
struct jpeg_error_mgr pub; /* "public" fields */
- jmp_buf setjmp_buffer; /* for return to caller */
+ jmp_buf setjmp_buffer; /* for return to caller */
};
-typedef struct my_error_mgr * my_error_ptr;
+typedef struct my_error_mgr* my_error_ptr;
static void my_error_exit(j_common_ptr cinfo)
{
- struct my_error_mgr *err = (struct my_error_mgr *)cinfo->err;
+ struct my_error_mgr* err = (struct my_error_mgr*)cinfo->err;
longjmp(err->setjmp_buffer, 1);
}
/* stolen from public domain example.c code in libjpg distribution. */
-static bool load_jpg(const char *file_name, ImageRec &tex)
+static bool load_jpg(const char* file_name, ImageRec& tex)
{
struct jpeg_decompress_struct cinfo;
struct my_error_mgr jerr;
JSAMPROW buffer[1]; /* Output row buffer */
- int row_stride; /* physical row width in output buffer */
+ int row_stride; /* physical row width in output buffer */
errno = 0;
- FILE *infile = fopen(file_name, "rb");
+ FILE* infile = fopen(file_name, "rb");
if (infile == NULL) {
perror((std::string("Couldn't open file ") + file_name).c_str());
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile);
- (void) jpeg_read_header(&cinfo, TRUE);
+ (void)jpeg_read_header(&cinfo, TRUE);
cinfo.out_color_space = JCS_RGB;
cinfo.quantize_colors = 0;
- (void) jpeg_calc_output_dimensions(&cinfo);
- (void) jpeg_start_decompress(&cinfo);
+ (void)jpeg_calc_output_dimensions(&cinfo);
+ (void)jpeg_start_decompress(&cinfo);
row_stride = cinfo.output_width * cinfo.output_components;
tex.sizeX = cinfo.output_width;
tex.bpp = 24;
while (cinfo.output_scanline < cinfo.output_height) {
- buffer[0] = (JSAMPROW)(char *)tex.data +
+ buffer[0] = (JSAMPROW)(char*)tex.data +
((cinfo.output_height - 1) - cinfo.output_scanline) * row_stride;
- (void) jpeg_read_scanlines(&cinfo, buffer, 1);
+ (void)jpeg_read_scanlines(&cinfo, buffer, 1);
}
- (void) jpeg_finish_decompress(&cinfo);
+ (void)jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);
fclose(infile);
}
/* stolen from public domain example.c code in libpng distribution. */
-static bool load_png(const char *file_name, ImageRec &tex)
+static bool load_png(const char* file_name, ImageRec& tex)
{
bool hasalpha = false;
png_structp png_ptr = NULL;
png_uint_32 width, height;
int bit_depth, color_type, interlace_type;
bool retval = false;
- png_byte **row_pointers = NULL;
+ png_byte** row_pointers = NULL;
errno = 0;
- FILE *fp = fopen(file_name, "rb");
+ FILE* fp = fopen(file_name, "rb");
if (fp == NULL) {
perror((std::string("Couldn't open file ") + file_name).c_str());
png_get_IHDR(png_ptr, info_ptr, &width, &height,
&bit_depth, &color_type, &interlace_type, NULL, NULL);
- if (bit_depth != 8) // transform SHOULD handle this...
+ if (bit_depth != 8) // transform SHOULD handle this...
goto png_done;
- if (color_type & PNG_COLOR_MASK_PALETTE) // !!! FIXME?
+ if (color_type & PNG_COLOR_MASK_PALETTE) // !!! FIXME?
goto png_done;
- if ((color_type & PNG_COLOR_MASK_COLOR) == 0) // !!! FIXME?
+ if ((color_type & PNG_COLOR_MASK_COLOR) == 0) // !!! FIXME?
goto png_done;
hasalpha = ((color_type & PNG_COLOR_MASK_ALPHA) != 0);
goto png_done;
if (!hasalpha) {
- png_byte *dst = tex.data;
+ png_byte* dst = tex.data;
for (int i = height - 1; i >= 0; i--) {
- png_byte *src = row_pointers[i];
+ png_byte* src = row_pointers[i];
for (unsigned j = 0; j < width; j++) {
dst[0] = src[0];
dst[1] = src[1];
}
else {
- png_byte *dst = tex.data;
+ png_byte* dst = tex.data;
int pitch = width * 4;
for (int i = height - 1; i >= 0; i--, dst += pitch)
memcpy(dst, row_pointers[i], pitch);
return (retval);
}
-static bool save_screenshot_png(const char *file_name)
+static bool save_screenshot_png(const char* file_name)
{
- FILE *fp = NULL;
+ FILE* fp = NULL;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
bool retval = false;
return false;
}
- png_bytep *row_pointers = new png_bytep[kContextHeight];
+ png_bytep* row_pointers = new png_bytep[kContextHeight];
png_bytep screenshot = new png_byte[kContextWidth * kContextHeight * 3];
if ((!screenshot) || (!row_pointers))
goto save_png_done;
{
SDL_PumpEvents();
int numkeys;
- const Uint8 *keyState = SDL_GetKeyboardState(&numkeys);
+ const Uint8* keyState = SDL_GetKeyboardState(&numkeys);
for (int i = 0; i < numkeys; i++) {
keyPressed[i] = !keyDown[i] && keyState[i];
keyDown[i] = keyState[i];
#include <time.h>
#include <windows.h>
-
class AppTime
{
-public:
- AppTime() {
+ public:
+ AppTime()
+ {
counterRate = 1;
baseCounter = 0;
- QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate);
- QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter);
+ QueryPerformanceFrequency((LARGE_INTEGER*)&counterRate);
+ QueryPerformanceCounter((LARGE_INTEGER*)&baseCounter);
}
__int64 counterRate; // LARGE_INTEGER type has no math functions so use int64
__int64 baseCounter;
AbsoluteTime UpTime()
{
__int64 counter;
- QueryPerformanceCounter( (LARGE_INTEGER*)&counter);
+ QueryPerformanceCounter((LARGE_INTEGER*)&counter);
counter -= g_appTime.baseCounter;
return time;
}
-
-Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b)
+Duration AbsoluteDeltaToDuration(AbsoluteTime& a, AbsoluteTime& b)
{
__int64 value = a.hi;
value <<= 32;
using namespace Game;
#ifdef WIN32
+#include "win-res/resource.hpp"
#include <shellapi.h>
#include <windows.h>
-#include "win-res/resource.hpp"
#endif
extern float multiplier;
extern int difficulty;
-extern SDL_Window *sdlwindow;
+extern SDL_Window* sdlwindow;
using namespace std;
-set<pair<int,int>> resolutions;
+set<pair<int, int>> resolutions;
// statics/globals (internal only) ------------------------------------------
void initGL()
{
- glClear( GL_COLOR_BUFFER_BIT );
+ glClear(GL_COLOR_BUFFER_BIT);
swap_gl_buffers();
// clear all states
- glDisable( GL_ALPHA_TEST);
- glDisable( GL_BLEND);
- glDisable( GL_DEPTH_TEST);
- glDisable( GL_FOG);
- glDisable( GL_LIGHTING);
- glDisable( GL_LOGIC_OP);
- glDisable( GL_TEXTURE_1D);
- glDisable( GL_TEXTURE_2D);
- glPixelTransferi( GL_MAP_COLOR, GL_FALSE);
- glPixelTransferi( GL_RED_SCALE, 1);
- glPixelTransferi( GL_RED_BIAS, 0);
- glPixelTransferi( GL_GREEN_SCALE, 1);
- glPixelTransferi( GL_GREEN_BIAS, 0);
- glPixelTransferi( GL_BLUE_SCALE, 1);
- glPixelTransferi( GL_BLUE_BIAS, 0);
- glPixelTransferi( GL_ALPHA_SCALE, 1);
- glPixelTransferi( GL_ALPHA_BIAS, 0);
+ glDisable(GL_ALPHA_TEST);
+ glDisable(GL_BLEND);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_FOG);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_LOGIC_OP);
+ glDisable(GL_TEXTURE_1D);
+ glDisable(GL_TEXTURE_2D);
+ glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
+ glPixelTransferi(GL_RED_SCALE, 1);
+ glPixelTransferi(GL_RED_BIAS, 0);
+ glPixelTransferi(GL_GREEN_SCALE, 1);
+ glPixelTransferi(GL_GREEN_BIAS, 0);
+ glPixelTransferi(GL_BLUE_SCALE, 1);
+ glPixelTransferi(GL_BLUE_BIAS, 0);
+ glPixelTransferi(GL_ALPHA_SCALE, 1);
+ glPixelTransferi(GL_ALPHA_BIAS, 0);
// set initial rendering states
- glShadeModel( GL_SMOOTH);
- glClearDepth( 1.0f);
- glDepthFunc( GL_LEQUAL);
- glDepthMask( GL_TRUE);
- glEnable( GL_DEPTH_TEST);
- glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
- glCullFace( GL_FRONT);
- glEnable( GL_CULL_FACE);
- glEnable( GL_LIGHTING);
- glEnable( GL_DITHER);
- glEnable( GL_COLOR_MATERIAL);
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glAlphaFunc( GL_GREATER, 0.5f);
-
- if ( CanInitStereo(stereomode) ) {
+ glShadeModel(GL_SMOOTH);
+ glClearDepth(1.0f);
+ glDepthFunc(GL_LEQUAL);
+ glDepthMask(GL_TRUE);
+ glEnable(GL_DEPTH_TEST);
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_DITHER);
+ glEnable(GL_COLOR_MATERIAL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glAlphaFunc(GL_GREATER, 0.5f);
+
+ if (CanInitStereo(stereomode)) {
InitStereo(stereomode);
} else {
fprintf(stderr, "Failed to initialize stereo, disabling.\n");
SDL_SetWindowFullscreen(sdlwindow, flags);
}
-SDL_bool sdlEventProc(const SDL_Event &e)
+SDL_bool sdlEventProc(const SDL_Event& e)
{
switch (e.type) {
case SDL_QUIT:
if (e.window.event == SDL_WINDOWEVENT_CLOSE) {
return SDL_FALSE;
}
- break;
+ break;
case SDL_MOUSEMOTION:
deltah += e.motion.xrel;
deltav += e.motion.yrel;
- break;
+ break;
case SDL_KEYDOWN:
if ((e.key.keysym.scancode == SDL_SCANCODE_G) &&
mode = (SDL_GetWindowGrab(sdlwindow) ? SDL_FALSE : SDL_TRUE);
SDL_SetWindowGrab(sdlwindow, mode);
SDL_SetRelativeMouseMode(mode);
- } else if ( (e.key.keysym.scancode == SDL_SCANCODE_RETURN) && (e.key.keysym.mod & KMOD_ALT) ) {
+ } else if ((e.key.keysym.scancode == SDL_SCANCODE_RETURN) && (e.key.keysym.mod & KMOD_ALT)) {
toggleFullscreen();
}
- break;
+ break;
}
return SDL_TRUE;
}
static Point gMidPoint;
-bool SetUp ()
+bool SetUp()
{
LOGFUNC;
if (SDL_GetDisplayMode(displayIdx, i, &mode) == -1)
continue;
if ((mode.w < 640) || (mode.h < 480))
- continue; // sane lower limit.
- pair<int,int> resolution(mode.w, mode.h);
+ continue; // sane lower limit.
+ pair<int, int> resolution(mode.w, mode.h);
resolutions.insert(resolution);
}
}
if (commandLineOptions[SHOWRESOLUTIONS]) {
printf("Available resolutions:\n");
for (auto resolution = resolutions.begin(); resolution != resolutions.end(); resolution++) {
- printf(" %d x %d\n", (int) resolution->first, (int) resolution->second);
+ printf(" %d x %d\n", (int)resolution->first, (int)resolution->second);
}
}
SDL_GL_MakeCurrent(sdlwindow, glctx);
int dblbuf = 0;
- if ((SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &dblbuf) == -1) || (!dblbuf))
- {
+ if ((SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &dblbuf) == -1) || (!dblbuf)) {
fprintf(stderr, "Failed to get a double-buffered context.\n");
SDL_Quit();
return false;
}
- if (SDL_GL_SetSwapInterval(-1) == -1) // try swap_tear first.
+ if (SDL_GL_SetSwapInterval(-1) == -1) // try swap_tear first.
SDL_GL_SetSwapInterval(1);
SDL_ShowCursor(0);
newscreenheight = screenheight;
/* If saved resolution is not in the list, add it to the list (so that it’s selectable in the options) */
- pair<int,int> startresolution(width,height);
+ pair<int, int> startresolution(width, height);
if (resolutions.find(startresolution) == resolutions.end()) {
resolutions.insert(startresolution);
}
return true;
}
-
static void DoMouse()
{
- if (mainmenu || ( (abs(deltah) < 10 * realmultiplier * 1000) && (abs(deltav) < 10 * realmultiplier * 1000) )) {
+ if (mainmenu || ((abs(deltah) < 10 * realmultiplier * 1000) && (abs(deltav) < 10 * realmultiplier * 1000))) {
deltah *= usermousesensitivity;
deltav *= usermousesensitivity;
mousecoordh += deltah;
else if (mousecoordv >= kContextHeight)
mousecoordv = kContextHeight - 1;
}
-
}
-void DoFrameRate (int update)
+void DoFrameRate(int update)
{
static long frames = 0;
- static AbsoluteTime time = {0, 0};
- static AbsoluteTime frametime = {0, 0};
- AbsoluteTime currTime = UpTime ();
- double deltaTime = (float) AbsoluteDeltaToDuration (currTime, frametime);
+ static AbsoluteTime time = { 0, 0 };
+ static AbsoluteTime frametime = { 0, 0 };
+ AbsoluteTime currTime = UpTime();
+ double deltaTime = (float)AbsoluteDeltaToDuration(currTime, frametime);
if (0 > deltaTime) // if negative microseconds
deltaTime /= -1000000.0;
if (update)
frametime = currTime; // reset for next time interval
- deltaTime = (float) AbsoluteDeltaToDuration (currTime, time);
+ deltaTime = (float)AbsoluteDeltaToDuration(currTime, time);
if (0 > deltaTime) // if negative microseconds
deltaTime /= -1000000.0;
}
}
-
-void DoUpdate ()
+void DoUpdate()
{
static float sps = 200;
static int count;
num_channels = 0;
}
*/
- if ( stereomode == stereoNone ) {
+ if (stereomode == stereoNone) {
DrawGLScene(stereoCenter);
} else {
DrawGLScene(stereoLeft);
// --------------------------------------------------------------------------
-
-void CleanUp (void)
+void CleanUp(void)
{
LOGFUNC;
return ((SDL_GetWindowFlags(sdlwindow) & SDL_WINDOW_INPUT_FOCUS) != 0);
}
-
-
#ifndef WIN32
// (code lifted from physfs: http://icculus.org/physfs/ ... zlib license.)
-static char *findBinaryInPath(const char *bin, char *envr)
+static char* findBinaryInPath(const char* bin, char* envr)
{
size_t alloc_size = 0;
- char *exe = NULL;
- char *start = envr;
- char *ptr;
+ char* exe = NULL;
+ char* start = envr;
+ char* ptr;
do {
size_t size;
- ptr = strchr(start, ':'); /* find next $PATH separator. */
+ ptr = strchr(start, ':'); /* find next $PATH separator. */
if (ptr)
*ptr = '\0';
size = strlen(start) + strlen(bin) + 2;
if (size > alloc_size) {
- char *x = (char *) realloc(exe, size);
+ char* x = (char*)realloc(exe, size);
if (x == NULL) {
if (exe != NULL)
free(exe);
- return(NULL);
+ return (NULL);
} /* if */
alloc_size = size;
strcat(exe, bin);
if (access(exe, X_OK) == 0) { /* Exists as executable? We're done. */
- strcpy(exe, start); /* i'm lazy. piss off. */
- return(exe);
+ strcpy(exe, start); /* i'm lazy. piss off. */
+ return (exe);
} /* if */
- start = ptr + 1; /* start points to beginning of next element. */
+ start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
if (exe != NULL)
free(exe);
- return(NULL); /* doesn't exist in path. */
+ return (NULL); /* doesn't exist in path. */
} /* findBinaryInPath */
-
-char *calcBaseDir(const char *argv0)
+char* calcBaseDir(const char* argv0)
{
/* If there isn't a path on argv0, then look through the $PATH for it. */
- char *retval;
- char *envr;
+ char* retval;
+ char* envr;
if (strchr(argv0, '/')) {
retval = strdup(argv0);
if (retval)
- *((char *) strrchr(retval, '/')) = '\0';
- return(retval);
+ *((char*)strrchr(retval, '/')) = '\0';
+ return (retval);
}
envr = getenv("PATH");
return NULL;
retval = findBinaryInPath(argv0, envr);
free(envr);
- return(retval);
+ return (retval);
}
-static inline void chdirToAppPath(const char *argv0)
+static inline void chdirToAppPath(const char* argv0)
{
- char *dir = calcBaseDir(argv0);
+ char* dir = calcBaseDir(argv0);
if (dir) {
#if (defined(__APPLE__) && defined(__MACH__))
// Chop off /Contents/MacOS if it's at the end of the string, so we
// land in the base of the app bundle.
const size_t len = strlen(dir);
- const char *bundledirs = "/Contents/MacOS";
+ const char* bundledirs = "/Contents/MacOS";
const size_t bundledirslen = strlen(bundledirs);
if (len > bundledirslen) {
- char *ptr = (dir + len) - bundledirslen;
+ char* ptr = (dir + len) - bundledirslen;
if (strcasecmp(ptr, bundledirs) == 0)
*ptr = '\0';
}
#endif
const option::Descriptor usage[] =
-{
- {UNKNOWN, 0, "", "", option::Arg::None, "USAGE: lugaru [options]\n\n"
- "Options:" },
- {HELP, 0, "h", "help", option::Arg::None, " -h, --help Print usage and exit." },
- {FULLSCREEN, 1, "f", "fullscreen", option::Arg::None, " -f, --fullscreen Start the game in fullscreen mode." },
- {FULLSCREEN, 0, "w", "windowed", option::Arg::None, " -w, --windowed Start the game in windowed mode (default)." },
- {NOMOUSEGRAB, 1, "", "nomousegrab", option::Arg::None, " --nomousegrab Disable mousegrab." },
- {NOMOUSEGRAB, 0, "", "mousegrab", option::Arg::None, " --mousegrab Enable mousegrab (default)." },
- {SOUND, 1, "", "nosound", option::Arg::None, " --nosound Disable sound." },
- {OPENALINFO, 0, "", "openal-info", option::Arg::None, " --openal-info Print info about OpenAL at launch." },
- {SHOWRESOLUTIONS, 0, "", "showresolutions", option::Arg::None, " --showresolutions List the resolutions found by SDL at launch." },
- {DEVTOOLS, 0, "d", "devtools", option::Arg::None, " -d, --devtools Enable dev tools: console, level editor and debug info." },
- {0,0,0,0,0,0}
-};
+ {
+ { UNKNOWN, 0, "", "", option::Arg::None, "USAGE: lugaru [options]\n\n"
+ "Options:" },
+ { HELP, 0, "h", "help", option::Arg::None, " -h, --help Print usage and exit." },
+ { FULLSCREEN, 1, "f", "fullscreen", option::Arg::None, " -f, --fullscreen Start the game in fullscreen mode." },
+ { FULLSCREEN, 0, "w", "windowed", option::Arg::None, " -w, --windowed Start the game in windowed mode (default)." },
+ { NOMOUSEGRAB, 1, "", "nomousegrab", option::Arg::None, " --nomousegrab Disable mousegrab." },
+ { NOMOUSEGRAB, 0, "", "mousegrab", option::Arg::None, " --mousegrab Enable mousegrab (default)." },
+ { SOUND, 1, "", "nosound", option::Arg::None, " --nosound Disable sound." },
+ { OPENALINFO, 0, "", "openal-info", option::Arg::None, " --openal-info Print info about OpenAL at launch." },
+ { SHOWRESOLUTIONS, 0, "", "showresolutions", option::Arg::None, " --showresolutions List the resolutions found by SDL at launch." },
+ { DEVTOOLS, 0, "d", "devtools", option::Arg::None, " -d, --devtools Enable dev tools: console, level editor and debug info." },
+ { 0, 0, 0, 0, 0, 0 }
+ };
option::Option commandLineOptions[commandLineOptionsNumber];
option::Option* commandLineOptionsBuffer;
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
- argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present
- option::Stats stats(true, usage, argc, argv);
+ argc -= (argc > 0);
+ argv += (argc > 0); // skip program name argv[0] if present
+ option::Stats stats(true, usage, argc, argv);
if (commandLineOptionsNumber != stats.options_max) {
std::cerr << "Found incorrect command line option number" << std::endl;
return 1;
return 1;
}
- // !!! FIXME: we could use a Win32 API for this. --ryan.
+// !!! FIXME: we could use a Win32 API for this. --ryan.
#ifndef WIN32
chdirToAppPath(argv[0]);
#endif
{
newGame();
- if (!SetUp ()) {
+ if (!SetUp()) {
delete[] commandLineOptionsBuffer;
return 42;
}
SDL_Event e;
if (!waiting) {
// message pump
- while ( SDL_PollEvent( &e ) ) {
+ while (SDL_PollEvent(&e)) {
if (!sdlEventProc(e)) {
gameDone = true;
break;
deleteGame();
}
- CleanUp ();
+ CleanUp();
return 0;
#ifdef NDEBUG