halflife-photomode/pm_shared/pm_defs.h

221 lines
7.2 KiB
C
Raw Normal View History

/***
2013-08-30 13:34:05 -07:00
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
// pm_defs.h
2013-08-30 13:34:05 -07:00
#pragma once
#include "Platform.h"
#define MAX_PHYSENTS 600 // Must have room for all entities in the world.
2013-08-30 13:34:05 -07:00
#define MAX_MOVEENTS 64
#define MAX_CLIP_PLANES 5
2013-08-30 13:34:05 -07:00
#define PM_NORMAL 0x00000000
#define PM_STUDIO_IGNORE 0x00000001 // Skip studio models
#define PM_STUDIO_BOX 0x00000002 // Use boxes for non-complex studio models (even in traceline)
#define PM_GLASS_IGNORE 0x00000004 // Ignore entities with non-normal rendermode
#define PM_WORLD_ONLY 0x00000008 // Only trace against the world
2013-08-30 13:34:05 -07:00
// Values for flags parameter of PM_TraceLine
#define PM_TRACELINE_PHYSENTSONLY 0
#define PM_TRACELINE_ANYVISIBLE 1
2013-08-30 13:34:05 -07:00
#include "pm_info.h"
// PM_PlayerTrace results.
#include "pmtrace.h"
#include "usercmd.h"
typedef struct model_s model_t;
2013-08-30 13:34:05 -07:00
// physent_t
typedef struct physent_s
{
char name[32]; // Name of model, or "player" or "world".
int player;
Vector origin; // Model's origin in world coordinates.
model_t* model; // only for bsp models
model_t* studiomodel; // SOLID_BBOX, but studio clip intersections.
Vector mins, maxs; // only for non-bsp models
int info; // For client or server to use to identify (index into edicts or cl_entities)
Vector angles; // rotated entities need this info for hull testing to work.
int solid; // Triggers and func_door type WATER brushes are SOLID_NOT
int skin; // BSP Contents for such things like fun_door water brushes.
int rendermode; // So we can ignore glass
2013-08-30 13:34:05 -07:00
// Complex collision detection.
float frame;
int sequence;
byte controller[4];
byte blending[2];
2013-08-30 13:34:05 -07:00
int movetype;
int takedamage;
int blooddecal;
int team;
int classnumber;
2013-08-30 13:34:05 -07:00
// For mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
Vector vuser1;
Vector vuser2;
Vector vuser3;
Vector vuser4;
2013-08-30 13:34:05 -07:00
} physent_t;
typedef struct playermove_s
{
int player_index; // So we don't try to run the PM_CheckStuck nudging too quickly.
qboolean server; // For debugging, are we running physics code on server side?
2013-08-30 13:34:05 -07:00
qboolean multiplayer; // 1 == multiplayer server
float time; // realtime on host, for reckoning duck timing
float frametime; // Duration of this frame
2013-08-30 13:34:05 -07:00
Vector forward, right, up; // Vectors for angles
2013-08-30 13:34:05 -07:00
// player state
Vector origin; // Movement origin.
Vector angles; // Movement view angles.
Vector oldangles; // Angles before movement view angles were looked at.
Vector velocity; // Current movement direction.
Vector movedir; // For waterjumping, a forced forward velocity so we can fly over lip of ledge.
Vector basevelocity; // Velocity of the conveyor we are standing, e.g.
2013-08-30 13:34:05 -07:00
// For ducking/dead
Vector view_ofs; // Our eye position.
float flDuckTime; // Time we started duck
qboolean bInDuck; // In process of ducking or ducked already?
2013-08-30 13:34:05 -07:00
// For walking/falling
int flTimeStepSound; // Next time we can play a step sound
int iStepLeft;
2013-08-30 13:34:05 -07:00
float flFallVelocity;
Vector punchangle;
2013-08-30 13:34:05 -07:00
float flSwimTime;
2013-08-30 13:34:05 -07:00
float flNextPrimaryAttack;
2013-08-30 13:34:05 -07:00
int effects; // MUZZLE FLASH, e.g.
2013-08-30 13:34:05 -07:00
int flags; // FL_ONGROUND, FL_DUCKING, etc.
int usehull; // 0 = regular player hull, 1 = ducked player hull, 2 = point hull
float gravity; // Our current gravity and friction.
float friction;
int oldbuttons; // Buttons last usercmd
float waterjumptime; // Amount of time left in jumping out of water cycle.
qboolean dead; // Are we a dead player?
int deadflag;
int spectator; // Should we use spectator physics model?
int movetype; // Our movement type, NOCLIP, WALK, FLY
2013-08-30 13:34:05 -07:00
int onground;
int waterlevel;
int watertype;
int oldwaterlevel;
2013-08-30 13:34:05 -07:00
char sztexturename[256];
char chtexturetype;
2013-08-30 13:34:05 -07:00
float maxspeed;
float clientmaxspeed; // Player specific maxspeed
2013-08-30 13:34:05 -07:00
// For mods
int iuser1;
int iuser2;
int iuser3;
int iuser4;
float fuser1;
float fuser2;
float fuser3;
float fuser4;
Vector vuser1;
Vector vuser2;
Vector vuser3;
Vector vuser4;
2013-08-30 13:34:05 -07:00
// world state
// Number of entities to clip against.
int numphysent;
physent_t physents[MAX_PHYSENTS];
2013-08-30 13:34:05 -07:00
// Number of momvement entities (ladders)
int nummoveent;
2013-08-30 13:34:05 -07:00
// just a list of ladders
physent_t moveents[MAX_MOVEENTS];
2013-08-30 13:34:05 -07:00
// All things being rendered, for tracing against things you don't actually collide with
int numvisent;
physent_t visents[MAX_PHYSENTS];
2013-08-30 13:34:05 -07:00
// input to run through physics.
usercmd_t cmd;
2013-08-30 13:34:05 -07:00
// Trace results for objects we collided with.
int numtouch;
pmtrace_t touchindex[MAX_PHYSENTS];
char physinfo[MAX_PHYSINFO_STRING]; // Physics info string
2013-08-30 13:34:05 -07:00
struct movevars_s* movevars;
Vector player_mins[4];
Vector player_maxs[4];
2013-08-30 13:34:05 -07:00
// Common functions
const char* (*PM_Info_ValueForKey)(const char* s, const char* key);
void (*PM_Particle)(float* origin, int color, float life, int zpos, int zvel);
int (*PM_TestPlayerPosition)(float* pos, pmtrace_t* ptrace);
void (*Con_NPrintf)(int idx, const char* fmt, ...);
void (*Con_DPrintf)(const char* fmt, ...);
void (*Con_Printf)(const char* fmt, ...);
double (*Sys_FloatTime)();
void (*PM_StuckTouch)(int hitent, pmtrace_t* ptraceresult);
int (*PM_PointContents)(float* p, int* truecontents /*filled in if this is non-null*/);
int (*PM_TruePointContents)(float* p);
int (*PM_HullPointContents)(struct hull_s* hull, int num, float* p);
pmtrace_t (*PM_PlayerTrace)(float* start, float* end, int traceFlags, int ignore_pe);
struct pmtrace_s* (*PM_TraceLine)(float* start, float* end, int flags, int usehulll, int ignore_pe);
int32 (*RandomLong)(int32 lLow, int32 lHigh);
float (*RandomFloat)(float flLow, float flHigh);
int (*PM_GetModelType)(model_t* mod);
void (*PM_GetModelBounds)(model_t* mod, float* mins, float* maxs);
void* (*PM_HullForBsp)(physent_t* pe, float* offset);
float (*PM_TraceModel)(physent_t* pEnt, const float* start, const float* end, trace_t* trace);
int (*COM_FileSize)(const char* filename);
byte* (*COM_LoadFile)(const char* path, int usehunk, int* pLength);
void (*COM_FreeFile)(void* buffer);
char* (*memfgets)(byte* pMemFile, int fileSize, int* pFilePos, char* pBuffer, int bufferSize);
2013-08-30 13:34:05 -07:00
// Functions
// Run functions for this frame?
qboolean runfuncs;
void (*PM_PlaySound)(int channel, const char* sample, float volume, float attenuation, int fFlags, int pitch);
const char* (*PM_TraceTexture)(int ground, float* vstart, float* vend);
void (*PM_PlaybackEventFull)(int flags, int clientindex, unsigned short eventindex, float delay, float* origin, float* angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
pmtrace_t (*PM_PlayerTraceEx)(float* start, float* end, int traceFlags, int (*pfnIgnore)(physent_t* pe));
int (*PM_TestPlayerPositionEx)(float* pos, pmtrace_t* ptrace, int (*pfnIgnore)(physent_t* pe));
struct pmtrace_s* (*PM_TraceLineEx)(float* start, float* end, int flags, int usehulll, int (*pfnIgnore)(physent_t* pe));
2013-08-30 13:34:05 -07:00
} playermove_t;