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 5 of 6 - libheretic
  • Loading branch information
danij-deng committed Apr 19, 2012
1 parent 681811a commit 1aa62e6
Show file tree
Hide file tree
Showing 17 changed files with 786 additions and 834 deletions.
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/h_config.h
Expand Up @@ -154,7 +154,7 @@ typedef struct jheretic_config_s {
*/
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 fallOff; // Objects fall under their own weight.
Expand Down
4 changes: 1 addition & 3 deletions doomsday/plugins/jheretic/include/p_local.h
Expand Up @@ -104,20 +104,18 @@ void P_PostMorphWeapon(player_t* player, weapontype_t weapon);
void P_UpdateBeak(player_t* player, pspdef_t* psp);
void P_FireWeapon(player_t* player);

void P_Thrust(player_t* player, angle_t angle, float move);
boolean P_UndoPlayerMorph(player_t* player);

extern mobjtype_t puffType;
extern mobj_t* missileMobj;

boolean P_MobjChangeState(mobj_t* mo, statenum_t state);
boolean P_SetMobjStateNF(mobj_t* mo, statenum_t state);
void P_ThrustMobj(mobj_t* mo, angle_t angle, float move);
void P_ThrustMobj(mobj_t* mo, angle_t angle, coord_t move);
void P_WindThrust(mobj_t* mo);
int P_FaceMobj(mobj_t* source, mobj_t* target, angle_t* delta);
boolean P_SeekerMissile(mobj_t* actor, angle_t thresh, angle_t turnMax);
void P_MobjThinker(mobj_t* mo);
void P_SpawnBloodSplatter(float x, float y, float z, mobj_t* originator);
void P_RipperBlood(mobj_t* mo);
boolean P_HitFloor(mobj_t* thing);
boolean P_CheckMissileSpawn(mobj_t* missile);
Expand Down
83 changes: 53 additions & 30 deletions doomsday/plugins/jheretic/include/p_mobj.h
@@ -1,4 +1,4 @@
/**\file
/**\file p_mobj.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
Expand All @@ -24,11 +24,11 @@
*/

/**
* p_mobj.h: Map Objects, MObj, definition and handling.
* Map Objects, MObj, definition and handling.
*/

#ifndef __P_MOBJ_H__
#define __P_MOBJ_H__
#ifndef LIBHERETIC_P_MOBJ_H
#define LIBHERETIC_P_MOBJ_H

#ifndef __JHERETIC__
# error "Using jHeretic headers without __JHERETIC__"
Expand All @@ -38,15 +38,15 @@
#include "h_think.h"
#include "info.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,14 +187,14 @@ typedef struct mobj_s {
int special3; // Special info
int moveDir; // 0-7
int moveCount; // when 0, select a new dir
struct mobj_s *target; // thing being chased/attacked (or NULL)
struct mobj_s* target; // thing being chased/attacked (or NULL)
// also the originator for missiles
// used by player to freeze a bit after
// teleporting
int threshold; // if >0, the target will be chased

int intFlags; // $dropoff_fix: 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

Expand All @@ -204,16 +204,16 @@ typedef struct mobj_s {

// 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;

// Used for pod generating.
struct mobj_s *generator;
struct mobj_s* generator;

int turnTime; // $visangle-facetarget
int corpseTics; // $vanish: how long has this been dead?
Expand All @@ -226,21 +226,44 @@ typedef struct polyobj_s {
// Heretic-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);

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_SpawnMissile(mobjtype_t type, mobj_t* source, mobj_t* dest,
boolean checkSpawn);
mobj_t* P_SpawnMissileAngle(mobjtype_t type, mobj_t *source,
angle_t angle, float momz);
mobj_t* P_SpawnTeleFog(float x, float y, angle_t angle);
void P_SpawnPuff(coord_t x, coord_t y, coord_t z, angle_t angle);

const terraintype_t* P_MobjGetFloorTerrainType(mobj_t *thing);
float P_MobjGetFriction(mobj_t *mo);
void P_SpawnBlood(coord_t x, coord_t y, coord_t z, int damage, angle_t angle);
void P_SpawnBloodSplatter(coord_t x, coord_t y, coord_t z, mobj_t* originator);

#endif
/**
* Tries to aim at a nearby monster if source is a player. Else aim is
* taken at dest.
*
* @param source The mobj doing the shooting.
* @param dest The mobj being shot at. Can be @c NULL if source
* is a player.
* @param type The type of mobj to be shot.
* @param checkSpawn @c true call P_CheckMissileSpawn.
*
* @return Pointer to the newly spawned missile.
*/
mobj_t* P_SpawnMissile(mobjtype_t type, mobj_t* source, mobj_t* dest, boolean checkSpawn);

/**
* Tries to aim at a nearby monster if 'source' is a player. Else aim is
* the angle of the source mobj. Z angle is specified with momZ.
*
* @param type The type of mobj to be shot.
* @param source The mobj doing the shooting.
* @param angle The X/Y angle to shoot the missile in.
* @param momZ The Z momentum of the missile to be spawned.
*
* @return Pointer to the newly spawned missile.
*/
mobj_t* P_SpawnMissileAngle(mobjtype_t type, mobj_t* source, angle_t angle, coord_t momz);

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

const terraintype_t* P_MobjGetFloorTerrainType(mobj_t* mobj);
coord_t P_MobjGetFriction(mobj_t* mobj);

#endif /// LIBHERETIC_P_MOBJ_H
2 changes: 1 addition & 1 deletion doomsday/plugins/jheretic/include/p_spec.h
Expand Up @@ -80,7 +80,7 @@ typedef enum {
build16 // Slowly build by 16.
} stair_e;

result_e T_MovePlane(Sector* sector, float speed, float dest,
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);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/plugins/jheretic/include/st_stuff.h
Expand Up @@ -117,9 +117,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/jheretic/src/h_api.c
Expand Up @@ -187,9 +187,9 @@ game_export_t* GetGameAPI(game_import_t* imports)
gx.Responder = G_Responder;
gx.EndFrame = H_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;

Expand Down
8 changes: 4 additions & 4 deletions doomsday/plugins/jheretic/src/m_cheat.c
Expand Up @@ -384,8 +384,8 @@ static void printDebugInfo(int player)
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);
Uri_Delete(mapUri);

Expand All @@ -396,13 +396,13 @@ static void printDebugInfo(int player)

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 1aa62e6

Please sign in to comment.