Skip to content

Commit

Permalink
API: Removed 'sprNames' table from InternalData
Browse files Browse the repository at this point in the history
None of the current game plugins currently access this data so lets
not export it. Bumped DE_API_INTERNAL_DATA to ver 2.

Todo: Doomsday should automatically generate Sprite definitions from
the sprite frame resources in WAD files (similarly to Materials), if
placed and named according to id Tech 1 conventions. Game plugins and
Doomsday Scripts will be able to access the definitions via the Defs
database. Authors will be able to define new Sprites and/or modify
the IWAD originals using .ded files.

If necessary, ResourceSystem could build a runtime representation of
this data for use with the renderer (probably won't be; most of the
relevant selection logic can be encapsulated in a new defn::Sprite
accessor and asset/resource caching is handled at another level).
  • Loading branch information
danij-deng committed Jul 7, 2015
1 parent 6a57c3f commit 3ad2ec0
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 48 deletions.
49 changes: 24 additions & 25 deletions doomsday/apps/api/api_gameexport.h
@@ -1,8 +1,7 @@
/** @file api_gameexport.h
* Data structures for the engine/plugin interfaces.
/** @file api_gameexport.h Data structures for the engine/plugin interfaces.
*
* @authors Copyright &copy; 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2006-2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -49,19 +48,19 @@ typedef struct {
int (*NetServerStop) (int before);
int (*NetConnect) (int before);
int (*NetDisconnect) (int before);
long int (*NetPlayerEvent) (int playernum, int type, void* data);
int (*NetWorldEvent) (int type, int parm, void* data);
void (*HandlePacket) (int fromplayer, int type, void* data,
long int (*NetPlayerEvent) (int playernum, int type, void *data);
int (*NetWorldEvent) (int type, int parm, void *data);
void (*HandlePacket) (int fromplayer, int type, void *data,
size_t length);

// Tickers.
void (*Ticker) (timespan_t ticLength);

// Responders.
int (*FinaleResponder) (const void* ddev);
int (*PrivilegedResponder) (event_t* ev);
int (*Responder) (event_t* ev);
int (*FallbackResponder) (event_t* ev);
int (*FinaleResponder) (void const *ddev);
int (*PrivilegedResponder) (event_t *ev);
int (*Responder) (event_t *ev);
int (*FallbackResponder) (event_t *ev);

// Refresh.
void (*BeginFrame) (void);
Expand Down Expand Up @@ -109,27 +108,27 @@ typedef struct {
* - 1: Displays to be drawn on top of view window (after bordering),
* such as the player HUD.
*/
void (*DrawViewPort) (int port, const RectRaw* portGeometry,
const RectRaw* windowGeometry, int player, int layer);
void (*DrawViewPort) (int port, RectRaw const *portGeometry,
RectRaw const *windowGeometry, int player, int layer);

/**
* Draw over-viewport displays covering the whole game window. Typically
* graphical user interfaces such as game menus are done here.
*
* @param windowSize Dimensions of the game window in real screen pixels.
*/
void (*DrawWindow) (const Size2Raw* windowSize);
void (*DrawWindow) (Size2Raw const *windowSize);

// Miscellaneous.
void (*MobjThinker) (void *mobj);
coord_t (*MobjFriction) (struct mobj_s const *mobj); // Returns a friction factor.
dd_bool (*MobjCheckPositionXYZ) (struct mobj_s* mobj, coord_t x, coord_t y, coord_t z);
dd_bool (*MobjTryMoveXYZ) (struct mobj_s* mobj, coord_t x, coord_t y, coord_t z);
void (*SectorHeightChangeNotification)(int sectorIdx); // Applies necessary checks on objects.
coord_t (*MobjFriction) (struct mobj_s const *mobj); // Returns a friction factor.
dd_bool (*MobjCheckPositionXYZ) (struct mobj_s *mobj, coord_t x, coord_t y, coord_t z);
dd_bool (*MobjTryMoveXYZ) (struct mobj_s *mobj, coord_t x, coord_t y, coord_t z);
void (*SectorHeightChangeNotification)(int sectorIdx); // Applies necessary checks on objects.

// Main structure sizes.
size_t mobjSize; // sizeof(mobj_t)
size_t polyobjSize; // sizeof(Polyobj)
size_t mobjSize; ///< sizeof(mobj_t)
size_t polyobjSize; ///< sizeof(Polyobj)

// Map setup

Expand All @@ -149,21 +148,21 @@ typedef struct {
* @return The action code returned by the game depends on the context.
*/
int (*HandleMapDataPropertyValue) (uint id, int dtype, int prop,
valuetype_t type, void* data);
valuetype_t type, void *data);
// Post map setup
/**
* The engine calls this to inform the game of any changes it is
* making to map data object to which the game might want to
* take further action.
*/
int (*HandleMapObjectStatusReport) (int code, uint id, int dtype, void* data);
int (*HandleMapObjectStatusReport) (int code, uint id, int dtype, void *data);
} game_export_t;

/// Function pointer for @c GetGameAPI() (exported by game plugin). @ingroup game
typedef game_export_t* (*GETGAMEAPI) (void);
typedef game_export_t *(*GETGAMEAPI) (void);

#ifdef __cplusplus
} // extern "C"
} // extern "C"
#endif

#endif /* DOOMSDAY_GAME_EXPORT_API_H */
#endif // DOOMSDAY_GAME_EXPORT_API_H
15 changes: 7 additions & 8 deletions doomsday/apps/api/api_internaldata.h
@@ -1,8 +1,8 @@
/** @file api_internaldata.h Public API for accessing the engine's internal data.
/** @file api_internaldata.h Public API for accessing the engine's internal data.
* @ingroup base
*
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2013 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2013-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -34,18 +34,17 @@ DENG_API_TYPEDEF(InternalData)
de_api_t api;

// Data arrays.
mobjinfo_t ** mobjInfo;
state_t ** states;
sprname_t ** sprNames;
ddtext_t ** text;
mobjinfo_t **mobjInfo;
state_t **states;
ddtext_t **text;

// General information.
int * validCount;
int *validCount;
}
DENG_API_T(InternalData);

#ifdef __DOOMSDAY__
DENG_USING_API(InternalData);
#endif

#endif // DOOMSDAY_API_INTERNALDATA_H
#endif // DOOMSDAY_API_INTERNALDATA_H
8 changes: 5 additions & 3 deletions doomsday/apps/api/apis.h
Expand Up @@ -2,6 +2,7 @@
* @ingroup base
*
* @authors Copyright © 2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2014-2015 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down Expand Up @@ -107,7 +108,8 @@ enum {
DE_API_INFINE = DE_API_INFINE_v1,

DE_API_INTERNAL_DATA_v1 = 1000, // 1.10
DE_API_INTERNAL_DATA = DE_API_INTERNAL_DATA_v1,
DE_API_INTERNAL_DATA_v2 = 1001, // 2.0 (removed sprNames)
DE_API_INTERNAL_DATA = DE_API_INTERNAL_DATA_v2,

DE_API_MAP_v1 = 1100, // 1.10
DE_API_MAP_v2 = 1101, // 1.11
Expand Down Expand Up @@ -165,7 +167,7 @@ enum {
* Base structure for API structs.
*/
typedef struct de_api_s {
int id; ///< API identification (including version) number.
int id; ///< API identification (including version) number.
} de_api_t;

#define DENG_API_TYPEDEF(Name) typedef struct de_api_##Name##_s
Expand All @@ -183,4 +185,4 @@ typedef struct de_api_s {
DENG_ASSERT(_api_##Name.api.id == Ident); \
break;

#endif // DOOMSDAY_APIS_H
#endif // DOOMSDAY_APIS_H
4 changes: 2 additions & 2 deletions doomsday/apps/client/include/def_main.h
Expand Up @@ -100,6 +100,7 @@ struct sfxinfo_t
};

extern ded_t defs; ///< Main definitions database (internal).
extern Array<sprname_t> sprNames; ///< Sprite name list.

struct stateinfo_t
{
Expand All @@ -114,7 +115,6 @@ struct stateinfo_t
*/
struct RuntimeDefs
{
Array<sprname_t> sprNames; ///< Sprite name list.
Array<mobjinfo_t> mobjInfo; ///< Map object info database.
Array<state_t> states; ///< State list.
Array<stateinfo_t> stateInfo;
Expand Down Expand Up @@ -182,7 +182,7 @@ ded_compositefont_t *Def_GetCompositeFont(char const *uri);
ded_light_t *Def_GetLightDef(int spr, int frame);

#ifdef __cplusplus
} // extern "C"
} // extern "C"
#endif

de::String Def_GetMobjName(int num);
Expand Down
1 change: 0 additions & 1 deletion doomsday/apps/client/src/dd_pinit.cpp
Expand Up @@ -63,7 +63,6 @@ DENG_DECLARE_API(InternalData) =
{ DE_API_INTERNAL_DATA },
runtimeDefs.mobjInfo.elementsPtr(),
runtimeDefs.states .elementsPtr(),
runtimeDefs.sprNames.elementsPtr(),
runtimeDefs.texts .elementsPtr(),
&validCount
};
Expand Down
19 changes: 11 additions & 8 deletions doomsday/apps/client/src/def_main.cpp
Expand Up @@ -74,7 +74,8 @@ struct actionlink_t
void (*func)(); ///< Pointer to the function.
};

ded_t defs; // The main definitions database.
ded_t defs; ///< The main definitions database.
Array<sprname_t> sprNames; ///< Sprite name list.

RuntimeDefs runtimeDefs;

Expand Down Expand Up @@ -102,7 +103,6 @@ void RuntimeDefs::clear()
}
sounds.clear();

sprNames.clear();
mobjInfo.clear();
states.clear();
texts.clear();
Expand Down Expand Up @@ -133,6 +133,7 @@ int Def_GetGameClasses()
void Def_Init()
{
runtimeDefs.clear();
sprNames.clear();
defs.clear();

// Make the definitions visible in the global namespace.
Expand Down Expand Up @@ -164,6 +165,7 @@ void Def_Destroy()

// Destroy the databases.
runtimeDefs.clear();
sprNames.clear();

defsInited = false;
}
Expand All @@ -177,9 +179,9 @@ spritenum_t Def_GetSpriteNum(char const *name)
{
if(name && name[0])
{
for(int i = 0; i < runtimeDefs.sprNames.size(); ++i)
for(int i = 0; i < sprNames.size(); ++i)
{
if(!qstricmp(runtimeDefs.sprNames[i].name, name))
if(!qstricmp(sprNames[i].name, name))
return i;
}
}
Expand Down Expand Up @@ -1290,6 +1292,7 @@ void Def_Read()
// Now we can clear all existing definitions and re-init.
defs.clear();
runtimeDefs.clear();
sprNames.clear();

// Generate definitions.
generateMaterialDefs();
Expand All @@ -1310,10 +1313,10 @@ void Def_Read()
#endif

// Sprite names.
runtimeDefs.sprNames.append(defs.sprites.size());
for(int i = 0; i < runtimeDefs.sprNames.size(); ++i)
sprNames.append(defs.sprites.size());
for(int i = 0; i < sprNames.size(); ++i)
{
qstrcpy(runtimeDefs.sprNames[i].name, defs.sprites[i].id);
qstrcpy(sprNames[i].name, defs.sprites[i].id);
}

// States.
Expand Down Expand Up @@ -1650,7 +1653,7 @@ void Def_Read()
os << defCountMsg(defs.sectorTypes.size(), "sector types");
os << defCountMsg(defs.musics.size(), "songs");
os << defCountMsg(runtimeDefs.sounds.size(), "sound effects");
os << defCountMsg(runtimeDefs.sprNames.size(), "sprite names");
os << defCountMsg(sprNames.size(), "sprite names");
os << defCountMsg(runtimeDefs.states.size(), "states");
os << defCountMsg(defs.decorations.size(), "surface decorations");
os << defCountMsg(defs.reflections.size(), "surface reflections");
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/resource/resourcesystem.cpp
Expand Up @@ -3755,7 +3755,7 @@ void ResourceSystem::initSprites()
{
// Format or generate an id for the sprite.
spritenum_t spriteId = Def_GetSpriteNum(def.name.toUtf8().constData());
if(spriteId == -1) spriteId = (runtimeDefs.sprNames.size() + customIdx++);
if(spriteId == -1) spriteId = (sprNames.size() + customIdx++);

// Append another frame set to the relevant sprite.
d->newSpriteFrameSet(spriteId).append(buildSpritesFromDefinition(def));
Expand Down

0 comments on commit 3ad2ec0

Please sign in to comment.