Merge branch 'master' into cleanup

Conflicts:
	CHANGELOG
	src/g_combat.c
	src/g_func.c
	src/g_items.c
This commit is contained in:
Yamagi Burmeister 2013-01-05 12:34:59 +01:00
commit 6e48d1aa2a
24 changed files with 320 additions and 153 deletions

View file

@ -1,3 +1,11 @@
The Reckoning 1.08 to 1.09
- Port 'The Reckoning' to Mac OS X.
The Reckoning 1.07 to 1.08
- Port 'The Reckoning' to Windows.
- Use randk() instead of rand(), a better PNRG.
- Fix some potential problems found by scan-build.
The Reckoning 1.06 to 1.07
- Port the new savegame system from baseq2
- Reorder the files to reflect the new structure of baseq2

102
Makefile
View file

@ -2,7 +2,7 @@
# Makefile for the xatrix game module for Quake II #
# #
# Just type "make" to compile the #
# - The Reckoning Game (game.so) #
# - The Reckoning Game (game.so / game.dll) #
# #
# Dependencies: #
# - None, but you need a Quake II to play. #
@ -10,28 +10,32 @@
# Yamagi Quake II ist recommended. #
# #
# Platforms: #
# - Linux #
# - FreeBSD #
# - Linux #
# - Windows #
# ----------------------------------------------------- #
# Check the OS type
# Detect the OS
ifdef SystemRoot
OSTYPE := Windows
else
OSTYPE := $(shell uname -s)
endif
# Some plattforms call it "amd64" and some "x86_64"
# Detect the architecture
ifeq ($(OSTYPE), Windows)
# At this time only i386 is supported on Windows
ARCH := i386
else
# Some platforms call it "amd64" and some "x86_64"
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
endif
# Refuse all other plattforms as a firewall against PEBKAC
# Refuse all other platforms as a firewall against PEBKAC
# (You'll need some #ifdef for your unsupported plattform!)
ifneq ($(ARCH),i386)
ifneq ($(ARCH),x86_64)
ifeq ($(findstring $(ARCH), i386 x86_64 sparc64 ia64),)
$(error arch $(ARCH) is currently not supported)
endif
endif
# ----------
# The compiler
CC := gcc
# ----------
@ -53,13 +57,22 @@ CC := gcc
# -fPIC for position independend code.
#
# -MMD to generate header dependencies.
ifeq ($(OSTYPE), Darwin)
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-fPIC -Wall -pipe -g -MMD
-Wall -pipe -g -arch i386 -arch x86_64
else
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
-Wall -pipe -g -MMD
endif
# ----------
# Base LDFLAGS.
ifeq ($(OSTYPE), Darwin)
LDFLAGS := -shared -arch i386 -arch x86_64
else
LDFLAGS := -shared
endif
# ----------
@ -68,24 +81,60 @@ all: xatrix
# ----------
# When make is invoked by "make VERBOSE=1" print
# the compiler and linker commands.
ifdef VERBOSE
Q :=
else
Q := @
endif
# ----------
# Phony targets
.PHONY : all clean xatrix
# ----------
# Cleanup
ifeq ($(OSTYPE), Windows)
clean:
@echo "===> CLEAN"
@rm -Rf build release
@-rmdir /S /Q release build
else
clean:
@echo "===> CLEAN"
${Q}rm -Rf build release
endif
# ----------
# The xatrix game
ifeq ($(OSTYPE), Windows)
xatrix:
@echo '===> Building game.so'
@mkdir -p release/
@echo "===> Building game.dll"
${Q}tools/mkdir.exe -p release
${MAKE} release/game.dll
build/%.o: %.c
@echo "===> CC $<"
${Q}tools/mkdir.exe -p $(@D)
${Q}$(CC) -c $(CFLAGS) -o $@ $<
else
xatrix:
@echo "===> Building game.so"
${Q}mkdir -p release
$(MAKE) release/game.so
build/%.o: %.c
@echo '===> CC $<'
@mkdir -p $(@D)
@$(CC) -c $(CFLAGS) -o $@ $<
@echo "===> CC $<"
${Q}mkdir -p $(@D)
${Q}$(CC) -c $(CFLAGS) -o $@ $<
release/game.so : CFLAGS += -fPIC
endif
# ----------
XATRIX_OBJS_ = \
@ -140,6 +189,7 @@ XATRIX_OBJS_ = \
src/player/weapon.o \
src/savegame/savegame.o \
src/shared/flash.o \
src/shared/rand.o \
src/shared/shared.o
# ----------
@ -159,8 +209,14 @@ XATRIX_DEPS= $(XATRIX_OBJS:.o=.d)
# ----------
ifeq ($(OSTYPE), Windows)
release/game.dll : $(XATRIX_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(XATRIX_OBJS)
else
release/game.so : $(XATRIX_OBJS)
@echo '===> LD $@'
@$(CC) $(LDFLAGS) -o $@ $(XATRIX_OBJS)
@echo "===> LD $@"
${Q}$(CC) $(LDFLAGS) -o $@ $(XATRIX_OBJS)
endif
# ----------

28
README
View file

@ -4,10 +4,36 @@ fixed, this version should run much more stable than the the old
SDK version. It must be used with the "Yamagi Quake II Client".
For more information visit http://www.yamagi.org/quake2.
Installation:
Installation for FreeBSD, Linux and OpenBSD:
--------------------------------------------
1. Type "make" or "gmake" to compile the game.so.
2. Create a subdirectory xatrix/ in your quake2 directory.
3. Copy pak0.pak and videos/ from the the Reckoning CD to
the newly created directory xatrix/.
4. Copy release/game.so to xatrix/.
5. Start the game with "./quake2 +set game xatrix"
Installation for OS X:
----------------------
1. Create a subdirectory xatrix/ in your quake2 directory.
2. Copy pak0.pak and videos/ from the the Reckoning CD to
the newly created directory xatrix/.
3. Copy game.dll from the zip-archive to xatrix/.
4. Start the game with "quake2 +set game xatrix"
If you want to compile 'xatrix' for OS X from source, please take a
look at the "Installation" section of the README of the Yamagi Quake II
client. In the same file the integration into an app-bundle is
explained.
Installation for Windows:
-------------------------
1. Create a subdirectory xatrix\ in your quake2 directory.
2. Copy pak0.pak and videos\ from the the Reckoning CD to
the newly created directory xatrix\.
3. Copy game.dll from the zip-archive to xatrix/.
4. Start the game with "quake2.exe +set game xatrix"
If you want to compile 'xatrix' for Windows from source, please take a
look at the "Installation" section of the README of the Yamagi Quake II
client. There's descripted how to setup the build environment.

View file

@ -16,7 +16,6 @@ UpdateChaseCam(edict_t *ent)
vec3_t forward, right;
trace_t trace;
int i;
vec3_t oldgoal;
vec3_t angles;
if (!ent)
@ -42,7 +41,6 @@ UpdateChaseCam(edict_t *ent)
targ = ent->client->chase_target;
VectorCopy(targ->s.origin, ownerv);
VectorCopy(ent->s.origin, oldgoal);
ownerv[2] += targ->viewheight;

View file

@ -155,11 +155,11 @@ Killed(edict_t *targ, edict_t *inflictor, edict_t *attacker,
void
SpawnDamage(int type, vec3_t origin, vec3_t normal, int damage)
{
gi.WriteByte(svc_temp_entity);
gi.WriteByte(type);
gi.WritePosition(origin);
gi.WriteDir(normal);
gi.multicast(origin, MULTICAST_PVS);
gi.WriteByte (svc_temp_entity);
gi.WriteByte (type);
gi.WritePosition (origin);
gi.WriteDir (normal);
gi.multicast (origin, MULTICAST_PVS);
}
/*

View file

@ -543,10 +543,7 @@ plat_blocked(edict_t *self, edict_t *other)
if (other)
{
/* Hack for entity without it's origin near the model */
vec3_t save;
VectorCopy(other->s.origin, save);
VectorMA(other->absmin, 0.5, other->size, other->s.origin);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
@ -1382,6 +1379,9 @@ door_use(edict_t *self, edict_t *other /* unused */, edict_t *activator)
edict_t *ent;
if (!self)
return;
if (self->flags & FL_TEAMSLAVE)
{
return;
@ -1579,10 +1579,7 @@ door_blocked(edict_t *self, edict_t *other)
if (other)
{
/* Hack for entitiy without their origin near the model */
vec3_t save;
VectorCopy(other->s.origin, save);
VectorMA(other->absmin, 0.5, other->size, other->s.origin);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
@ -2108,11 +2105,8 @@ train_blocked(edict_t *self, edict_t *other)
/* if it's still there, nuke it */
if (other)
{
/* Hack for entity without an origin near the model */
vec3_t save;
VectorCopy(other->s.origin, save);
VectorMA(other->absmin, 0.5, other->size, other->s.origin);
/* Hack for entity without an origin near the model */
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}
@ -2809,10 +2803,7 @@ door_secret_blocked(edict_t *self, edict_t *other)
if (other)
{
/* Hack for entities without their origin near the model */
vec3_t save;
VectorCopy(other->s.origin, save);
VectorMA(other->absmin, 0.5, other->size, other->s.origin);
VectorMA (other->absmin, 0.5, other->size, other->s.origin);
BecomeExplosion1(other);
}

View file

@ -141,7 +141,7 @@ DoRespawn(edict_t *ent)
{
}
choice = rand() % count;
choice = count ? randk() % count : 0;
for (count = 0, ent = master; count < choice; ent = ent->chain, count++)
{

View file

@ -120,6 +120,9 @@ GetGameAPI(game_import_t *import)
globals.edict_size = sizeof(edict_t);
/* Initalize the PRNG */
randk_seed();
return &globals;
}

View file

@ -79,12 +79,6 @@ void dabeam_hit (edict_t *self)
vec3_t start;
vec3_t end;
trace_t tr;
int count;
if (self->spawnflags & 0x80000000)
count = 8;
else
count = 4;
ignore = self;
VectorCopy (self->s.origin, start);

View file

@ -494,7 +494,6 @@ qboolean SV_Push (edict_t *pusher, vec3_t move, vec3_t amove)
{
int i, e;
edict_t *check, *block;
vec3_t mins, maxs;
pushed_t *p;
vec3_t org, org2, move2, forward, right, up;
vec3_t realmins, realmaxs;
@ -512,13 +511,6 @@ qboolean SV_Push (edict_t *pusher, vec3_t move, vec3_t amove)
move[i] = 0.125 * (int)temp;
}
// find the bounding box
for (i=0 ; i<3 ; i++)
{
mins[i] = pusher->absmin[i] + move[i];
maxs[i] = pusher->absmax[i] + move[i];
}
// we need this for pushing things later
VectorSubtract (vec3_origin, amove, org);
AngleVectors (org, forward, right, up);

View file

@ -396,15 +396,6 @@ speed default is 1000
void use_target_blaster (edict_t *self, edict_t *other, edict_t *activator)
{
int effect;
if (self->spawnflags & 2)
effect = 0;
else if (self->spawnflags & 1)
effect = EF_HYPERBLASTER;
else
effect = EF_BLASTER;
fire_blaster (self, self->s.origin, self->movedir, self->dmg, self->speed, EF_BLASTER, MOD_TARGET_BLASTER);
gi.sound (self, CHAN_VOICE, self->noise_index, 1, ATTN_NORM, 0);
}

View file

@ -687,6 +687,9 @@ void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick
int mask;
qboolean water;
if (!self)
return;
VectorMA (start, 8192, aimdir, end);
VectorCopy (start, from);
ignore = self;
@ -1041,7 +1044,6 @@ void heat_think (edict_t *self)
edict_t *target = NULL;
edict_t *aquire = NULL;
vec3_t vec;
vec3_t oldang;
int len;
int oldlen = 0;
@ -1078,11 +1080,8 @@ void heat_think (edict_t *self)
if (aquire != NULL)
{
VectorCopy (self->s.angles, oldang);
VectorSubtract (aquire->s.origin, self->s.origin, vec);
vectoangles (vec, self->s.angles);
VectorNormalize (vec);
VectorCopy (vec, self->movedir);
VectorScale (vec, 500, self->velocity);

View file

@ -505,8 +505,8 @@ extern edict_t *g_edicts;
#define LLOFS(x) (size_t)&(((level_locals_t *)NULL)->x)
#define CLOFS(x) (size_t)&(((gclient_t *)NULL)->x)
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))
#define random() ((randk() & 0x7fff) / ((float)0x7fff))
#define crandom() (2.0 * (random() - 0.5))
extern cvar_t *maxentities;
extern cvar_t *deathmatch;

View file

@ -19,7 +19,7 @@
#include <time.h>
typedef unsigned char byte;
typedef enum {false, true} qboolean;
typedef enum {false, true} qboolean;
#ifndef NULL
#define NULL ((void *)0)
@ -35,7 +35,12 @@ typedef enum {false, true} qboolean;
#define MAX_TOKEN_CHARS 128 /* max length of an individual token */
#define MAX_QPATH 64 /* max length of a quake game pathname */
#ifdef _WIN32
#define MAX_OSPATH 256 /* max length of a filesystem pathname (same as MAX_PATH) */
#else
#define MAX_OSPATH 128 /* max length of a filesystem pathname */
#endif
/* */
/* per-level limits */
@ -178,6 +183,8 @@ void Com_sprintf(char *dest, int size, char *fmt, ...);
void Com_PageInMemory(byte *buffer, int size);
char *strlwr ( char *s );
/* ============================================= */
/* portable case insensitive compare */
@ -209,6 +216,14 @@ void Info_RemoveKey(char *s, char *key);
void Info_SetValueForKey(char *s, char *key, char *value);
qboolean Info_Validate(char *s);
/* ============================================= */
/* Random number generator */
int randk(void);
float frandk(void);
float crandk(void);
void randk_seed(void);
/*
* ==============================================================
*
@ -221,7 +236,6 @@ extern int curtime; /* time returned by last Sys_Milliseconds */
int Sys_Milliseconds(void);
void Sys_Mkdir(char *path);
void Sys_Rmdir(char *path);
char *strlwr(char *s);
/* large block stack allocation routines */
@ -426,9 +440,9 @@ typedef enum
#define PMF_NO_PREDICTION 64 /* temporarily disables prediction (used for grappling hook) */
/* this structure needs to be communicated bit-accurate/
from the server to the client to guarantee that
prediction stays in sync, so no floats are used.
if any part of the game code modifies this struct, it
from the server to the client to guarantee that
prediction stays in sync, so no floats are used.
if any part of the game code modifies this struct, it
will result in a prediction error of some degree. */
typedef struct
{
@ -439,7 +453,7 @@ typedef struct
byte pm_flags; /* ducked, jump_held, etc */
byte pm_time; /* each unit = 8 ms */
short gravity;
short delta_angles[3]; /* add to command angles to get view direction
short delta_angles[3]; /* add to command angles to get view direction
changed by spawns, rotating objects, and teleporters */
} pmove_state_t;
@ -487,9 +501,9 @@ typedef struct
int (*pointcontents)(vec3_t point);
} pmove_t;
/* entity_state_t->effects
/* entity_state_t->effects
Effects are things handled on the client side (lights, particles,
frame animations) that happen constantly on the given entity.
frame animations) that happen constantly on the given entity.
An entity that has effects will be sent to the client even if
it has a zero index model. */
#define EF_ROTATE 0x00000001 /* rotate (bonus items) */
@ -748,7 +762,7 @@ typedef struct
#define MZ2_WIDOW_DISRUPTOR 148
#define MZ2_WIDOW_BLASTER 149
#define MZ2_WIDOW_RAIL 150
#define MZ2_WIDOW_PLASMABEAM 151
#define MZ2_WIDOW_PLASMABEAM 151
#define MZ2_CARRIER_MACHINEGUN_L2 152
#define MZ2_CARRIER_MACHINEGUN_R2 153
#define MZ2_WIDOW_RAIL_LEFT 154
@ -811,9 +825,9 @@ typedef struct
extern vec3_t monster_flash_offset[];
/* Temp entity events are for things that happen
at a location seperate from any existing entity.
Temporary entity messages are explicitly constructed
/* Temp entity events are for things that happen
at a location seperate from any existing entity.
Temporary entity messages are explicitly constructed
and broadcast. */
typedef enum
{
@ -884,7 +898,7 @@ typedef enum
#define SPLASH_BLOOD 6
/* sound channels:
channel 0 never willingly overrides
channel 0 never willingly overrides
other channels (1-7) allways override
a playing sound on that channel */
#define CHAN_AUTO 0
@ -960,8 +974,8 @@ typedef enum
#define ANGLE2SHORT(x) ((int)((x) * 65536 / 360) & 65535)
#define SHORT2ANGLE(x) ((x) * (360.0 / 65536))
/* config strings are a general means of communication from
the server to all connected clients. Each config string
/* config strings are a general means of communication from
the server to all connected clients. Each config string
can be at most MAX_QPATH characters. */
#define CS_NAME 0
#define CS_CDTRACK 1
@ -985,9 +999,9 @@ typedef enum
/* ============================================== */
/* entity_state_t->event values
entity events are for effects that take place reletive
to an existing entities origin. Very network efficient.
/* entity_state_t->event values
entity events are for effects that take place reletive
to an existing entities origin. Very network efficient.
All muzzle flashes really should be converted to events... */
typedef enum
{
@ -1001,8 +1015,8 @@ typedef enum
EV_OTHER_TELEPORT
} entity_event_t;
/* entity_state_t is the information conveyed from the server
in an update message about entities that the client will
/* entity_state_t is the information conveyed from the server
in an update message about entities that the client will
need to render in some way */
typedef struct entity_state_s
{
@ -1015,7 +1029,7 @@ typedef struct entity_state_s
int modelindex2, modelindex3, modelindex4; /* weapons, CTF flags, etc */
int frame;
int skinnum;
unsigned int effects;
unsigned int effects;
int renderfx;
int solid; /* for client side prediction, 8*(bits 0-4) is x/y radius */
/* 8*(bits 5-9) is z down distance, 8(bits10-15) is z up */
@ -1028,9 +1042,9 @@ typedef struct entity_state_s
/* ============================================== */
/* player_state_t is the information needed in addition to pmove_state_t
to rendered a view. There will only be 10 player_state_t sent each second,
but the number of pmove_state_t changes will be reletive to client
/* player_state_t is the information needed in addition to pmove_state_t
to rendered a view. There will only be 10 player_state_t sent each second,
but the number of pmove_state_t changes will be reletive to client
frame rates */
typedef struct
{

View file

@ -479,7 +479,6 @@ qboolean Boss2_CheckAttack (edict_t *self)
vec3_t temp;
float chance;
trace_t tr;
qboolean enemy_infront;
int enemy_range;
float enemy_yaw;
@ -498,7 +497,6 @@ qboolean Boss2_CheckAttack (edict_t *self)
return false;
}
enemy_infront = infront(self, self->enemy);
enemy_range = range(self, self->enemy);
VectorSubtract (self->enemy->s.origin, self->s.origin, temp);
enemy_yaw = vectoyaw(temp);

View file

@ -511,12 +511,6 @@ void jorg_firebullet (edict_t *self)
void jorg_attack(edict_t *self)
{
vec3_t vec;
float range;
VectorSubtract (self->enemy->s.origin, self->s.origin, vec);
range = VectorLength (vec);
if (random() <= 0.75)
{
gi.sound (self, CHAN_VOICE, sound_attack1, 1, ATTN_NORM,0);
@ -551,7 +545,6 @@ qboolean Jorg_CheckAttack (edict_t *self)
vec3_t temp;
float chance;
trace_t tr;
qboolean enemy_infront;
int enemy_range;
float enemy_yaw;
@ -570,7 +563,6 @@ qboolean Jorg_CheckAttack (edict_t *self)
return false;
}
enemy_infront = infront(self, self->enemy);
enemy_range = range(self, self->enemy);
VectorSubtract (self->enemy->s.origin, self->s.origin, temp);
enemy_yaw = vectoyaw(temp);

View file

@ -588,16 +588,9 @@ void makron_sight(edict_t *self, edict_t *other)
void makron_attack(edict_t *self)
{
vec3_t vec;
float range;
float r;
r = random();
VectorSubtract (self->enemy->s.origin, self->s.origin, vec);
range = VectorLength (vec);
if (r <= 0.3)
self->monsterinfo.currentmove = &makron_move_attack3;
else if (r <= 0.6)
@ -697,7 +690,6 @@ qboolean Makron_CheckAttack (edict_t *self)
vec3_t temp;
float chance;
trace_t tr;
qboolean enemy_infront;
int enemy_range;
float enemy_yaw;
@ -716,7 +708,6 @@ qboolean Makron_CheckAttack (edict_t *self)
return false;
}
enemy_infront = infront(self, self->enemy);
enemy_range = range(self, self->enemy);
VectorSubtract (self->enemy->s.origin, self->s.origin, temp);
enemy_yaw = vectoyaw(temp);

View file

@ -212,7 +212,7 @@ void roam_goal (edict_t *self)
vec3_t end;
edict_t *ent;
vec3_t dang;
int len, oldlen, whichi, i;
int len, oldlen, i;
vec3_t vec;
vec3_t whichvec;
@ -227,7 +227,6 @@ void roam_goal (edict_t *self)
gi.linkentity (ent);
oldlen = 0;
whichi = 0;
for (i=0; i<12; i++)
{
@ -1116,8 +1115,6 @@ void fixbot_fire_welder (edict_t *self)
{
vec3_t start;
vec3_t forward, right, up;
vec3_t end;
vec3_t dir;
vec3_t vec;
float r;
@ -1132,10 +1129,6 @@ void fixbot_fire_welder (edict_t *self)
AngleVectors (self->s.angles, forward, right, up);
G_ProjectSource (self->s.origin, vec, forward, right, start);
VectorCopy (self->enemy->s.origin, end);
VectorSubtract (end, start, dir);
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_WELDING_SPARKS);
gi.WriteByte (10);

View file

@ -160,7 +160,6 @@ void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer)
int sorted[MAX_CLIENTS];
int sortedscores[MAX_CLIENTS];
int score, total;
int picnum;
int x, y;
gclient_t *cl;
edict_t *cl_ent;
@ -203,7 +202,6 @@ void DeathmatchScoreboardMessage (edict_t *ent, edict_t *killer)
cl = &game.clients[sorted[i]];
cl_ent = g_edicts + 1 + sorted[i];
picnum = gi.imageindex ("i_fixme");
x = (i>=6) ? 160 : 0;
y = 32 + 32 * (i%6);
@ -367,11 +365,9 @@ G_SetStats
void G_SetStats (edict_t *ent)
{
gitem_t *item;
int index, cells;
int index, cells = 0;
int power_armor_type;
cells = 0;
//
// health
//

View file

@ -1571,24 +1571,20 @@ void weapon_ionripper_fire (edict_t *ent)
vec3_t offset;
vec3_t tempang;
int damage;
int kick;
if (deathmatch->value)
{
// tone down for deathmatch
damage = 30;
kick = 40;
}
else
{
damage = 50;
kick = 60;
}
if (is_quad)
{
damage *= 4;
kick *= 4;
}
VectorCopy (ent->client->v_angle, tempang);

View file

@ -66,8 +66,14 @@
*/
#if defined(__FreeBSD__)
#define OS "FreeBSD"
#elif defined(__APPLE__)
#define OS "MacOS X"
#elif defined(__OpenBSD__)
#define OS "OpenBSD"
#elif defined(__linux__)
#define OS "Linux"
#elif defined(_WIN32)
#define OS "Windows"
#else
#define OS "Unknown"
#endif
@ -76,6 +82,10 @@
#define ARCH "i386"
#elif defined(__x86_64__)
#define ARCH "amd64"
#elif defined(__ia64__)
#define ARCH "ia64"
#elif defined(__sparc__)
#define ARCH "sparc64"
#else
#define ARCH "unknown"
#endif

97
src/shared/rand.c Normal file
View file

@ -0,0 +1,97 @@
/*
* KISS PRNG (c) 2011 Shinobu
*
* This file was optained from zuttobenkyou.wordpress.com
* and modified by the Yamagi Quake II developers.
*
* LICENSE: Public domain
*
* =======================================================================
*
* KISS PRNG, as devised by Dr. George Marsaglia
*
* =======================================================================
*/
#include <stdint.h>
#define QSIZE 0x200000
#define CNG (cng = 6906969069ULL * cng + 13579)
#define XS (xs ^= (xs << 13), xs ^= (xs >> 17), xs ^= (xs << 43))
#define KISS (B64MWC() + CNG + XS)
static uint64_t QARY[QSIZE];
static int j;
static uint64_t carry;
static uint64_t xs;
static uint64_t cng;
uint64_t
B64MWC(void)
{
uint64_t t, x;
j = (j + 1) & (QSIZE - 1);
x = QARY[j];
t = (x << 28) + carry;
carry = (x >> 36) - (t < x);
return QARY[j] = t - x;
}
/*
* Generate a pseudorandom
* integer >0.
*/
int
randk(void)
{
int r;
r = (int)KISS;
r = (r < 0) ? (r * -1) : r;
return r;
}
/*
* Generate a pseudorandom
* signed float between
* 0 and 1.
*/
float
frandk(void)
{
return (randk()&32767)* (1.0/32767);
}
/* Generate a pseudorandom
* float between -1 and 1.
*/
float
crandk(void)
{
return (randk()&32767)* (2.0/32767) - 1;
}
/*
* Seeds the PRNG
*/
void
randk_seed(void)
{
uint64_t i;
/* Seed QARY[] with CNG+XS: */
for (i = 0; i < QSIZE; i++)
{
QARY[i] = CNG + XS;
}
/* Run through several rounds
to warm up the state */
for (i = 0; i < 256; i++)
{
randk();
}
}

View file

@ -6,6 +6,8 @@
* =======================================================================
*/
#include <ctype.h>
#include "../header/shared.h"
#define DEG2RAD(a) (a * M_PI) / 180.0F
@ -304,8 +306,8 @@ anglemod(float a)
int i;
vec3_t corners[2];
/*
* This is the slow, general version
/*
* This is the slow, general version
*/
int
BoxOnPlaneSide2(vec3_t emins, vec3_t emaxs, struct cplane_s *p)
@ -423,7 +425,7 @@ BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct cplane_s *p)
p->normal[2] * emaxs[2];
break;
default:
dist1 = dist2 = 0;
dist1 = dist2 = 0;
break;
}
@ -756,7 +758,7 @@ COM_DefaultExtension(char *path, const char *extension)
qboolean bigendien;
/* can't just use function pointers, or dll linkage can
/* can't just use function pointers, or dll linkage can
mess up when qcommon is included in multiple places */
short (*_BigShort)(short l);
short (*_LittleShort)(short l);
@ -768,37 +770,37 @@ float (*_LittleFloat)(float l);
short
BigShort(short l)
{
return _BigShort(l);
return _BigShort(l);
}
short
LittleShort(short l)
{return
_LittleShort(l);
{
return _LittleShort(l);
}
int
BigLong(int l)
{
return _BigLong(l);
return _BigLong(l);
}
int
LittleLong(int l)
{
return _LittleLong(l);
return _LittleLong(l);
}
float
BigFloat(float l)
{
return _BigFloat(l);
return _BigFloat(l);
}
float
LittleFloat(float l)
{
return _LittleFloat(l);
return _LittleFloat(l);
}
short
@ -875,6 +877,7 @@ Swap_Init(void)
_LittleLong = LongNoSwap;
_BigFloat = FloatSwap;
_LittleFloat = FloatNoSwap;
Com_Printf("Byte ordering: little endian\n\n");
}
else
{
@ -885,11 +888,15 @@ Swap_Init(void)
_LittleLong = LongSwap;
_BigFloat = FloatNoSwap;
_LittleFloat = FloatSwap;
Com_Printf("Byte ordering: big endian\n\n");
}
if (LittleShort(*(short *)swaptest) != 1)
assert("Error in the endian conversion!");
}
/*
* does a varargs printf into a temp buffer, so I don't
* does a varargs printf into a temp buffer, so I don't
* need to have varargs versions of all text functions.
*/
char *
@ -1085,13 +1092,29 @@ Com_sprintf(char *dest, int size, char *fmt, ...)
if ((len >= size) || (len == size))
{
Com_Printf("Com_sprintf: overflow\n");
len = size - 1;
dest = NULL;
return;
}
bigbuffer[size - 1] = '\0';
strcpy(dest, bigbuffer);
}
char *
strlwr ( char *s )
{
char *p = s;
while ( *s )
{
*s = tolower( *s );
s++;
}
return ( p );
}
/*
* =====================================================================
*
@ -1109,7 +1132,7 @@ char *
Info_ValueForKey(char *s, char *key)
{
char pkey[512];
static char value[2][512]; /* use two buffers so compares
static char value[2][512]; /* use two buffers so compares
work without stomping on each other */
static int valueindex;
char *o;
@ -1313,4 +1336,3 @@ Info_SetValueForKey(char *s, char *key, char *value)
*s = 0;
}

BIN
tools/mkdir.exe Normal file

Binary file not shown.