Skip to content

Commit

Permalink
Fixed bug #2159521: Polyobjs completely missing under *nix. Yet again…
Browse files Browse the repository at this point in the history
…, this is due to the fact that public symbols are shared between engine and game libraries. As both the engine and jHexen had a PO_InitForMap, the game was actually calling the engine's copy and not it's own. We should try to do something about this as it is a recurring problem.

Also did some cleaning up.
  • Loading branch information
danij committed Dec 9, 2008
1 parent fe9f3a1 commit 80cde06
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 55 deletions.
10 changes: 5 additions & 5 deletions doomsday/engine/api/doomsday.def
Expand Up @@ -289,17 +289,17 @@ EXPORTS
P_PolyobjLink @82 NONAME
P_PolyobjUnLink @81 NONAME

PO_GetPolyobj @424 NONAME
PO_SetCallback @83 NONAME
P_GetPolyobj @424 NONAME
P_SetPolyobjCallback @83 NONAME

; Play: Thinkers.
P_ThinkerAdd @86 NONAME
P_ThinkerRemove @87 NONAME
P_ThinkerSetStasis @426 NONAME
P_ThinkerSetStasis @426 NONAME

P_RunThinkers @84 NONAME
P_InitThinkers @85 NONAME
P_IterateThinkers @425 NONAME
P_IterateThinkers @425 NONAME

; Refresh.
DD_GetFrameRate @88 NONAME
Expand All @@ -314,7 +314,7 @@ EXPORTS
R_SetBorderGfx @93 NONAME
R_GetSpriteInfo @94 NONAME
R_GetPatchInfo @237 NONAME
R_MaterialGetInfo @427 NONAME
R_MaterialGetInfo @427 NONAME
R_MaterialIsCustom @349 NONAME
R_MaterialCheckNumForName @336 NONAME
R_MaterialNameForNum @337 NONAME
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -375,8 +375,8 @@ extern "C" {
void P_PolyobjLink(struct polyobj_s* po);
void P_PolyobjUnLink(struct polyobj_s* po);

struct polyobj_s* PO_GetPolyobj(uint num);
void PO_SetCallback(void (*func)(struct mobj_s*, void*, void*));
struct polyobj_s* P_GetPolyobj(uint num);
void P_SetPolyobjCallback(void (*func)(struct mobj_s*, void*, void*));

// Play: Thinkers.
void P_ThinkerAdd(thinker_t* th);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/p_polyob.h
Expand Up @@ -39,11 +39,11 @@ extern polyobj_t** polyObjs; // List of all poly-objects on the map.
extern uint numPolyObjs;

// Polyobj system.
void PO_InitForMap(void);
void PO_SetCallback(void (*func) (struct mobj_s*, void*, void*));
void P_MapInitPolyobjs(void);
void P_SetPolyobjCallback(void (*func) (struct mobj_s*, void*, void*));

polyobj_t* PO_GetPolyobj(uint num);
polyobj_t* PO_GetPolyobjForDegen(void *degenMobj);
polyobj_t* P_GetPolyobj(uint num);
polyobj_t* P_GetPolyobjForDegen(void *degenMobj);

// Polyobject interface.
boolean P_PolyobjMove(struct polyobj_s* po, float x, float y);
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/cl_world.c
Expand Up @@ -296,7 +296,7 @@ void Cl_PolyMoverThinker(polymover_t *mover)
}

// Do the move.
P_PolyobjMove(PO_GetPolyobj(mover->number | 0x80000000), dx, dy);
P_PolyobjMove(P_GetPolyobj(mover->number | 0x80000000), dx, dy);
}

if(mover->rotate)
Expand All @@ -315,7 +315,7 @@ void Cl_PolyMoverThinker(polymover_t *mover)
dist = FIX2FLT(poly->angleSpeed);
}

P_PolyobjRotate(PO_GetPolyobj(mover->number | 0x80000000), FLT2FIX(dist));
P_PolyobjRotate(P_GetPolyobj(mover->number | 0x80000000), FLT2FIX(dist));
}

// Can we get rid of this mover?
Expand Down
10 changes: 5 additions & 5 deletions doomsday/engine/portable/src/p_polyob.c
Expand Up @@ -68,7 +68,7 @@ uint numPolyObjs;
/**
* The po_callback is called when a polyobj hits a mobj.
*/
void PO_SetCallback(void (*func) (struct mobj_s*, void*, void*))
void P_SetPolyobjCallback(void (*func) (struct mobj_s*, void*, void*))
{
po_callback = func;
}
Expand All @@ -79,7 +79,7 @@ void PO_SetCallback(void (*func) (struct mobj_s*, void*, void*))
* @param num If MSB is set, treat num as an index, ELSE
* num is a tag that *should* match one polyobj.
*/
polyobj_t* PO_GetPolyobj(uint num)
polyobj_t* P_GetPolyobj(uint num)
{
if(num & 0x80000000)
{
Expand Down Expand Up @@ -110,7 +110,7 @@ polyobj_t* PO_GetPolyobj(uint num)
* @returns Ptr to the polyobj that owns the degenmobj,
* else @c NULL.
*/
polyobj_t* PO_GetPolyobjForDegen(void* degenMobj)
polyobj_t* P_GetPolyobjForDegen(void* degenMobj)
{
uint i;
polyobj_t* po;
Expand Down Expand Up @@ -192,7 +192,7 @@ void P_PolyobjUpdateBBox(polyobj_t* po)
* Called at the start of the map after all the structures needed for
* refresh have been setup.
*/
void PO_InitForMap(void)
void P_MapInitPolyobjs(void)
{
uint i;

Expand Down Expand Up @@ -239,7 +239,7 @@ void PO_InitForMap(void)
{
if(ssec->polyObj)
{
Con_Message("PO_InitForMap: Warning: Multiple polyobjs in a single subsector\n"
Con_Message("P_MapInitPolyobjs: Warning: Multiple polyobjs in a single subsector\n"
" (ssec %i, sector %i). Previous polyobj overridden.\n",
GET_SUBSECTOR_IDX(ssec), GET_SECTOR_IDX(ssec->sector));
}
Expand Down
6 changes: 2 additions & 4 deletions doomsday/engine/portable/src/r_world.c
Expand Up @@ -1649,8 +1649,7 @@ void R_SetupMap(int mode, int flags)
initSurfaceMaterialOffset(&si->SW_bottomsurface);
}

// We don't render fakeradio on polyobjects...
PO_InitForMap();
P_MapInitPolyobjs();
return;
}
case DDSMM_FINALIZE:
Expand Down Expand Up @@ -1694,8 +1693,7 @@ void R_SetupMap(int mode, int flags)
initSurfaceMaterialOffset(&si->SW_bottomsurface);
}

// We don't render fakeradio on polyobjects...
PO_InitForMap();
P_MapInitPolyobjs();

// Run any commands specified in Map Info.
{
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/sv_sound.c
Expand Up @@ -74,7 +74,7 @@ static void Sv_IdentifySoundOrigin(mobj_t **origin, sector_t **sector,
{
// No mobj ID => it's not a real mobj.

if((*poly = PO_GetPolyobjForDegen(*origin)) == NULL)
if((*poly = P_GetPolyobjForDegen(*origin)) == NULL)
{
// It wasn't a polyobj degenmobj, try the sectors instead.
*sector = R_GetSectorForDegen(*origin);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/plugins/common/src/p_saveg.c
Expand Up @@ -2664,7 +2664,7 @@ static int SV_ReadPolyObj(void)
if(saveVersion >= 3)
ver = SV_ReadByte();

po = PO_GetPolyobj(SV_ReadLong()); // Get polyobj by tag.
po = P_GetPolyobj(SV_ReadLong()); // Get polyobj by tag.
if(!po)
Con_Error("UnarchivePolyobjs: Invalid polyobj tag");

Expand Down Expand Up @@ -2702,7 +2702,7 @@ static void P_ArchiveWorld(void)
SV_BeginSegment(ASEG_POLYOBJS);
SV_WriteLong(numpolyobjs);
for(i = 0; i < numpolyobjs; ++i)
SV_WritePolyObj(PO_GetPolyobj(i | 0x80000000));
SV_WritePolyObj(P_GetPolyobj(i | 0x80000000));
#endif
}

Expand Down Expand Up @@ -4343,7 +4343,7 @@ static void P_ArchiveSounds(void)
SV_WriteLong(node->currentSoundID);
for(i = 0; i < numpolyobjs; ++i)
{
polyobj_t* po = PO_GetPolyobj(i | 0x80000000);
polyobj_t* po = P_GetPolyobj(i | 0x80000000);

if(po && node->mobj == (mobj_t*) &po->startSpot)
{
Expand Down Expand Up @@ -4399,7 +4399,7 @@ static void P_UnArchiveSounds(void)
}
else
{
polyobj_t* po = PO_GetPolyobj(secNum | 0x80000000);
polyobj_t* po = P_GetPolyobj(secNum | 0x80000000);

if(po)
sndMobj = (mobj_t*) &po->startSpot;
Expand Down
36 changes: 18 additions & 18 deletions doomsday/plugins/jhexen/src/po_man.c
Expand Up @@ -76,7 +76,7 @@ void PO_SetDestination(polyobj_t *po, float dist, uint an, float speed)
void T_RotatePoly(polyevent_t* pe)
{
unsigned int absSpeed;
polyobj_t* po = PO_GetPolyobj(pe->polyobj);
polyobj_t* po = P_GetPolyobj(pe->polyobj);

if(P_PolyobjRotate(po, pe->intSpeed))
{
Expand Down Expand Up @@ -114,7 +114,7 @@ boolean EV_RotatePoly(linedef_t *line, byte *args, int direction,
polyobj_t* po;

polyNum = args[0];
po = PO_GetPolyobj(polyNum);
po = P_GetPolyobj(polyNum);
if(po)
{
if(po->specialData && !overRide)
Expand Down Expand Up @@ -159,7 +159,7 @@ boolean EV_RotatePoly(linedef_t *line, byte *args, int direction,

while((mirror = getPolyobjMirror(polyNum)) != 0)
{
po = PO_GetPolyobj(mirror);
po = P_GetPolyobj(mirror);
if(po && po->specialData && !overRide)
{ // Mirroring po is already in motion.
break;
Expand Down Expand Up @@ -192,7 +192,7 @@ boolean EV_RotatePoly(linedef_t *line, byte *args, int direction,
pe->intSpeed = (args[1] * direction * (ANGLE_90 / 64)) >> 3;
po->angleSpeed = pe->intSpeed;

po = PO_GetPolyobj(polyNum);
po = P_GetPolyobj(polyNum);
if(po)
{
po->specialData = pe;
Expand All @@ -211,7 +211,7 @@ boolean EV_RotatePoly(linedef_t *line, byte *args, int direction,
void T_MovePoly(polyevent_t* pe)
{
unsigned int absSpeed;
polyobj_t* po = PO_GetPolyobj(pe->polyobj);
polyobj_t* po = P_GetPolyobj(pe->polyobj);

if(P_PolyobjMove(po, pe->speed[MX], pe->speed[MY]))
{
Expand Down Expand Up @@ -246,7 +246,7 @@ boolean EV_MovePoly(linedef_t* line, byte* args, boolean timesEight,
angle_t angle;

polyNum = args[0];
po = PO_GetPolyobj(polyNum);
po = P_GetPolyobj(polyNum);
if(po)
{
if(po->specialData && !overRide)
Expand Down Expand Up @@ -285,7 +285,7 @@ boolean EV_MovePoly(linedef_t* line, byte* args, boolean timesEight,

while((mirror = getPolyobjMirror(polyNum)) != 0)
{
po = PO_GetPolyobj(mirror);
po = P_GetPolyobj(mirror);
if(po && po->specialData && !overRide)
{ // mirroring po is already in motion
break;
Expand Down Expand Up @@ -320,7 +320,7 @@ boolean EV_MovePoly(linedef_t* line, byte* args, boolean timesEight,
void T_PolyDoor(polydoor_t* pd)
{
int absSpeed;
polyobj_t* po = PO_GetPolyobj(pd->polyobj);
polyobj_t* po = P_GetPolyobj(pd->polyobj);

if(pd->tics)
{
Expand All @@ -329,7 +329,7 @@ void T_PolyDoor(polydoor_t* pd)
PO_StartSequence(po, SEQ_DOOR_STONE);

// Movement is about to begin. Update the destination.
PO_SetDestination(PO_GetPolyobj(pd->polyobj), FIX2FLT(pd->dist),
PO_SetDestination(P_GetPolyobj(pd->polyobj), FIX2FLT(pd->dist),
pd->direction, FIX2FLT(pd->intSpeed));
}
return;
Expand Down Expand Up @@ -379,7 +379,7 @@ void T_PolyDoor(polydoor_t* pd)
pd->speed[MX] = -pd->speed[MX];
pd->speed[MY] = -pd->speed[MY];
// Update destination.
PO_SetDestination(PO_GetPolyobj(pd->polyobj), FIX2FLT(pd->dist),
PO_SetDestination(P_GetPolyobj(pd->polyobj), FIX2FLT(pd->dist),
pd->direction, FIX2FLT(pd->intSpeed));
pd->close = false;
PO_StartSequence(po, SEQ_DOOR_STONE);
Expand Down Expand Up @@ -446,7 +446,7 @@ boolean EV_OpenPolyDoor(linedef_t* line, byte* args, podoortype_t type)
angle_t angle = 0;

polyNum = args[0];
po = PO_GetPolyobj(polyNum);
po = P_GetPolyobj(polyNum);
if(po)
{
if(po->specialData)
Expand Down Expand Up @@ -491,7 +491,7 @@ boolean EV_OpenPolyDoor(linedef_t* line, byte* args, podoortype_t type)

while((mirror = getPolyobjMirror(polyNum)) != 0)
{
po = PO_GetPolyobj(mirror);
po = P_GetPolyobj(mirror);
if(po && po->specialData)
{ // Mirroring po is already in motion.
break;
Expand Down Expand Up @@ -539,7 +539,7 @@ static int getPolyobjMirror(uint poly)

for(i = 0; i < numpolyobjs; ++i)
{
polyobj_t* po = PO_GetPolyobj(i | 0x80000000);
polyobj_t* po = P_GetPolyobj(i | 0x80000000);

if(po->tag == poly)
{
Expand Down Expand Up @@ -622,17 +622,17 @@ void PO_InitForMap(void)
{
uint i;

Con_Message("PO_Init: Initializing polyobjects.\n");
Con_Message("PO_InitForMap: Initializing polyobjects.\n");

// thrustMobj will handle polyobj <-> mobj interaction.
PO_SetCallback(thrustMobj);
P_SetPolyobjCallback(thrustMobj);
for(i = 0; i < numpolyobjs; ++i)
{
uint j;
spawnspot_t* mt;
polyobj_t* po;

po = PO_GetPolyobj(i | 0x80000000);
po = P_GetPolyobj(i | 0x80000000);

// Init game-specific properties.
po->specialData = NULL;
Expand Down Expand Up @@ -662,14 +662,14 @@ void PO_InitForMap(void)
}
else
{
Con_Message("PO_Init: Warning, missing spawnspot for poly %i.", i);
Con_Message("PO_InitForMap: Warning, missing spawnspot for poly %i.", i);
}
}
}

boolean PO_Busy(int polyobj)
{
polyobj_t* po = PO_GetPolyobj(polyobj);
polyobj_t* po = P_GetPolyobj(polyobj);

if(po && po->specialData != NULL)
return true;
Expand Down

0 comments on commit 80cde06

Please sign in to comment.