Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

helper.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------- //
00002 //
00003 // MODULE  : helper.h
00004 //
00005 // PURPOSE : Helper functions, etc - Definitions and constants
00006 //
00007 // CREATED : 12/28/00
00008 //
00009 // (c) 2000 LithTech, Inc.  All Rights Reserved
00010 //
00011 // ----------------------------------------------------------------------- //
00012 
00013 #ifndef __HELPER_H__
00014 #define __HELPER_H__
00015 
00016 
00017 // Shared includes
00018 #include "commandids.h"
00019 #include "msgids.h"
00020 
00021 // Engine includes
00022 #include <ltcodes.h>
00023 
00024 
00026 inline const char *LTRESULT_TO_STRING(LTRESULT x)
00027 {
00028     return 
00029     x == LT_OK                          ? "LT_OK" : 
00030     x == LT_ERROR                       ? "LT_ERROR" : 
00031     x == LT_FINISHED                    ? "LT_FINISHED" : 
00032 //  x == VIDEO_STARTED                  ? "VIDEO_STARTED" : 
00033 //  x == VIDEO_ERROR                    ? "VIDEO_ERROR" : 
00034 //  x == VIDEO_PLAYING                  ? "VIDEO_PLAYING" : 
00035 //  x == VIDEO_NOTPLAYING               ? "VIDEO_NOTPLAYING" : 
00036     x == LT_TRIEDTOREMOVECLIENTOBJECT   ? "LT_TRIEDTOREMOVECLIENTOBJECT" : 
00037     x == LT_NOTINWORLD                  ? "LT_NOTINWORLD" : 
00038     x == LT_MISSINGFILE                 ? "LT_MISSINGFILE" : 
00039     x == LT_MISSINGWORLDMODEL           ? "LT_MISSINGWORLDMODEL" : 
00040     x == LT_INVALIDMODELFILE            ? "LT_INVALIDMODELFILE" : 
00041     x == LT_OBJECTNOTINWORLD            ? "LT_OBJECTNOTINWORLD" :
00042     x == LT_CANTREMOVESERVEROBJECT      ? "LT_CANTREMOVESERVEROBJECT" : 
00043     x == LT_CANTLOADGAMERESOURCES       ? "LT_CANTLOADGAMERESOURCES" : 
00044     x == LT_CANTINITIALIZEINPUT         ? "LT_CANTINITIALIZEINPUT" : 
00045     x == LT_MISSINGSHELLDLL             ? "LT_MISSINGSHELLDLL" : 
00046     x == LT_INVALIDSHELLDLL             ? "LT_INVALIDSHELLDLL" : 
00047     x == LT_INVALIDSHELLDLLVERSION      ? "LT_INVALIDSHELLDLLVERSION" : 
00048     x == LT_CANTCREATECLIENTSHELL       ? "LT_CANTCREATECLIENTSHELL" : 
00049     x == LT_UNABLETOINITSOUND           ? "LT_UNABLETOINITSOUND" : 
00050     x == LT_MISSINGMUSICDLL             ? "LT_MISSINGMUSICDLL" : 
00051     x == LT_INVALIDMUSICDLL             ? "LT_INVALIDMUSICDLL" : 
00052     x == LT_UNABLETOINITMUSICDLL        ? "LT_UNABLETOINITMUSICDLL" : 
00053     x == LT_CANTINITDIRECTPLAY          ? "LT_CANTINITDIRECTPLAY" :
00054     x == LT_USERCANCELED                ? "LT_USERCANCELED" : 
00055     x == LT_MISSINGWORLDFILE            ? "LT_MISSINGWORLDFILE" : 
00056     x == LT_INVALIDWORLDFILE            ? "LT_INVALIDWORLDFILE" : 
00057     x == LT_ERRORBINDINGWORLD           ? "LT_ERRORBINDINGWORLD" : 
00058     x == LT_INVALIDSERVERPACKET         ? "LT_INVALIDSERVERPACKET" : 
00059     x == LT_MISSINGSPRITEFILE           ? "LT_MISSINGSPRITEFILE" : 
00060     x == LT_INVALIDSPRITEFILE           ? "LT_INVALIDSPRITEFILE" : 
00061     x == LT_MISSINGMODELFILE            ? "LT_MISSINGMODELFILE" : 
00062     x == LT_UNABLETORESTOREVIDEO        ? "LT_UNABLETORESTOREVIDEO" : 
00063     x == LT_SERVERERROR                 ? "LT_SERVERERROR" : 
00064     x == LT_CANTCREATESERVER            ? "LT_CANTCREATESERVER" : 
00065     x == LT_ERRORLOADINGRENDERDLL       ? "LT_ERRORLOADINGRENDERDLL" : 
00066     x == LT_MISSINGCLASS                ? "LT_MISSINGCLASS" : 
00067     x == LT_CANTCREATESERVERSHELL       ? "LT_CANTCREATESERVERSHELL" : 
00068     x == LT_INVALIDOBJECTDLL            ? "LT_INVALIDOBJECTDLL" : 
00069     x == LT_INVALIDOBJECTDLLVERSION     ? "LT_INVALIDOBJECTDLLVERSION" : 
00070     x == LT_ERRORINITTINGNETDRIVER      ? "LT_ERRORINITTINGNETDRIVER" : 
00071     x == LT_NOGAMERESOURCES             ? "LT_NOGAMERESOURCES" : 
00072     x == LT_CANTRESTOREOBJECT           ? "LT_CANTRESTOREOBJECT" : 
00073     x == LT_NODENOTFOUND                ? "LT_NODENOTFOUND" : 
00074     x == LT_INVALIDPARAMS               ? "LT_INVALIDPARAMS" : 
00075     x == LT_NOTFOUND                    ? "LT_NOTFOUND" : 
00076     x == LT_ALREADYEXISTS               ? "LT_ALREADYEXISTS" : 
00077     x == LT_NOTCONNECTED                ? "LT_NOTCONNECTED" : 
00078     x == LT_INSIDE                      ? "LT_INSIDE" : 
00079     x == LT_OUTSIDE                     ? "LT_OUTSIDE" : 
00080     x == LT_INVALIDDATA                 ? "LT_INVALIDDATA" : 
00081     x == LT_OUTOFMEMORY                 ? "LT_OUTOFMEMORY" : 
00082     x == LT_MISSINGPALETTE              ? "LT_MISSINGPALETTE" : 
00083     x == LT_INVALIDVERSION              ? "LT_INVALIDVERSION" : 
00084     x == LT_NOCHANGE                    ? "LT_NOCHANGE" : 
00085     x == LT_INPUTBUFFEROVERFLOW         ? "LT_INPUTBUFFEROVERFLOW" : 
00086     x == LT_OVERFLOW                    ? "LT_OVERFLOW" : 
00087     x == LT_KEPTSAMEMODE                ? "LT_KEPTSAMEMODE" : 
00088     x == LT_NOTINITIALIZED              ? "LT_NOTINITIALIZED" : 
00089     x == LT_ALREADYIN3D                 ? "LT_ALREADYIN3D" : 
00090     x == LT_NOTIN3D                     ? "LT_NOTIN3D" : 
00091     x == LT_ERRORCOPYINGFILE            ? "LT_ERRORCOPYINGFILE" : 
00092     x == LT_INVALIDFILE                 ? "LT_INVALIDFILE" : 
00093     x == LT_INVALIDNETVERSION           ? "LT_INVALIDNETVERSION" : 
00094     x == LT_TIMEOUT                     ? "LT_TIMEOUT" : 
00095     x == LT_CANTBINDTOPORT              ? "LT_CANTBINDTOPORT" : 
00096     x == LT_REJECTED                    ? "LT_REJECTED" : 
00097     x == LT_NOTSAMEGUID                 ? "LT_NOTSAMEGUID" :
00098     x == LT_UNSUPPORTED                 ? "LT_UNSUPPORTED" : 
00099     x == LT_INPROGRESS                  ? "LT_INPROGRESS" : 
00100     x == LT_NO3DSOUNDPROVIDER           ? "LT_NO3DSOUNDPROVIDER" : 
00101     x == LT_YES                         ? "LT_YES" : 
00102     x == LT_NO                          ? "LT_NO" : 
00103     x == LT_MISSINGCURSORRESOURCE       ? "LT_MISSINGCURSORRESOURCE" : 
00104     x == LT_ESCABORT                    ? "LT_ESCABORT" : 
00105     x == LT_ERRORINITTINGMPM            ? "LT_ERRORINITTINGMPM" : 
00106     x == LT_BUFFERTOOSMALL              ? "LT_BUFFERTOOSMALL" : 
00107     x == LT_ALREADYINITIALIZED          ? "LT_ALREADYINITIALIZED" : 
00108     x == LT_RETRY                       ? "LT_RETRY" : 
00109     "<unknown LTRESULT>";
00110 }
00111 
00112 
00114 inline const char * LTEVENT_TO_STRING(uint32 x)
00115 {
00116     return
00117     x == LTEVENT_DISCONNECT             ? "LTEVENT_DISCONNECT" : 
00118     x == LTEVENT_SHUTDOWN               ? "LTEVENT_SHUTDOWN" : 
00119     x == LTEVENT_RENDERINIT             ? "LTEVENT_RENDERINIT" : 
00120     x == LTEVENT_RENDERTERM             ? "LTEVENT_RENDERTERM" : 
00121     x == LTEVENT_RENDERALMOSTINITTED    ? "LTEVENT_RENDERALMOSTINITTED" : 
00122     x == LTEVENT_LOSTFOCUS              ? "LTEVENT_LOSTFOCUS" : 
00123     x == LTEVENT_GAINEDFOCUS            ? "LTEVENT_GAINEDFOCUS" : 
00124 
00125 #ifdef __NEW_INPUT
00126     x == LTEVENT_DEVICE_CONNECTED       ? "LTEVENT_DEVICE_CONNECTED" : 
00127     x == LTEVENT_DEVICE_DISCONNECTED    ? "LTEVENT_DEVICE_DISCONNECTED" : 
00128     x == LTEVENT_DEVICE_MODE_CHANGE     ? "LTEVENT_DEVICE_MODE_CHANGE" : 
00129     x == LTEVENT_SPLITTER_CONNECTED     ? "LTEVENT_SPLITTER_CONNECTED" : 
00130     x == LTEVENT_SPLITTER_DISCONNECTED  ? "LTEVENT_SPLITTER_DISCONNECTED" : 
00131     x == LTEVENT_DEVICE_WAITING         ? "LTEVENT_DEVICE_WAITING" : 
00132     x == LTEVENT_DEVICE_WAITING_DONE    ? "LTEVENT_DEVICE_WAITING_DONE" : 
00133 #endif
00134 
00135     "<unknown LTEVENT>";
00136 }
00137 
00138 
00140 #ifdef __LTSERVEROBJ_H__
00141 
00142 inline const char * ENGINEMESSAGEID_TO_STRING(uint32 x)
00143 {
00144     return
00145     x == MID_PRECREATE                  ? "MID_PRECREATE" : 
00146     x == MID_OBJECTCREATED              ? "MID_OBJECTCREATED" : 
00147     x == MID_UPDATE                     ? "MID_UPDATE" : 
00148     x == MID_TOUCHNOTIFY                ? "MID_TOUCHNOTIFY" : 
00149     x == MID_LINKBROKEN                 ? "MID_LINKBROKEN" : 
00150     x == MID_MODELSTRINGKEY             ? "MID_MODELSTRINGKEY" : 
00151     x == MID_CRUSH                      ? "MID_CRUSH" : 
00152     x == MID_LOADOBJECT                 ? "MID_LOADOBJECT" : 
00153     x == MID_SAVEOBJECT                 ? "MID_SAVEOBJECT" : 
00154     x == MID_AFFECTPHYSICS              ? "MID_AFFECTPHYSICS" : 
00155     x == MID_PARENTATTACHMENTREMOVED    ? "MID_PARENTATTACHMENTREMOVED" : 
00156     x == MID_GETFORCEUPDATEOBJECTS      ? "MID_GETFORCEUPDATEOBJECTS" : 
00157     x == MID_ACTIVATING                 ? "MID_ACTIVATING" : 
00158     x == MID_DEACTIVATING               ? "MID_DEACTIVATING" : 
00159     x == MID_ALLOBJECTSCREATED          ? "MID_ALLOBJECTSCREATED" : 
00160     x == MID_POSITIONUPDATE             ? "MID_POSITIONUPDATE" : 
00161     x == MID_ROTATIONUPDATE             ? "MID_ROTATIONUPDATE" : 
00162     "<unknown EngineMessageID>";
00163 }
00164 
00165 #endif
00166 
00167 
00169 inline const char * MESSAGEID_TO_STRING(uint8 x)
00170 {
00171     return
00172     x == MSG_STARTPOINT_ROT             ? "MSG_STARTPOINT_ROT" : 
00173     x == MSG_TRIGGER_ENTER              ? "MSG_TRIGGER_ENTER" : 
00174     x == MSG_TRIGGER_EXIT               ? "MSG_TRIGGER_EXIT" : 
00175     "<unknown MessageID>";
00176 }
00177 
00178 
00180 inline const char * COMMANDID_TO_STRING(int x)
00181 {
00182     return
00183     x == CMD_MOVE_FORWARD               ? "CMD_MOVE_FORWARD" : 
00184     x == CMD_MOVE_BACKWARD              ? "CMD_MOVE_BACKWARD" : 
00185     x == CMD_MOVE_LEFT                  ? "CMD_MOVE_LEFT" : 
00186     x == CMD_MOVE_RIGHT                 ? "CMD_MOVE_RIGHT" : 
00187     x == CMD_MOVE_UP                    ? "CMD_MOVE_UP" : 
00188     x == CMD_MOVE_DOWN                  ? "CMD_MOVE_DOWN" : 
00189     x == CMD_ROLL_LEFT                  ? "CMD_ROLL_LEFT" : 
00190     x == CMD_ROLL_RIGHT                 ? "CMD_ROLL_RIGHT" : 
00191     x == CMD_YAW_LEFT                   ? "CMD_YAW_LEFT" : 
00192     x == CMD_YAW_RIGHT                  ? "CMD_YAW_RIGHT" : 
00193     x == CMD_PITCH_UP                   ? "CMD_PITCH_UP" : 
00194     x == CMD_PITCH_DOWN                 ? "CMD_PITCH_DOWN" : 
00195     x == CMD_RESET_VIEW                 ? "CMD_RESET_VIEW" : 
00196     x == CMD_ACTION1                    ? "CMD_ACTION1" : 
00197     x == CMD_ACTION2                    ? "CMD_ACTION2" : 
00198     x == CMD_ACTION3                    ? "CMD_ACTION3" : 
00199     x == CMD_ACTION4                    ? "CMD_ACTION4" : 
00200     x == CMD_SPECIAL1                   ? "CMD_SPECIAL1" : 
00201     x == CMD_SPECIAL2                   ? "CMD_SPECIAL2" : 
00202     x == CMD_MOUSE_BUTTON0              ? "CMD_MOUSE_BUTTON0" : 
00203     x == CMD_MOUSE_BUTTON1              ? "CMD_MOUSE_BUTTON1" : 
00204     x == CMD_MOUSE_BUTTON2              ? "CMD_MOUSE_BUTTON2" : 
00205     x == CMD_CYCLE_PLAYER_STATE         ? "CMD_CYCLE_PLAYER_STATE" : 
00206     x == CMD_CYCLE_CAMERA_STATE         ? "CMD_CYCLE_CAMERA_STATE" : 
00207     x == CMD_TOGGLE_MENU                ? "CMD_TOGGLE_MENU" : 
00208     x == CMD_QUIT                       ? "CMD_QUIT" : 
00209     "<unknown CommandID>";
00210 }
00211 
00212 
00214 inline float g_GetRandom(float min, float max)
00215 {
00216     float randNum = (float)rand() / (float)RAND_MAX;
00217     float num = min + (max - min) * randNum;
00218     return num;
00219 }
00220 
00221 
00223 inline float g_MapJoyDeadZone(uint8 in)
00224 {
00225     // create a deadzone around the center of the range, and then a
00226     // linear response outside that, ranging from -1.0f for the
00227     // smallest input value (0) to 1.0f for the largest input value
00228     // (255).
00229     
00230     uint8 center=128;
00231     uint8 range=35;
00232     
00233     uint8 dzl=center-range;
00234     uint8 dzh=center+range;
00235     
00236     if (in<dzh){
00237         if (in>dzl){
00238             return 0.0f;
00239         } else {
00240             return (dzl-in)/(0.0f-dzl);
00241         }
00242     } else {
00243         return (in-dzh)/(255.0f-dzh);
00244     }
00245 }
00246 
00247 
00248 #endif  // __HELPER_H__

Generated on Mon Mar 4 08:42:23 2002 for Aria by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002