diff --git a/.gitignore b/.gitignore index cf6b61aca6..a3d2b83b61 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ macx_release_build server-runtime client-runtime Zcustom.conf +.web.manifest \ No newline at end of file diff --git a/distrib/autobuild.py b/distrib/autobuild.py index 0e1f2fa30e..58aed4d5c4 100755 --- a/distrib/autobuild.py +++ b/distrib/autobuild.py @@ -1,16 +1,22 @@ #!/usr/bin/python # coding=utf-8 - -# Script for managing automated build events. +# +# Script for performing automated build events. # http://dengine.net/dew/index.php?title=Automated_build_system +# +# The Build Pilot (pilot.py) is responsible for task distribution +# and management. import sys import os +import subprocess import shutil import time import string import glob import builder +import pickle +import zipfile from builder.git import * from builder.utils import * @@ -246,6 +252,101 @@ def dir_cleanup(): print 'Cleanup done.' +def system_command(cmd): + result = subprocess.call(cmd, shell=True) + if result != 0: + raise Exception("Error from " + cmd) + + +def generate_apidoc(): + """Run Doxygen to generate all API documentation.""" + os.chdir(os.path.join(builder.config.DISTRIB_DIR, '../doomsday/engine')) + git_pull() + + print "\n-=-=- PUBLIC API DOCS -=-=-" + system_command('doxygen api.doxy >/dev/null') + + print "\n-=-=- INTERNAL WIN32 DOCS -=-=-" + system_command('doxygen engine-win32.doxy >/dev/null') + + print "\n-=-=- INTERNAL MAC/UNIX DOCS -=-=-" + system_command('doxygen engine-mac.doxy >/dev/null') + + print "\n-=-=- JDOOM DOCS -=-=-" + os.chdir(os.path.join(builder.config.DISTRIB_DIR, '../doomsday/plugins/jdoom')) + system_command('doxygen jdoom.doxy >/dev/null') + + print "\n-=-=- JHERETIC DOCS -=-=-" + os.chdir(os.path.join(builder.config.DISTRIB_DIR, '../doomsday/plugins/jheretic')) + system_command('doxygen jheretic.doxy >/dev/null') + + print "\n-=-=- JHEXEN DOCS -=-=-" + os.chdir(os.path.join(builder.config.DISTRIB_DIR, '../doomsday/plugins/jhexen')) + system_command('doxygen jhexen.doxy >/dev/null') + + +def web_path(): + return os.path.join(builder.config.DISTRIB_DIR, '..', 'web') + + +def web_manifest_filename(): + return os.path.join(builder.config.DISTRIB_DIR, '..', '.web.manifest') + + +def web_save(state): + pickle.dump(state, file(web_manifest_filename(), 'wb'), pickle.HIGHEST_PROTOCOL) + + +def web_init(): + print 'Initializing web update manifest.' + web_save(DirState(web_path())) + + +def web_update(): + print 'Checking for web file changes...' + git_pull() + + oldState = pickle.load(file(web_manifest_filename(), 'rb')) + state = DirState(web_path()) + updated = state.list_new_files(oldState) + removed = state.list_removed(oldState) + + # Save the updated state. + web_save(state) + + # Is there anything to do? + if not updated and not removed[0] and not removed[1]: + print 'Everything up-to-date.' + return + + # Compile the update package. + print 'Updated:', updated + print 'Removed:', removed + arcFn = os.path.join(builder.config.DISTRIB_DIR, '..', + 'web_update_%s.zip' % time.strftime('%Y%m%d-%H%M%S')) + arc = zipfile.ZipFile(arcFn, 'w') + for up in updated: + arc.write(os.path.join(web_path(), up), 'updated/' + up) + if removed[0] or removed[1]: + tmpFn = '_removed.tmp' + tmp = file(tmpFn, 'wt') + for n in removed[0]: + print >> tmp, 'rm', n + for d in removed[1]: + print >> tmp, 'rmdir', d + tmp.close() + arc.write(tmpFn, 'removed.txt') + os.remove(tmpFn) + arc.close() + + # Deliver the update to the website. + print 'Delivering', arcFn + system_command('scp %s dengine@dengine.net:www/incoming/' % arcFn) + + # No need to keep a local copy. + os.remove(arcFn) + + def show_help(): """Prints a description of each command.""" for cmd in sorted_commands(): @@ -271,6 +372,9 @@ def sorted_commands(): 'xmlfeed': update_xml_feed, 'purge': purge_obsolete, 'cleanup': dir_cleanup, + 'apidoc': generate_apidoc, + 'web_init': web_init, + 'web_update': web_update, 'help': show_help } diff --git a/distrib/builder/utils.py b/distrib/builder/utils.py index c83ffb38c5..043cd14a2d 100644 --- a/distrib/builder/utils.py +++ b/distrib/builder/utils.py @@ -7,6 +7,60 @@ import build_number import config +def omit_path(path, omitted): + if path.startswith(omitted): + path = path[len(omitted):] + if path[0] == '/': path = path[1:] + return path + + +class FileState: + def __init__(self, isDir, mtime): + if isDir: + self.type = 'dir' + else: + self.type = 'file' + self.mtime = int(mtime) + + def __repr__(self): + return "(%s, %i)" % (self.type, self.mtime) + + +class DirState: + def __init__(self, path=None): + self.files = {} # path -> FileState + if path: + self.update(path, path) + + def update(self, path, omitted=None): + for name in os.listdir(path): + if name[0] == '.': continue + fullPath = os.path.join(path, name) + self.files[omit_path(fullPath, omitted)] = \ + FileState(os.path.isdir(fullPath), os.stat(fullPath).st_mtime) + if os.path.isdir(fullPath): + self.update(fullPath, omitted) + + def list_new_files(self, oldState): + new = [] + for path in self.files: + if self.files[path].type == 'dir': continue + if path not in oldState.files or self.files[path].mtime > oldState.files[path].mtime: + new.append(path) + return new + + def list_removed(self, oldState): + """Returns a tuple: (list of removed files, list of removed dirs)""" + rmFiles = [] + rmDirs = [] + for oldPath in oldState.files: + if oldPath not in self.files: + if oldState.files[oldPath].type == 'dir': + rmDirs.append(oldPath) + else: + rmFiles.append(oldPath) + return (rmFiles, rmDirs) + def sys_id(): return "%s-%s" % (sys.platform, platform.architecture()[0]) diff --git a/distrib/pilot.py b/distrib/pilot.py index aca99e4956..432f96d856 100755 --- a/distrib/pilot.py +++ b/distrib/pilot.py @@ -2,7 +2,7 @@ # coding=utf-8 # # The Doomsday Build Pilot -# (c) 2011 Jaakko Keränen +# (c) 2011-2012 Jaakko Keränen # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,6 +23,9 @@ ## tasks for the builder client systems. It listens on a TCP port for incoming ## queries and actions. On the clients the pilot is run periodically by cron, ## and any new tasks are carried out. +## +## The pilot's responsibility is distributed task management; the autobuild +## script carries out the actual tasks. import sys import os @@ -78,6 +81,9 @@ def main(): finally: endPilotInstance() +def msg(s): + print >> sys.stderr, s + def isServer(): return 'server' in sys.argv @@ -120,6 +126,15 @@ def pidFileName(): return 'client.pid' +def isStale(fn): + """Files are considered stale after some time has passed.""" + age = time.time() - os.stat(fn).st_ctime + if age > 4*60*60: + msg(fn + ' is stale, ignoring it.') + return True + return False + + def startNewPilotInstance(): """A new pilot instance can only be started if one is not already running on the system. If an existing instance is detected, this one will quit @@ -127,8 +142,9 @@ def startNewPilotInstance(): # Check for an existing pid file. pid = os.path.join(homeDir(), pidFileName()) if os.path.exists(pid): - # Cannot start right now -- will be retried later. - sys.exit(0) + if not isStale(pid): + # Cannot start right now -- will be retried later. + sys.exit(0) print >> file(pid, 'w'), str(os.getpid()) @@ -181,7 +197,7 @@ def handle(self): raise Exception("Requests must be of type 'dict'") self.doRequest() except Exception, x: - print 'Request failed:', x + msg('Request failed: ' + str(x)) response = { 'result': 'error', 'error': str(x) } self.respond(response) @@ -267,53 +283,37 @@ def doTask(task): return True if task == 'tag_build': - print "TASK: TAG NEW BUILD" + msg("TAG NEW BUILD") return autobuild('create') elif task == 'deb_changes': - print "TASK: UPDATE .DEB CHANGELOG" + msg("UPDATE .DEB CHANGELOG") return autobuild('debchanges') elif task == 'build': - print "TASK: BUILD RELEASE" + msg("BUILD RELEASE") return autobuild('platform_release') elif task == 'publish': - print "TASK: PUBLISH" + msg("PUBLISH") systemCommand('deng_copy_build_to_sourceforge.sh') elif task == 'apt_refresh': - print "TASK: APT REPOSITORY REFRESH" + msg("APT REPOSITORY REFRESH") return autobuild('apt') elif task == 'update_feed': - print "TASK: UPDATE FEED" + msg("UPDATE FEED") autobuild('feed') autobuild('xmlfeed') elif task == 'purge': - print "TASK: PURGE" + msg("PURGE") return autobuild('purge') elif task == 'generate_apidoc': - print "TASK: GENERATE API DOCUMENTATION" - os.chdir(os.path.join(pilotcfg.DISTRIB_DIR, '../doomsday/engine')) - systemCommand('git pull') - print "\nPUBLIC API DOCS" - systemCommand('doxygen api.doxy >/dev/null') - print "\nINTERNAL WIN32 DOCS" - systemCommand('doxygen engine-win32.doxy >/dev/null') - print "\nINTERNAL MAC/UNIX DOCS" - systemCommand('doxygen engine-mac.doxy >/dev/null') - print "\nJDOOM DOCS" - os.chdir(os.path.join(pilotcfg.DISTRIB_DIR, '../doomsday/plugins/jdoom')) - systemCommand('doxygen jdoom.doxy >/dev/null') - print "\nJHERETIC DOCS" - os.chdir(os.path.join(pilotcfg.DISTRIB_DIR, '../doomsday/plugins/jheretic')) - systemCommand('doxygen jheretic.doxy >/dev/null') - print "\nJHEXEN DOCS" - os.chdir(os.path.join(pilotcfg.DISTRIB_DIR, '../doomsday/plugins/jhexen')) - systemCommand('doxygen jhexen.doxy >/dev/null') + msg("GENERATE API DOCUMENTATION") + return autobuild('apidoc') return True diff --git a/doomsday/engine/api/dd_infine.h b/doomsday/engine/api/dd_infine.h index c8bf86a7ed..2a814ea0b3 100644 --- a/doomsday/engine/api/dd_infine.h +++ b/doomsday/engine/api/dd_infine.h @@ -40,18 +40,24 @@ typedef ident_t finaleid_t; * @ingroup infine apiFlags */ ///@{ -#define FF_LOCAL 0x1 /// Local scripts are executed client-side. +#define FF_LOCAL 0x1 ///< Local scripts are executed client-side. ///@} /** * Execute a set of Finale commands. - * @param script One or more commands to be executed. - * @param flags @ref finaleFlags. - * @param setupCmds One or more commands to be executed immediately during - * finale setup. Can be used to configure the default page - * state. + * @param script One or more commands to be executed. + * @param flags @ref finaleFlags. */ finaleid_t FI_Execute2(const char* script, int flags, const char* setupCmds); + +/** + * Execute a set of Finale commands. + * @param script One or more commands to be executed. + * @param flags @ref finaleFlags. + * @param setupCmds One or more commands to be executed immediately during + * finale setup. Can be used to configure the default page + * state. + */ finaleid_t FI_Execute(const char* script, int flags); /** diff --git a/doomsday/engine/api/dd_share.h b/doomsday/engine/api/dd_share.h index 41129b81c6..827ed729bf 100644 --- a/doomsday/engine/api/dd_share.h +++ b/doomsday/engine/api/dd_share.h @@ -54,13 +54,11 @@ extern "C" { #include "dd_gl.h" #include "dd_ui.h" #include "dd_infine.h" -#include "../portable/include/p_think.h" -#include "../portable/include/def_share.h" +#include "def_share.h" +#include "thinker.h" /** @file * @todo dd_version.h is not officially a public header file! - * @todo def_share.h is not officially a public header file! - * @todo p_think.h is not officially a public header file! */ //------------------------------------------------------------------------ diff --git a/doomsday/engine/api/dd_types.h b/doomsday/engine/api/dd_types.h index 47f3a7f6c0..a449e196ec 100644 --- a/doomsday/engine/api/dd_types.h +++ b/doomsday/engine/api/dd_types.h @@ -162,11 +162,6 @@ typedef enum { #define VALID_RESOURCE_CLASS(n) ((n) >= RESOURCECLASS_FIRST && (n) < RESOURCECLASS_COUNT) -typedef struct trigger_s { - timespan_t duration; - timespan_t accum; -} trigger_t; - #ifndef __BYTEBOOL__ #define __BYTEBOOL__ # ifdef __cplusplus diff --git a/doomsday/engine/portable/include/def_share.h b/doomsday/engine/api/def_share.h similarity index 69% rename from doomsday/engine/portable/include/def_share.h rename to doomsday/engine/api/def_share.h index d1421d6cee..20d100fc38 100644 --- a/doomsday/engine/portable/include/def_share.h +++ b/doomsday/engine/api/def_share.h @@ -1,36 +1,33 @@ -/**\file - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html - * - *\author Copyright © 2003-2012 Jaakko Keränen - *\author Copyright © 2005-2012 Daniel Swanson +/** + * @file def_share.h + * Shared definition data structures and constants. @ingroup defs * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * @authors Copyright © 2003-2012 Jaakko Keränen + * @authors Copyright © 2005-2012 Daniel Swanson * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -/** - * def_share.h: Shared Definition Data Structures and Constants + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA */ -#ifndef __DOOMSDAY_GAME_DATA_H__ -#define __DOOMSDAY_GAME_DATA_H__ +#ifndef LIBDENG_SHARED_GAME_DEFINITIONS_H +#define LIBDENG_SHARED_GAME_DEFINITIONS_H #include "dd_types.h" +/// @addtogroup defs +///@{ + #define NUM_MOBJ_FLAGS 3 #define NUM_MOBJ_MISC 4 #define NUM_STATE_MISC 3 @@ -95,19 +92,24 @@ typedef struct { } musicinfo_t; typedef struct { - char* text; // Pointer to the text (don't modify). + char* text; ///< Pointer to the text (don't modify). } ddtext_t; -// Map Info flags. -#define MIF_FOG 0x1 // Fog is used in the map. -#define MIF_DRAW_SPHERE 0x2 // Always draw the sky sphere. -#define MIF_NO_INTERMISSION 0x4 // Skip any intermission between maps. +/** + * @defgroup mapInfoFlags Map Info Flags + * @ingroup defs apiFlags + */ +///@{ +#define MIF_FOG 0x1 ///< Fog is used in the map. +#define MIF_DRAW_SPHERE 0x2 ///< Always draw the sky sphere. +#define MIF_NO_INTERMISSION 0x4 ///< Skip any intermission between maps. +///@} typedef struct { char* name; char* author; int music; - int flags; // MIF_* flags. + int flags; ///< MIF_* flags. float ambient; float gravity; float parTime; @@ -165,9 +167,9 @@ typedef struct { float interval[DDLT_MAX_CHAINS][2]; int count[DDLT_MAX_CHAINS]; int ambientSound; - float soundInterval[2]; // min,max - float materialMoveAngle[2]; // floor, ceil - float materialMoveSpeed[2]; // floor, ceil + float soundInterval[2]; ///< min,max + float materialMoveAngle[2]; ///< floor, ceil + float materialMoveSpeed[2]; ///< floor, ceil float windAngle; float windSpeed; float verticalWind; @@ -175,7 +177,7 @@ typedef struct { float friction; char* lightFunc; int lightInterval[2]; - char* colFunc[3]; // RGB + char* colFunc[3]; ///< RGB int colInterval[3][2]; char* floorFunc; float floorMul, floorOff; @@ -185,4 +187,6 @@ typedef struct { int ceilInterval[2]; } sectortype_t; -#endif +///@} + +#endif // LIBDENG_SHARED_GAME_DEFINITIONS_H diff --git a/doomsday/engine/api/doomsday.def b/doomsday/engine/api/doomsday.def index f7629d2e98..d6d7c13578 100644 --- a/doomsday/engine/api/doomsday.def +++ b/doomsday/engine/api/doomsday.def @@ -2,7 +2,7 @@ ; ; Highest ordinal is currently: --> 751 <-- ; Other free ordinals: -; none +; 340, 341 NAME "DOOMSDAY" @@ -774,8 +774,6 @@ EXPORTS M_ClearBox @208 NONAME M_AddToBox @209 NONAME M_ScreenShot @210 NONAME - M_CheckTrigger @340 NONAME - M_RunTrigger @341 NONAME M_CeilPow2 @422 NONAME M_NumDigits @143 NONAME M_RatioReduce @499 NONAME diff --git a/doomsday/engine/api/doomsday.h b/doomsday/engine/api/doomsday.h index 8a3fa4ae81..f3541935cf 100644 --- a/doomsday/engine/api/doomsday.h +++ b/doomsday/engine/api/doomsday.h @@ -351,15 +351,19 @@ void Net_SendPacket(int to_player, int type, const void* data, size_t length); // //------------------------------------------------------------------------ +/// @addtogroup math +///@{ + float P_AccurateDistance(float dx, float dy); + float P_ApproxDistance(float dx, float dy); + float P_ApproxDistance3(float dx, float dy, float dz); +///@} + /** * @defgroup playsim * @ingroup game */ ///@{ - float P_AccurateDistance(float dx, float dy); - float P_ApproxDistance(float dx, float dy); - float P_ApproxDistance3(float dx, float dy, float dz); int P_PointOnLinedefSide(float xy[2], const struct linedef_s* lineDef); int P_PointOnLinedefSideXY(float x, float y, const struct linedef_s* lineDef); int P_BoxOnLineSide(const AABoxf* box, const struct linedef_s* ld); @@ -410,20 +414,27 @@ void Net_SendPacket(int to_player, int type, const void* data, size_t length); void P_Impulse(int playerNum, int control); ///@} - // Play: Setup. - +/// @addtogroup map +///@{ +// Play: Setup. boolean P_MapExists(const char* uri); boolean P_MapIsCustom(const char* uri); const char* P_MapSourceFile(const char* uri); boolean P_LoadMap(const char* uri); +///@} - // Play: World data access (Map Data Updates and access to other information). +// Play: World data access (Map Data Updates and access to other information). #include "dd_world.h" - // Play: Misc. - void P_SpawnDamageParticleGen(struct mobj_s* mo, struct mobj_s* inflictor, int amount); +/// @addtogroup playsim +///@{ +// Play: Misc. +void P_SpawnDamageParticleGen(struct mobj_s* mo, struct mobj_s* inflictor, int amount); +///@} +/// @addtogroup mobj +///@{ // Play: Mobjs. struct mobj_s* P_MobjCreate(think_t function, float x, float y, float z, angle_t angle, float radius, float height, int ddflags); void P_MobjDestroy(struct mobj_s* mo); @@ -442,6 +453,13 @@ boolean P_LoadMap(const char* uri); int P_MobjSectorsIterator(struct mobj_s* mo, int (*func) (sector_t*, void*), void* data); +///@} + +/** + * @defgroup polyobj Polygon Objects + * @ingroup map + */ +///@{ // Play: Polyobjs. boolean P_PolyobjMove(struct polyobj_s* po, float x, float y); @@ -451,12 +469,21 @@ boolean P_LoadMap(const char* uri); struct polyobj_s* P_GetPolyobj(uint num); void P_SetPolyobjCallback(void (*func)(struct mobj_s*, void*, void*)); +///@} + +/// @addtogroup material +///@{ // Play: Materials. materialid_t Materials_ResolveUri(const Uri* uri); materialid_t Materials_ResolveUriCString(const char* path); Uri* Materials_ComposeUri(materialid_t materialId); +///@} + +/// @addtogroup playsim +///@{ + // Play: Thinkers. void DD_InitThinkers(void); void DD_RunThinkers(void); @@ -466,21 +493,45 @@ Uri* Materials_ComposeUri(materialid_t materialId); int DD_IterateThinkers(think_t type, int (*func) (thinker_t *th, void*), void* data); +///@} + //------------------------------------------------------------------------ // // UI. // //------------------------------------------------------------------------ +/// @addtogroup gl +///@{ + fontid_t Fonts_ResolveUri(const Uri* uri); +///@} + //------------------------------------------------------------------------ // // Refresh. // //------------------------------------------------------------------------ +/** + * Determines whether the current run of the thinkers should be considered a + * "sharp" tick. Sharp ticks occur exactly 35 times per second. Thinkers may be + * called at any rate faster than this; in order to retain compatibility with + * the original Doom engine game logic that ran at 35 Hz, such logic should + * only be executed on sharp ticks. + * + * @return @c true, if a sharp tick is currently in effect. + * + * @ingroup playsim + */ boolean DD_IsSharpTick(void); + +/** + * @defgroup render Renderer + */ +///@{ + int DD_GetFrameRate(void); void R_SetupMap(int mode, int flags); @@ -548,20 +599,30 @@ void R_HSVToRGB(float* rgb, float h, float s, float v); angle_t R_PointToAngle2(float x1, float y1, float x2, float y2); struct subsector_s* R_PointInSubsector(float x, float y); +///@} + //------------------------------------------------------------------------ // // Renderer. // //------------------------------------------------------------------------ +/// @addtogroup render +///@{ + void R_SkyParams(int layer, int param, void* data); +///@} + //------------------------------------------------------------------------ // // Graphics. // //------------------------------------------------------------------------ +/// @addtogroup gl +///@{ + void GL_UseFog(int yes); byte* GL_GrabScreen(void); void GL_SetFilter(boolean enable); @@ -572,12 +633,17 @@ void GL_ConfigureBorderedProjection(borderedprojectionstate_t* bp, int flags, in void GL_BeginBorderedProjection(borderedprojectionstate_t* bp); void GL_EndBorderedProjection(borderedprojectionstate_t* bp); +///@} + //------------------------------------------------------------------------ // // Audio. // //------------------------------------------------------------------------ +/// @addtogroup audio +///@{ + void S_MapChange(void); int S_LocalSoundAtVolumeFrom(int sound_id, struct mobj_s* origin, float* pos, float volume); int S_LocalSoundAtVolume(int soundID, struct mobj_s* origin, float volume); @@ -594,12 +660,22 @@ void GL_EndBorderedProjection(borderedprojectionstate_t* bp); void S_StopMusic(void); void S_PauseMusic(boolean doPause); +///@} + //------------------------------------------------------------------------ // // Miscellaneous. // //------------------------------------------------------------------------ +/** + * @ingroup render + */ +int M_ScreenShot(const char* filename, int bits); + +/// @addtogroup base +///@{ + char* M_SkipWhite(char* str); char* M_FindWhite(char* str); char* M_StrCatQuoted(char* dest, const char* src, size_t len); @@ -607,7 +683,10 @@ boolean M_IsStringValidInt(const char* str); boolean M_IsStringValidByte(const char* str); boolean M_IsStringValidFloat(const char* str); - int M_ScreenShot(const char* filename, int bits); +///@} + +/// @addtogroup math +///@{ void M_ClearBox(fixed_t* box); void M_AddToBox(fixed_t* box, fixed_t x, fixed_t y); @@ -619,10 +698,6 @@ boolean M_IsStringValidFloat(const char* str); byte RNG_RandByte(void); float RNG_RandFloat(void); - // Miscellaneous: Time utilities. - boolean M_RunTrigger(trigger_t* trigger, timespan_t advanceTime); - boolean M_CheckTrigger(const trigger_t* trigger, timespan_t advanceTime); - // Miscellaneous: Math. void V2_Rotate(float vec[2], float radians); float V2_Intersection(const float* p1, const float* delta1, const float* p2, const float* delta2, float point[2]); @@ -633,6 +708,11 @@ boolean M_IsStringValidFloat(const char* str); binangle_t bamsAtan2(int y, int x); +///@} + +/// @addtogroup base +///@{ + // Miscellaneous: Command line. void _DECALL ArgAbbreviate(const char* longName, const char* shortName); int _DECALL Argc(void); @@ -644,6 +724,8 @@ boolean M_IsStringValidFloat(const char* str); int _DECALL ArgExists(const char* check); int _DECALL ArgIsOption(int i); +///@} + #ifdef __cplusplus } #endif diff --git a/doomsday/engine/api/thinker.h b/doomsday/engine/api/thinker.h new file mode 100644 index 0000000000..0ba26ba68a --- /dev/null +++ b/doomsday/engine/api/thinker.h @@ -0,0 +1,70 @@ +/** + * @file thinker.h + * Thinkers. @ingroup playsim + * + * @authors Copyright © 2003-2012 Jaakko Keränen + * @authors Copyright © 2006-2012 Daniel Swanson + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef LIBDENG_THINKER_H +#define LIBDENG_THINKER_H + +/// @addtogroup thinker +///@{ + +/// Function pointer to a function to handle an actor's thinking. +typedef void (*think_t) (); + +/** + * Base for all thinker objects. + */ +typedef struct thinker_s { + struct thinker_s *prev, *next; + think_t function; + boolean inStasis; + thid_t id; ///< Only used for mobjs (zero is not an ID). +} thinker_t; + +void DD_InitThinkers(void); +void DD_RunThinkers(void); +void DD_ThinkerAdd(thinker_t* th); +void DD_ThinkerRemove(thinker_t* th); +void DD_ThinkerSetStasis(thinker_t* th, boolean on); +int DD_IterateThinkers(think_t func, int (*callback) (thinker_t*, void*), + void* context); + +///@} + +/// Not part of the public API. +///@{ +boolean P_ThinkerListInited(void); + +void P_InitThinkerLists(byte flags); +int P_IterateThinkers(think_t type, byte flags, + int (*callback) (thinker_t* th, void*), + void* context); + +void P_ThinkerAdd(thinker_t* th, boolean makePublic); +void P_ThinkerRemove(thinker_t* th); + +void P_SetMobjID(thid_t id, boolean state); +boolean P_IsUsedMobjID(thid_t id); +boolean P_IsMobjThinker(think_t thinker); +struct mobj_s* P_MobjForID(int id); +///@} + +#endif // LIBDENG_THINKER_H diff --git a/doomsday/engine/engine.pro b/doomsday/engine/engine.pro index 3ff547105f..52a564426b 100644 --- a/doomsday/engine/engine.pro +++ b/doomsday/engine/engine.pro @@ -89,6 +89,7 @@ DENG_API_HEADERS = \ api/dd_vectorgraphic.h \ api/dd_wad.h \ api/dd_world.h \ + api/def_share.h \ api/dengproject.h \ api/dfile.h \ api/doomsday.h \ @@ -102,6 +103,7 @@ DENG_API_HEADERS = \ api/sys_audiod.h \ api/sys_audiod_mus.h \ api/sys_audiod_sfx.h \ + api/thinker.h \ api/uri.h \ api/writer.h @@ -147,7 +149,6 @@ DENG_HEADERS = \ portable/include/dd_zone.h \ portable/include/def_data.h \ portable/include/def_main.h \ - portable/include/def_share.h \ portable/include/de_audio.h \ portable/include/de_base.h \ portable/include/de_bsp.h \ @@ -238,7 +239,6 @@ DENG_HEADERS = \ portable/include/p_sight.h \ portable/include/p_subsector.h \ portable/include/p_surface.h \ - portable/include/p_think.h \ portable/include/p_ticker.h \ portable/include/p_vertex.h \ portable/include/rend_bias.h \ diff --git a/doomsday/engine/portable/include/de_play.h b/doomsday/engine/portable/include/de_play.h index d9bf715b8e..5757ba4b7f 100644 --- a/doomsday/engine/portable/include/de_play.h +++ b/doomsday/engine/portable/include/de_play.h @@ -41,7 +41,7 @@ #include "p_sector.h" #include "p_polyobj.h" #include "p_dmu.h" -#include "p_think.h" +#include "thinker.h" #include "p_object.h" #include "p_intercept.h" #include "p_maputil.h" diff --git a/doomsday/engine/portable/include/m_linkedlist.h b/doomsday/engine/portable/include/m_linkedlist.h index e88e965b65..f66ecb7bd0 100644 --- a/doomsday/engine/portable/include/m_linkedlist.h +++ b/doomsday/engine/portable/include/m_linkedlist.h @@ -1,32 +1,30 @@ -/**\file - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html +/** + * @file m_linkedlist.h + * Linked list. @ingroup base * - *\author Copyright © 2009-2012 Daniel Swanson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * A pretty simple linked list implementation that supports + * single, double and ring lists. + + * @authors Copyright © 2009-2012 Daniel Swanson + * @authors Copyright © 2012 Jaakko Keränen * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -/* - * m_linkedlist.h: Linked lists. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA */ -#ifndef __LINKEDLIST_H__ -#define __LINKEDLIST_H__ +#ifndef LIBDENG_LINKEDLIST_H +#define LIBDENG_LINKEDLIST_H #ifdef __cplusplus extern "C" { @@ -56,14 +54,16 @@ COMPAREFUNC( compareDouble ); COMPAREFUNC( compareString ); COMPAREFUNC( compareAddress ); -// -// Linked lists. -// -typedef void* linklist_t; +struct linklist_s; + +/** + * LinkList instance. Use List_New() to construct. + */ +typedef struct linklist_s LinkList; #define PTR_NOT_LIST -1 -// Linked list errors: +/// Linked list errors. enum { LL_NO_ERROR, LL_ERROR_UNKNOWN, @@ -80,40 +80,39 @@ enum { // List_Iterate flags #define LIF_REVERSE 0x1 // Iteration will be tail > head. -// Create/Destroy: -linklist_t *List_Create(void); -linklist_t *List_Create2(int createFlags, comparefunc func); -void List_Destroy(linklist_t *list); +LinkList* List_New(void); +LinkList* List_NewWithCompareFunc(int createFlags, comparefunc func); +void List_Destroy(LinkList *list); // Inserts: -int List_InsertFront(linklist_t *list, const void *data); -int List_InsertBack(linklist_t *list, const void *data); +int List_InsertFront(LinkList *list, const void *data); +int List_InsertBack(LinkList *list, const void *data); // Retrieves: -void* List_GetFront(const linklist_t *list); -void* List_GetBack(const linklist_t *list); -void* List_GetAt(const linklist_t *list, listindex_t position); +void* List_GetFront(const LinkList *list); +void* List_GetBack(const LinkList *list); +void* List_GetAt(const LinkList *list, listindex_t position); // Extracts: -void* List_ExtractFront(linklist_t *list); -void* List_ExtractBack(linklist_t *list); -void* List_ExtractAt(linklist_t *list, listindex_t position); +void* List_ExtractFront(LinkList *list); +void* List_ExtractBack(LinkList *list); +void* List_ExtractAt(LinkList *list, listindex_t position); // Other: -void List_SetCompareFunc(linklist_t *list, comparefunc func); -void List_Clear(linklist_t *list); -listindex_t List_Find(const linklist_t *list, const void *data); -int List_Exchange(linklist_t *list, listindex_t positionA, +void List_SetCompareFunc(LinkList *list, comparefunc func); +void List_Clear(LinkList *list); +listindex_t List_Find(const LinkList *list, const void *data); +int List_Exchange(LinkList *list, listindex_t positionA, listindex_t positionB); // Sorts: -void List_Sort(linklist_t *list); +void List_Sort(LinkList *list); // State retrieval: -listindex_t List_Count(const linklist_t *list); -int List_GetError(const linklist_t *list); +listindex_t List_Count(const LinkList *list); +int List_GetError(const LinkList *list); // Iteration: -int List_Iterate(const linklist_t *list, int iterateFlags, +int List_Iterate(const LinkList *list, int iterateFlags, void *data, int (*callback) (void *element, void *data)); // Debugging: @@ -125,4 +124,4 @@ void List_Test(void); } #endif -#endif +#endif // LIBDENG_LINKEDLIST_H diff --git a/doomsday/engine/portable/include/m_misc.h b/doomsday/engine/portable/include/m_misc.h index e280ce3ac5..3e74e516b4 100644 --- a/doomsday/engine/portable/include/m_misc.h +++ b/doomsday/engine/portable/include/m_misc.h @@ -136,7 +136,7 @@ float M_CycleIntoRange(float value, float length); /** * Using Euclid's Algorithm reduce the given numerator and denominator by - * their greatest common integer divisor. + * their greatest common integer divisor. @ingroup math * @param numerator Input and output numerator. * @param denominator Input and output denominator. * @return Greatest common divisor. @@ -146,11 +146,11 @@ int M_RatioReduce(int* numerator, int* denominator); double M_SlopeToAngle(double dx, double dy); double M_Length(double x, double y); int M_NumDigits(int num); -uint M_CRC32(byte* data, uint length); -// Time utilities. -boolean M_RunTrigger(trigger_t* trigger, timespan_t advanceTime); -boolean M_CheckTrigger(const trigger_t* trigger, timespan_t advanceTime); +/** + * Calculate CRC-32 for an arbitrary data buffer. @ingroup math + */ +uint M_CRC32(byte* data, uint length); // Other utilities: diff --git a/doomsday/engine/portable/include/p_think.h b/doomsday/engine/portable/include/p_think.h deleted file mode 100644 index 726cf05f3a..0000000000 --- a/doomsday/engine/portable/include/p_think.h +++ /dev/null @@ -1,65 +0,0 @@ -/**\file - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html - * - *\author Copyright © 2003-2012 Jaakko Keränen - *\author Copyright © 2006-2012 Daniel Swanson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -/** - * p_think.h: Thinkers - */ - -#ifndef __DOOMSDAY_THINKER_H__ -#define __DOOMSDAY_THINKER_H__ - -// think_t is a function pointer to a routine to handle an actor -typedef void (*think_t) (); - -typedef struct thinker_s { - struct thinker_s *prev, *next; - think_t function; - boolean inStasis; - thid_t id; // Only used for mobjs (zero is not an ID). -} thinker_t; - -boolean P_ThinkerListInited(void); - -void P_InitThinkerLists(byte flags); -int P_IterateThinkers(think_t type, byte flags, - int (*callback) (thinker_t* th, void*), - void* context); - -void P_ThinkerAdd(thinker_t* th, boolean makePublic); -void P_ThinkerRemove(thinker_t* th); - -void P_SetMobjID(thid_t id, boolean state); -boolean P_IsUsedMobjID(thid_t id); -boolean P_IsMobjThinker(think_t thinker); -struct mobj_s* P_MobjForID(int id); - -// Public interface: -void DD_InitThinkers(void); -void DD_RunThinkers(void); -void DD_ThinkerAdd(thinker_t* th); -void DD_ThinkerRemove(thinker_t* th); -void DD_ThinkerSetStasis(thinker_t* th, boolean on); -int DD_IterateThinkers(think_t func, int (*callback) (thinker_t*, void*), - void* context); -#endif diff --git a/doomsday/engine/portable/include/r_data.h b/doomsday/engine/portable/include/r_data.h index 64419752fd..58c874ad44 100644 --- a/doomsday/engine/portable/include/r_data.h +++ b/doomsday/engine/portable/include/r_data.h @@ -32,7 +32,7 @@ #include "dd_types.h" #include "gl_main.h" #include "dd_def.h" -#include "p_think.h" +#include "thinker.h" #include "m_nodepile.h" #include "def_data.h" diff --git a/doomsday/engine/portable/src/m_linkedlist.c b/doomsday/engine/portable/src/m_linkedlist.c index 8481a071c7..55d796066d 100644 --- a/doomsday/engine/portable/src/m_linkedlist.c +++ b/doomsday/engine/portable/src/m_linkedlist.c @@ -1,56 +1,42 @@ -/**\file - *\section License - * License: GPL - * Online License Link: http://www.gnu.org/licenses/gpl.html - * - *\author Copyright © 2007-2012 Daniel Swanson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - /** - * m_linkedlist.c: A pretty simple linked list implementation. + * @file m_linkedlist.c + * Linked list. @ingroup base + + * @authors Copyright © 2009-2012 Daniel Swanson + * @authors Copyright © 2012 Jaakko Keränen + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html * - * Supports single, double and ring lists. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA */ -// HEADER FILES ------------------------------------------------------------ +#include "m_linkedlist.h" #include #include #ifndef NDEBUG -#include // For debug message output. +# include // For debug message output. #endif -#include "m_linkedlist.h" - -// MACROS ------------------------------------------------------------------ - #define COMPARETYPERELATIVE(type) \ - ((*(type *)a < *(type *)b) - (*(type *)a > *(type *)b)) + ((*(type*)a < *(type*)b) - (*(type*)a > *(type*)b)) #define COMPAREFUNCTYPERELATIVE(name, type) \ - COMPAREFUNC(name) \ - { \ + COMPAREFUNC(name) { \ return COMPARETYPERELATIVE(type); \ } -// TYPES ------------------------------------------------------------------- - typedef struct listnode_s { struct listnode_s *next, *prev; void *data; @@ -62,7 +48,7 @@ typedef struct liststate_s { int lastError; } liststate_t; -typedef struct linkedlist_s { +struct linklist_s { // List state: liststate_t *state; @@ -72,21 +58,7 @@ typedef struct linkedlist_s { // Misc: comparefunc funcCompare; -} list_t; - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -// CODE -------------------------------------------------------------------- +}; static __inline listnode_t *allocNode(void) { @@ -98,7 +70,7 @@ static __inline void freeNode(listnode_t *node) free(node); } -static __inline listnode_t *newNode(list_t *list) +static __inline listnode_t *newNode(LinkList *list) { listnode_t *n; @@ -123,7 +95,7 @@ static __inline listnode_t *newNode(list_t *list) return n; } -static __inline void moveNodeForReuse(list_t *list, listnode_t *node) +static __inline void moveNodeForReuse(LinkList *list, listnode_t *node) { if(list->unused != NULL) node->next = list->unused; @@ -134,7 +106,7 @@ static __inline void moveNodeForReuse(list_t *list, listnode_t *node) list->unused = node; } -static __inline void insertNodeAfter(list_t *list, listnode_t *node, +static __inline void insertNodeAfter(LinkList *list, listnode_t *node, listnode_t *newnode) { newnode->prev = node; @@ -151,7 +123,7 @@ static __inline void insertNodeAfter(list_t *list, listnode_t *node, node->next = newnode; } -static __inline void insertNodeBefore(list_t *list, listnode_t *node, +static __inline void insertNodeBefore(LinkList *list, listnode_t *node, listnode_t *newnode) { newnode->prev = node->prev; @@ -168,7 +140,7 @@ static __inline void insertNodeBefore(list_t *list, listnode_t *node, node->prev = newnode; } -static __inline void insertNodeAtStart(list_t *list, listnode_t *newnode) +static __inline void insertNodeAtStart(LinkList *list, listnode_t *newnode) { if(list->headptr == NULL) { @@ -182,7 +154,7 @@ static __inline void insertNodeAtStart(list_t *list, listnode_t *newnode) insertNodeBefore(list, list->headptr, newnode); } -static __inline void insertNodeAtEnd(list_t *list, listnode_t *newnode) +static __inline void insertNodeAtEnd(LinkList *list, listnode_t *newnode) { if(list->tailptr == NULL) { @@ -196,7 +168,7 @@ static __inline void insertNodeAtEnd(list_t *list, listnode_t *newnode) insertNodeAfter(list, list->tailptr, newnode); } -static __inline void removeNode(list_t *list, listnode_t *node) +static __inline void removeNode(LinkList *list, listnode_t *node) { if(list->state->flags & LCF_CIRCULAR) { @@ -230,7 +202,7 @@ static __inline void removeNode(list_t *list, listnode_t *node) moveNodeForReuse(list, node); } -static listindex_t findByData(const list_t *list, const void *data) +static listindex_t findByData(const LinkList *list, const void *data) { if(list->state->numElements > 0) { @@ -263,7 +235,7 @@ static listindex_t findByData(const list_t *list, const void *data) return -1; } -static listnode_t *findAtPosition(const list_t *list, listindex_t position) +static listnode_t *findAtPosition(const LinkList *list, listindex_t position) { if(list->state->numElements > 0) { @@ -314,7 +286,7 @@ static listnode_t *findAtPosition(const list_t *list, listindex_t position) return NULL; } -static __inline void* getAt(const list_t *list, listindex_t position) +static __inline void* getAt(const LinkList *list, listindex_t position) { void *data = NULL; listnode_t *n; @@ -327,7 +299,7 @@ static __inline void* getAt(const list_t *list, listindex_t position) return data; } -static __inline void* extractAt(list_t *list, listindex_t position) +static __inline void* extractAt(LinkList *list, listindex_t position) { void *data = NULL; listnode_t *n; @@ -342,7 +314,7 @@ static __inline void* extractAt(list_t *list, listindex_t position) return data; } -static __inline int exchangeElements(list_t *list, listindex_t positionA, +static __inline int exchangeElements(LinkList *list, listindex_t positionA, listindex_t positionB) { listnode_t *a, *b; @@ -362,7 +334,7 @@ static __inline int exchangeElements(list_t *list, listindex_t positionA, return 1; // Success! } -static __inline void clear(list_t *list) +static __inline void clear(LinkList *list) { if(list->state->numElements > 0) { @@ -382,7 +354,7 @@ static __inline void clear(list_t *list) } } -static __inline void clearUnused(list_t *list) +static __inline void clearUnused(LinkList *list) { listnode_t *n, *np; @@ -479,7 +451,7 @@ static listnode_t *doMergeSort(listnode_t *list, comparefunc funcCompare) return list; } -static void mergeSort(list_t *list) +static void mergeSort(LinkList *list) { if(list->state->numElements > 1) { @@ -519,9 +491,9 @@ static void mergeSort(list_t *list) } } -static linklist_t *createList(int flags, comparefunc cFunc) +static LinkList *createList(int flags, comparefunc cFunc) { - list_t *list = malloc(sizeof(list_t)); + LinkList *list = malloc(sizeof(LinkList)); liststate_t *state = malloc(sizeof(liststate_t)); list->headptr = list->tailptr = NULL; @@ -533,7 +505,7 @@ static linklist_t *createList(int flags, comparefunc cFunc) list->state->flags = flags; list->state->lastError = LL_NO_ERROR; - return (linklist_t*) list; + return (LinkList*) list; } /** @@ -541,7 +513,7 @@ static linklist_t *createList(int flags, comparefunc cFunc) * * @return Ptr to the newly created list. */ -linklist_t *List_Create(void) +LinkList *List_New(void) { return createList(0, compareAddress); } @@ -557,7 +529,7 @@ linklist_t *List_Create(void) * address) will be set. * @return Ptr to the newly created list. */ -linklist_t *List_Create2(int flags, comparefunc cFunc) +LinkList *List_NewWithCompareFunc(int flags, comparefunc cFunc) { return createList(flags, (!cFunc? compareAddress : cFunc)); } @@ -567,18 +539,15 @@ linklist_t *List_Create2(int flags, comparefunc cFunc) * * @param llist Ptr to the list to be destroyed. */ -void List_Destroy(linklist_t *llist) +void List_Destroy(LinkList *list) { - if(llist) + if(list) { - list_t *list = (list_t*) llist; - clear(list); clearUnused(list); free(list->state); free(list); - return; } } @@ -589,11 +558,11 @@ void List_Destroy(linklist_t *llist) * @param data Ptr to the element being added. * @return Non-zero, iff successfull. */ -int List_InsertFront(linklist_t *llist, const void *data) +int List_InsertFront(LinkList *llist, const void *data) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; listnode_t *n; n = newNode(list); @@ -615,11 +584,11 @@ int List_InsertFront(linklist_t *llist, const void *data) * @param data Ptr to the element being added. * @return Non-zero iff successfull. */ -int List_InsertBack(linklist_t *llist, const void *data) +int List_InsertBack(LinkList *llist, const void *data) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; listnode_t *n; n = newNode(list); @@ -641,11 +610,11 @@ int List_InsertBack(linklist_t *llist, const void *data) * @return Ptr to the extracted element if found and removed * successfully. */ -void *List_ExtractFront(linklist_t *llist) +void *List_ExtractFront(LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return extractAt(list, 0); } @@ -659,11 +628,11 @@ void *List_ExtractFront(linklist_t *llist) * @return Ptr to the extracted element if found and removed * successfully. */ -void *List_ExtractBack(linklist_t *llist) +void *List_ExtractBack(LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return extractAt(list, list->state->numElements - 1); } @@ -679,11 +648,11 @@ void *List_ExtractBack(linklist_t *llist) * @return Ptr to the extracted element if found and removed * successfully. */ -void *List_ExtractAt(linklist_t *llist, listindex_t position) +void *List_ExtractAt(LinkList *llist, listindex_t position) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return extractAt(list, position); } @@ -696,11 +665,11 @@ void *List_ExtractAt(linklist_t *llist, listindex_t position) * @param llist Ptr to the list to retrieve the element from. * @return @c true, iff an element was found at front of the list. */ -void *List_GetFront(const linklist_t *llist) +void *List_GetFront(const LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return getAt(list, 0); } @@ -713,11 +682,11 @@ void *List_GetFront(const linklist_t *llist) * @param llist Ptr to the list to retrieve the element from. * @return @c true, iff an element was found at back of the list. */ -void *List_GetBack(const linklist_t *llist) +void *List_GetBack(const LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return getAt(list, list->state->numElements - 1); } @@ -732,11 +701,11 @@ void *List_GetBack(const linklist_t *llist) * @param position Position of the element to be retrieved. * @return Ptr to the element if found at the given position. */ -void *List_GetAt(const linklist_t *llist, listindex_t position) +void *List_GetAt(const LinkList *llist, listindex_t position) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return getAt(list, position); } @@ -752,12 +721,12 @@ void *List_GetAt(const linklist_t *llist, listindex_t position) * @param positionB Position of the send element being exchanged. * @return Non-zero if successfull. */ -int List_Exchange(linklist_t *llist, listindex_t positionA, +int List_Exchange(LinkList *llist, listindex_t positionA, listindex_t positionB) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return exchangeElements(list, positionA, positionB); } @@ -771,11 +740,11 @@ int List_Exchange(linklist_t *llist, listindex_t positionA, * @param llist Ptr to the list to be searched. * @return Index of the element in the list if found, else @c <0. */ -listindex_t List_Find(const linklist_t *llist, const void *data) +listindex_t List_Find(const LinkList *llist, const void *data) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return findByData(list, data); } @@ -792,11 +761,11 @@ listindex_t List_Find(const linklist_t *llist, const void *data) * * @param llist Ptr to the list to be sorted. */ -void List_Sort(linklist_t *llist) +void List_Sort(LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; mergeSort(list); return; } @@ -808,11 +777,11 @@ void List_Sort(linklist_t *llist) * * @param llist Ptr to the list to be cleared. */ -void List_Clear(linklist_t *llist) +void List_Clear(LinkList *llist) { if(llist) { - clear((list_t*) llist); + clear((LinkList*) llist); return; } } @@ -824,11 +793,11 @@ void List_Clear(linklist_t *llist) * @return @c >= 0, Number of elements in the list else, * @c <0, if error. */ -listindex_t List_Count(const linklist_t *llist) +listindex_t List_Count(const LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return list->state->numElements; } @@ -842,11 +811,11 @@ listindex_t List_Count(const linklist_t *llist) * @param func Ptr to the compare func to use. Note: If @ NULL, the * default compareAddress will be assigned. */ -void List_SetCompareFunc(linklist_t *llist, comparefunc func) +void List_SetCompareFunc(LinkList *llist, comparefunc func) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; if(!func) list->funcCompare = compareAddress; else @@ -870,12 +839,12 @@ void List_SetCompareFunc(linklist_t *llist, comparefunc func) * @c >0, iff every callback returns non-zero else, * @c == 0, if iteration was ended by the callback. */ -int List_Iterate(const linklist_t *llist, int iterateFlags, void *data, +int List_Iterate(const LinkList *llist, int iterateFlags, void *data, int (*callback) (void *element, void *data)) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; int retVal = 1; if(list->state->numElements > 0) @@ -918,11 +887,11 @@ int List_Iterate(const linklist_t *llist, int iterateFlags, void *data, * @param llist Ptr to the list to process. * @return Last error reported by the list. */ -int List_GetError(const linklist_t *llist) +int List_GetError(const LinkList *llist) { if(llist) { - list_t *list = (list_t*) llist; + LinkList *list = (LinkList*) llist; return list->state->lastError; } @@ -970,7 +939,7 @@ int printInt(void *element, void *data) return 1; // Continue iteration. } -static int checkError(linklist_t *list) +static int checkError(LinkList *list) { int error; @@ -981,15 +950,15 @@ static int checkError(linklist_t *list) static void testList(int cFlags) { - linklist_t *list; + LinkList *list; int *data, i, count; int integers[10] = {2456, 12, 76889, 45, 2, 0, -45, 680, -4005, 89}; if(cFlags < 0) - list = List_Create(); + list = List_New(); else - list = List_Create2(cFlags, NULL); + list = List_NewWithCompareFunc(cFlags, NULL); checkError(list); if(List_Count(list) != 0) diff --git a/doomsday/engine/portable/src/m_misc.c b/doomsday/engine/portable/src/m_misc.c index f72864ef28..7230764fdb 100644 --- a/doomsday/engine/portable/src/m_misc.c +++ b/doomsday/engine/portable/src/m_misc.c @@ -1122,52 +1122,6 @@ void M_ReadBits(uint numBits, const uint8_t** src, uint8_t* cb, uint8_t* out) } } -/** - * Advances time and return true if the trigger is triggered. - * - * @param trigger Time trigger. - * @param advanceTime Amount of time to advance the trigger. - * - * @return @c true, if the trigger has accumulated enough time - * to fill the trigger's time threshold. - */ -boolean M_RunTrigger(trigger_t *trigger, timespan_t advanceTime) -{ - // Either use the trigger's duration, or fall back to the default. - timespan_t duration = (trigger->duration? trigger->duration : 1.0f/35); - - trigger->accum += advanceTime; - - if(trigger->accum >= duration) - { - trigger->accum -= duration; - return true; - } - - // It wasn't triggered. - return false; -} - -/** - * Checks if the trigger will trigger after @a advanceTime seconds. - * The trigger itself is not modified in any way. - * - * @param trigger Time trigger. - * @param advanceTime Amount of time to advance the trigger. - * - * @return @c true, if the trigger will accumulate enough time after @a advanceTime - * to fill the trigger's time threshold. - */ -boolean M_CheckTrigger(const trigger_t *trigger, timespan_t advanceTime) -{ - // Either use the trigger's duration, or fall back to the default. - timespan_t duration = (trigger->duration? trigger->duration : 1.0f/35); - return (trigger->accum + advanceTime>= duration); -} - -/** - * Calculate CRC-32 for an arbitrary data buffer. - */ uint M_CRC32(byte *data, uint length) { /* ====================================================================== */ diff --git a/doomsday/engine/portable/src/net_demo.c b/doomsday/engine/portable/src/net_demo.c index 2f4da1aca5..2c6563d2c0 100644 --- a/doomsday/engine/portable/src/net_demo.c +++ b/doomsday/engine/portable/src/net_demo.c @@ -590,9 +590,7 @@ void Demo_ReadLocalCamera(void) */ void Demo_Ticker(timespan_t time) { - static trigger_t fixed = { 1 / 35.0, 0 }; - - if(!M_RunTrigger(&fixed, time)) + if(!DD_IsSharpTick()) return; // Only playback is handled. diff --git a/doomsday/engine/portable/src/rend_font.c b/doomsday/engine/portable/src/rend_font.c index 73cc9c0ac2..566ac35e27 100644 --- a/doomsday/engine/portable/src/rend_font.c +++ b/doomsday/engine/portable/src/rend_font.c @@ -168,12 +168,11 @@ boolean FR_Available(void) void FR_Ticker(timespan_t ticLength) { - static trigger_t fixed = { 1 / 35.0 }; - if(!inited) return; + // Restricted to fixed 35 Hz ticks. - if(!M_RunTrigger(&fixed, ticLength)) + if(!DD_IsSharpTick()) return; // It's too soon. ++typeInTime; diff --git a/doomsday/engine/portable/src/ui_main.c b/doomsday/engine/portable/src/ui_main.c index 7a1c9c3706..287711812d 100644 --- a/doomsday/engine/portable/src/ui_main.c +++ b/doomsday/engine/portable/src/ui_main.c @@ -509,7 +509,6 @@ void UI_Ticker(timespan_t time) { #define UIALPHA_FADE_STEP .07 - static trigger_t fixed = { 1 / 35.0, 0 }; float diff = 0; if(!uiActive) @@ -517,7 +516,7 @@ void UI_Ticker(timespan_t time) if(!uiCurrentPage) return; - if(!M_RunTrigger(&fixed, time)) + if(!DD_IsSharpTick()) return; // Move towards the target alpha level for the entire UI.