Skip to content

Commit

Permalink
Refactor: All map coordinates are now represented as double floating-…
Browse files Browse the repository at this point in the history
…point

Part 3 of 6 - libdoom
  • Loading branch information
danij-deng committed Apr 19, 2012
1 parent 8d11ff7 commit 7280cb7
Show file tree
Hide file tree
Showing 19 changed files with 450 additions and 501 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/include/d_config.h
Expand Up @@ -157,7 +157,7 @@ typedef struct jdoom_config_s {
byte anyBossDeath;
byte monstersStuckInDoors;
byte avoidDropoffs;
byte moveBlock; // Dont handle large negative movement in P_TryMove.
byte moveBlock; // Dont handle large negative movement in P_TryMoveXY.
byte wallRunNorthOnly; // If handle large make exception for wallrunning
byte zombiesCanExit; // Zombie players can exit levels.
byte fallOff; // Objects fall under their own weight.
Expand Down
10 changes: 5 additions & 5 deletions doomsday/plugins/jdoom/include/d_player.h
Expand Up @@ -106,11 +106,11 @@ typedef struct player_s {
boolean centering; // The player's view pitch is centering back to zero.
int update, startSpot;

float viewOffset[3]; // Relative to position of the player mobj.
float viewZ; // Focal origin above r.z.
float viewHeight; // Base height above floor for viewZ.
float viewHeightDelta;
float bob; // Bounded/scaled total momentum.
coord_t viewOffset[3]; // Relative to position of the player mobj.
coord_t viewZ; // Focal origin above r.z.
coord_t viewHeight; // Base height above floor for viewZ.
coord_t viewHeightDelta;
coord_t bob; // Bounded/scaled total momentum.

// Target view to a mobj (NULL=disabled):
mobj_t* viewLock; // $democam
Expand Down
47 changes: 24 additions & 23 deletions doomsday/plugins/jdoom/include/p_mobj.h
Expand Up @@ -34,21 +34,22 @@
# error "Using jDoom headers without __JDOOM__"
#endif

#include "dd_types.h"
#include "d_think.h"
#include "p_terraintype.h"
#include "doomdata.h"
#include "info.h"
#include "tables.h"

#define NOMOM_THRESHOLD (0.00000001f) // (integer) 0
#define DROPOFFMOM_THRESHOLD (0.25f) // FRACUNIT/4
#define NOMOM_THRESHOLD (0.0001) // (integer) 0
#define DROPOFFMOM_THRESHOLD (0.25) // FRACUNIT/4
#define MAXMOM (30) // 30*FRACUNIT
#define MAXMOMSTEP (15) // 30*FRACUNIT/2

#define FRICTION_LOW (0.97265625f) // 0xf900
#define FRICTION_FLY (0.91796875f) // 0xeb00
#define FRICTION_NORMAL (0.90625000f) // 0xe800
#define FRICTION_HIGH (0.41992187f) // 0xd700/2
#define FRICTION_LOW (0.97265625) // 0xf900
#define FRICTION_FLY (0.91796875) // 0xeb00
#define FRICTION_NORMAL (0.90625000) // 0xe800
#define FRICTION_HIGH (0.41992187) // 0xd700/2

/**
* Mobj flags
Expand Down Expand Up @@ -187,33 +188,33 @@ typedef struct mobj_s {

// Thing being chased/attacked (or NULL),
// also the originator for missiles.
struct mobj_s *target;
struct mobj_s* target;

// If >0, the target will be chased
// no matter what (even if shot)
int threshold;

int intFlags; // internal flags
float dropOffZ; // $dropoff_fix
coord_t dropOffZ; // $dropoff_fix
short gear; // used in torque simulation
boolean wallRun; // true = last move was the result of a wallrun

// Additional info record for player avatars only.
// Only valid if type == MT_PLAYER
struct player_s *player;
struct player_s* player;

// Player number last looked for.
int lastLook;

// For nightmare/multiplayer respawn.
struct {
float pos[3];
coord_t origin[3];
angle_t angle;
int flags; // MSF_* flags
} spawnSpot;

// Thing being chased/attacked for tracers.
struct mobj_s *tracer;
struct mobj_s* tracer;

int turnTime; // $visangle-facetarget
int corpseTics; // $vanish: how long has this been dead?
Expand All @@ -226,20 +227,20 @@ typedef struct polyobj_s {
// Doom-specific data:
} Polyobj;

mobj_t* P_SpawnMobj3f(mobjtype_t type, float x, float y, float z,
angle_t angle, int spawnFlags);
mobj_t* P_SpawnMobj3fv(mobjtype_t type, const float pos[3],
angle_t angle, int spawnFlags);
mobj_t* P_SpawnMobjXYZ(mobjtype_t type, coord_t x, coord_t y, coord_t z, angle_t angle, int spawnFlags);
mobj_t* P_SpawnMobj(mobjtype_t type, coord_t const pos[3], angle_t angle, int spawnFlags);

mobj_t* P_SpawnCustomPuff(mobjtype_t type, float x, float y, float z,
angle_t angle);
mobj_t* P_SpawnMissile(mobjtype_t type, mobj_t* source, mobj_t* dest);
void P_SpawnPuff(float x, float y, float z, angle_t angle);
void P_SpawnBlood(float x, float y, float z, int damage,
angle_t angle);
mobj_t* P_SpawnTeleFog(float x, float y, angle_t angle);
mobj_t* P_SpawnCustomPuff(mobjtype_t type, coord_t x, coord_t y, coord_t z, angle_t angle);
mobj_t* P_SpawnMissile(mobjtype_t type, mobj_t* source, mobj_t* dest);

void P_SpawnPuff(coord_t x, coord_t y, coord_t z, angle_t angle);

void P_SpawnBlood(coord_t x, coord_t y, coord_t z, int damage, angle_t angle);

mobj_t* P_SpawnTeleFog(coord_t x, coord_t y, angle_t angle);

const terraintype_t* P_MobjGetFloorTerrainType(mobj_t* mo);
float P_MobjGetFriction(mobj_t *mo);

coord_t P_MobjGetFriction(mobj_t* mo);

#endif
8 changes: 4 additions & 4 deletions doomsday/plugins/jdoom/include/p_spec.h
Expand Up @@ -72,12 +72,12 @@ typedef enum {
pastdest
} result_e;

result_e T_MovePlane(Sector* sector, float speed, float dest,
int crush, int floorOrCeiling, int direction);
result_e T_MovePlane(Sector* sector, float speed, coord_t dest, int crush,
int floorOrCeiling, int direction);


int EV_BuildStairs(LineDef* line, stair_e type);
int EV_BuildStairs(LineDef* line, stair_e type);

boolean P_UseSpecialLine2(mobj_t* mo, LineDef* line, int side);
boolean P_UseSpecialLine2(mobj_t* mo, LineDef* line, int side);

#endif
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/include/r_defs.h
Expand Up @@ -62,7 +62,7 @@ typedef struct xsector_s {
byte seqType; // NOT USED ATM

struct {
float origHeight;
coord_t origHeight;
} planes[2]; // {floor, ceiling}

float origLight;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jdoom/include/st_stuff.h
Expand Up @@ -118,9 +118,9 @@ float ST_AutomapOpacity(int player);
boolean ST_AutomapObscures2(int player, const RectRaw* region);
boolean ST_AutomapObscures(int player, int x, int y, int width, int height);

int ST_AutomapAddPoint(int player, float x, float y, float z);
int ST_AutomapAddPoint(int player, coord_t x, coord_t y, coord_t z);
void ST_AutomapClearPoints(int player);
boolean ST_AutomapPointOrigin(int player, int point, float* x, float* y, float* z);
boolean ST_AutomapPointOrigin(int player, int point, coord_t* x, coord_t* y, coord_t* z);

void ST_SetAutomapCameraRotation(int player, boolean on);

Expand Down
6 changes: 3 additions & 3 deletions doomsday/plugins/jdoom/src/d_api.c
Expand Up @@ -234,9 +234,9 @@ game_export_t* GetGameAPI(game_import_t* imports)
gx.Responder = G_Responder;
gx.EndFrame = D_EndFrame;
gx.MobjThinker = P_MobjThinker;
gx.MobjFriction = (float (*)(void *)) P_MobjGetFriction;
gx.MobjCheckPosition3f = P_CheckPosition3f;
gx.MobjTryMove3f = P_TryMove3f;
gx.MobjFriction = (coord_t (*)(void *)) P_MobjGetFriction;
gx.MobjCheckPositionXYZ = P_CheckPositionXYZ;
gx.MobjTryMoveXYZ = P_TryMoveXYZ;
gx.SectorHeightChangeNotification = P_HandleSectorHeightChange;
gx.UpdateState = G_UpdateState;
gx.GetInteger = D_GetInteger;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/jdoom/src/d_console.c
Expand Up @@ -87,7 +87,7 @@ cvartemplate_t gameCVars[] = {
// Items
{"server-game-nobfg", 0, CVT_BYTE, &cfg.noNetBFG, 0, 1},
#if 0
{"server-game-coop-nothing", 0, CVT_BYTE, &cfg.noCoopAnything, 0, 1}, // not implemented atm, see P_SpawnMobj3f
{"server-game-coop-nothing", 0, CVT_BYTE, &cfg.noCoopAnything, 0, 1}, // not implemented atm, see P_SpawnMobjXYZ
#endif
{"server-game-coop-respawn-items", 0, CVT_BYTE,
&cfg.coopRespawnItems, 0, 1},
Expand Down
14 changes: 7 additions & 7 deletions doomsday/plugins/jdoom/src/m_cheat.c
Expand Up @@ -521,9 +521,9 @@ int Cht_MyPosFunc(const int* args, int player)

sprintf(buf, "ang=0x%x;x,y,z=(%g,%g,%g)",
players[CONSOLEPLAYER].plr->mo->angle,
players[CONSOLEPLAYER].plr->mo->pos[VX],
players[CONSOLEPLAYER].plr->mo->pos[VY],
players[CONSOLEPLAYER].plr->mo->pos[VZ]);
players[CONSOLEPLAYER].plr->mo->origin[VX],
players[CONSOLEPLAYER].plr->mo->origin[VY],
players[CONSOLEPLAYER].plr->mo->origin[VZ]);
P_SetMessage(plr, buf, false);
return true;
}
Expand All @@ -541,8 +541,8 @@ static void printDebugInfo(player_t* plr)
mapUri = G_ComposeMapUri(gameEpisode, gameMap);
mapPath = Uri_ToString(mapUri);
sprintf(textBuffer, "MAP [%s] X:%g Y:%g Z:%g",
Str_Text(mapPath), plr->plr->mo->pos[VX], plr->plr->mo->pos[VY],
plr->plr->mo->pos[VZ]);
Str_Text(mapPath), plr->plr->mo->origin[VX], plr->plr->mo->origin[VY],
plr->plr->mo->origin[VZ]);
P_SetMessage(plr, textBuffer, false);
Str_Delete(mapPath);
Uri_Delete(mapUri);
Expand All @@ -554,13 +554,13 @@ static void printDebugInfo(player_t* plr)

uri = Materials_ComposeUri(P_GetIntp(sub, DMU_FLOOR_MATERIAL));
path = Uri_ToString(uri);
Con_Message(" FloorZ:%g Material:%s\n", P_GetFloatp(sub, DMU_FLOOR_HEIGHT), Str_Text(path));
Con_Message(" FloorZ:%g Material:%s\n", P_GetDoublep(sub, DMU_FLOOR_HEIGHT), Str_Text(path));
Str_Delete(path);
Uri_Delete(uri);

uri = Materials_ComposeUri(P_GetIntp(sub, DMU_CEILING_MATERIAL));
path = Uri_ToString(uri);
Con_Message(" CeilingZ:%g Material:%s\n", P_GetFloatp(sub, DMU_CEILING_HEIGHT), Str_Text(path));
Con_Message(" CeilingZ:%g Material:%s\n", P_GetDoublep(sub, DMU_CEILING_HEIGHT), Str_Text(path));
Str_Delete(path);
Uri_Delete(uri);

Expand Down

0 comments on commit 7280cb7

Please sign in to comment.