Skip to content

Commit

Permalink
just a the branch says, use cstdint and cstdbool (#7)
Browse files Browse the repository at this point in the history
* use cstdint

* f32, f64, and bools

angelscript.h should not be changed
  • Loading branch information
psi29a authored Apr 7, 2018
1 parent 1555219 commit 7ed464c
Show file tree
Hide file tree
Showing 183 changed files with 4,212 additions and 4,235 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ build/
.idea/
.kdev4/
*.kdev4
cmake-build-debug/
22 changes: 11 additions & 11 deletions BloodXL/BloodXL_Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ BloodXL_Game::BloodXL_Game(const XLEngine_Plugin_API *API)
m_pAPI->RegisterScriptFunc("void Game_LoadMap(string &in)", asFUNCTION(SC_Game_LoadMap));

//We only worry about the UI scripts, palettes, color maps and so on if we're running a client.
if ( m_pAPI->IsServer() == XL_FALSE )
if ( m_pAPI->IsServer() == false )
{
//Start the UI script for title screen.
m_pAPI->Start_UI_Script( "BloodXL/CoreUI.as" );

//load the game palette so that the UI is correct.
u8 *pal = xlNew u8[768*3+1];
u8 *new_pal = xlNew u8[768*3+1];
uint8_t *pal = xlNew uint8_t[768*3+1];
uint8_t *new_pal = xlNew uint8_t[768*3+1];
if ( m_pAPI->GameFile_Open(ARCHIVETYPE_RFF, "BLOOD.RFF", "BLOOD.PAL") )
{
u32 len = m_pAPI->GameFile_GetLength();
uint32_t len = m_pAPI->GameFile_GetLength();
m_pAPI->GameFile_Read(pal, len);
m_pAPI->GameFile_Close();

Expand All @@ -65,16 +65,16 @@ BloodXL_Game::BloodXL_Game(const XLEngine_Plugin_API *API)
"P4.PLU"
};
//load the "PLU" files for different palettes.
u8 *pData = xlNew u8[16385];
for (u32 i=1; i<14; i++)
uint8_t *pData = xlNew uint8_t[16385];
for (uint32_t i=1; i<14; i++)
{
if ( m_pAPI->GameFile_Open(ARCHIVETYPE_RFF, "BLOOD.RFF", aszPLU_Files[i]) )
{
u32 len = m_pAPI->GameFile_GetLength();
uint32_t len = m_pAPI->GameFile_GetLength();
m_pAPI->GameFile_Read(pData, len);
m_pAPI->GameFile_Close();

for (u32 c=0; c<256; c++)
for (uint32_t c=0; c<256; c++)
{
new_pal[ c*3 + 0 ] = pal[ pData[c]*3 + 0 ];
new_pal[ c*3 + 1 ] = pal[ pData[c]*3 + 1 ];
Expand All @@ -92,7 +92,7 @@ BloodXL_Game::BloodXL_Game(const XLEngine_Plugin_API *API)
m_Player = xlNew BloodXL_Player(API);

//If we are running a server, then just load the startup map.
if ( m_pAPI->IsServer() == XL_TRUE )
if ( m_pAPI->IsServer() == true )
{
SC_Game_LoadMap( m_pAPI->Startup_GetStartMap() );
}
Expand Down Expand Up @@ -123,12 +123,12 @@ void BloodXL_Game::PostRender(float dt)
{
}

void BloodXL_Game::KeyDown(s32 key)
void BloodXL_Game::KeyDown(int32_t key)
{
m_Player->KeyDown(key);
}

void BloodXL_Game::NewGame(s32 episode, s32 difficulty)
void BloodXL_Game::NewGame(int32_t episode, int32_t difficulty)
{
char szMapName[32];
sprintf(szMapName, "E%dM1.MAP", episode+1);
Expand Down
10 changes: 5 additions & 5 deletions BloodXL/BloodXL_Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ class BloodXL_Game
void PreRender(float dt);
void PostRender(float dt);

void KeyDown(s32 key);
void KeyDown(int32_t key);

void GetVersion(s32& major, s32& minor) { major = m_nVersionMajor; minor = m_nVersionMinor; }
void GetVersion(int32_t& major, int32_t& minor) { major = m_nVersionMajor; minor = m_nVersionMinor; }

void NewGame(s32 episode, s32 difficulty);
void NewGame(int32_t episode, int32_t difficulty);

private:
const XLEngine_Plugin_API *m_pAPI;
s32 m_nVersionMajor;
s32 m_nVersionMinor;
int32_t m_nVersionMajor;
int32_t m_nVersionMinor;
BloodXL_Player *m_Player;

//Script commands
Expand Down
62 changes: 31 additions & 31 deletions BloodXL/BloodXL_Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#include "../math/Vector3.h"

LOGIC_CB_MAP(BloodXL_Player);
const f32 _VertClamp = 0.785398f;
const f32 m_PlayerHeight = 4.697265625f;
const f32 m_PlayerCrouch = 1.800618409f;
const float _VertClamp = 0.785398f;
const float m_PlayerHeight = 4.697265625f;
const float m_PlayerCrouch = 1.800618409f;
#define CAMERA_ROT_INC 0.0021333333f

f32 m_fAccelInc = 0.01f;
f32 m_fAccelDec = 0.25f;
float m_fAccelInc = 0.01f;
float m_fAccelDec = 0.25f;

BloodXL_Player::BloodXL_Player(const XLEngine_Plugin_API *API)
{
Expand Down Expand Up @@ -40,35 +40,35 @@ BloodXL_Player::~BloodXL_Player(void)
{
}

void BloodXL_Player::LogicSetup(u32 uObjID, u32 uParamCount, LogicParam *param)
void BloodXL_Player::LogicSetup(uint32_t uObjID, uint32_t uParamCount, LogicParam *param)
{
}

void BloodXL_Player::ObjectSetup(u32 uObjID, u32 uParamCount, LogicParam *param)
void BloodXL_Player::ObjectSetup(uint32_t uObjID, uint32_t uParamCount, LogicParam *param)
{
}

void BloodXL_Player::KeyDown(s32 key)
void BloodXL_Player::KeyDown(int32_t key)
{
if ( key == XL_SPACE )
{
Vector3 p0, p1;
p0 = m_PhysicsData->m_Loc; p0.z += m_PlayerHeight;
p1 = p0 + m_PhysicsData->m_Dir*10.0f;

u32 uSector = m_PhysicsData->m_uSector;
uint32_t uSector = m_PhysicsData->m_uSector;
m_pAPI->World_Activate(&p0, &p1, uSector);
}
}

void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
void BloodXL_Player::Update(uint32_t uObjID, uint32_t uParamCount, LogicParam *param)
{
XL_BOOL bUpdateControls = m_pAPI->Engine_AllowPlayerControls();

//Handle player control
//Look
f32 fDeltaX = m_pAPI->GetMouseDx();
f32 fDeltaY = m_pAPI->GetMouseDy();
float fDeltaX = m_pAPI->GetMouseDx();
float fDeltaY = m_pAPI->GetMouseDy();

if ( bUpdateControls )
{
Expand All @@ -89,7 +89,7 @@ void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
}
}
}
static f32 fOldMoveSpd=0.0f;
static float fOldMoveSpd=0.0f;
static Vector3 vLastDir(0.0f, 0.0f, 0.0f);

Vector3 vDir;
Expand All @@ -107,10 +107,10 @@ void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
//Movement
Vector3 vLoc = m_PhysicsData->m_Loc;
Vector3 vel(0.0f, 0.0f, 0.0f);
f32 fSpeed = 0.45699f;
float fSpeed = 0.45699f;
bool bCrouch = false;
static f32 fCameraHeightPrev = m_PlayerHeight;
f32 fCameraHeight = m_PlayerHeight;
static float fCameraHeightPrev = m_PlayerHeight;
float fCameraHeight = m_PlayerHeight;
if ( bUpdateControls )
{
if ( m_pAPI->IsKeyDown( XL_C ) )
Expand Down Expand Up @@ -145,8 +145,8 @@ void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
fCameraHeightPrev = fCameraHeight;

//now we want to find our final move speed.
f32 fDesSpeed = vel.Normalize();
f32 fMoveSpeed = fDesSpeed;
float fDesSpeed = vel.Normalize();
float fMoveSpeed = fDesSpeed;
if ( 1 )
{
float s = (fDesSpeed-fOldMoveSpd) > 0.0f ? 1.0f : -1.0f;
Expand All @@ -168,11 +168,11 @@ void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
fOldMoveSpd = fMoveSpeed;
vel = vel*fMoveSpeed;

f32 fDelta = 0.0f;
f32 fMoveSpd = vel.Normalize();
f32 fPlayerRadius = 1.01f; //was 1.51
float fDelta = 0.0f;
float fMoveSpd = vel.Normalize();
float fPlayerRadius = 1.01f; //was 1.51
//split collision into 1 unit segments.
f32 fPrevZ = vLoc.z;
float fPrevZ = vLoc.z;
if ( fMoveSpd != 0.0f )
{
do
Expand All @@ -193,19 +193,19 @@ void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
vLoc.z += fCameraHeight;

//now do the up/down walking/running movement...
static f32 time_sum = 0.0f;
static f32 time_sum2 = 0.0f;
static f32 fAnimSpd = 0.0f;
const f32 K = 16.0f;
const f32 K2 = 4.0f;
const f32 A = 0.25f;
const f32 dt = 1.0f/60.0f;
static float time_sum = 0.0f;
static float time_sum2 = 0.0f;
static float fAnimSpd = 0.0f;
const float K = 16.0f;
const float K2 = 4.0f;
const float A = 0.25f;
const float dt = 1.0f/60.0f;
if ( 1 )//!m_bJumping && !m_bFalling )
{
time_sum = fmodf(time_sum +dt*K, MATH_TWO_PI);
time_sum2 = fmodf(time_sum2+dt*K2, MATH_TWO_PI);
}
f32 zAnim = sinf( time_sum ) * A * fMoveSpeed * m_PlayerHeight/fCameraHeight;
float zAnim = sinf( time_sum ) * A * fMoveSpeed * m_PlayerHeight/fCameraHeight;
vLoc.z += zAnim;

/*
Expand All @@ -222,6 +222,6 @@ void BloodXL_Player::Update(u32 uObjID, u32 uParamCount, LogicParam *param)
m_pAPI->Engine_SetCameraData( &vLoc.x, &vDir.x, m_PlayerData.m_fPitch, fMoveSpeed, m_PhysicsData->m_uSector );
}

void BloodXL_Player::Message(u32 uObjID, u32 uParamCount, LogicParam *param)
void BloodXL_Player::Message(uint32_t uObjID, uint32_t uParamCount, LogicParam *param)
{
}
18 changes: 9 additions & 9 deletions BloodXL/BloodXL_Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ class BloodXL_Player
~BloodXL_Player(void);

void SetPassthruAdjoins(bool bPassthru) { m_bPassthruAdjoins = bPassthru; }
void KeyDown(s32 key);
void KeyDown(int32_t key);

private:
struct PlayerData
{
u32 m_HP;
f32 m_fYaw;
f32 m_fPitch;
uint32_t m_HP;
float m_fYaw;
float m_fPitch;
};

const XLEngine_Plugin_API *m_pAPI;
u32 m_uObjID;
uint32_t m_uObjID;
PlayerData m_PlayerData;
ObjectPhysicsData *m_PhysicsData;
bool m_bPassthruAdjoins;

void LogicSetup(u32 uObjID, u32 uParamCount, LogicParam *param);
void ObjectSetup(u32 uObjID, u32 uParamCount, LogicParam *param);
void Update(u32 uObjID, u32 uParamCount, LogicParam *param);
void Message(u32 uObjID, u32 uParamCount, LogicParam *param);
void LogicSetup(uint32_t uObjID, uint32_t uParamCount, LogicParam *param);
void ObjectSetup(uint32_t uObjID, uint32_t uParamCount, LogicParam *param);
void Update(uint32_t uObjID, uint32_t uParamCount, LogicParam *param);
void Message(uint32_t uObjID, uint32_t uParamCount, LogicParam *param);

LOGIC_CB_FUNC();
};
Expand Down
8 changes: 4 additions & 4 deletions BloodXL/BloodXL_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
BloodXL_Game *m_pGame=NULL;

//Interface between Game classes and C library interface.
void BloodXL_Update(s32 stage, f32 dt, XLEngine_Plugin_API *API, void *pUserData)
void BloodXL_Update(int32_t stage, float dt, XLEngine_Plugin_API *API, void *pUserData)
{
if ( stage == UPDATE_STAGE_FIXED )
{
Expand All @@ -17,7 +17,7 @@ void BloodXL_Update(s32 stage, f32 dt, XLEngine_Plugin_API *API, void *pUserData
}
}

void BloodXL_Render(s32 stage, f32 dt, XLEngine_Plugin_API *API, void *pUserData)
void BloodXL_Render(int32_t stage, float dt, XLEngine_Plugin_API *API, void *pUserData)
{
if ( stage == RENDER_STAGE_PREWORLD )
{
Expand All @@ -29,7 +29,7 @@ void BloodXL_Render(s32 stage, f32 dt, XLEngine_Plugin_API *API, void *pUserData
}
}

void BloodXL_KeyDownCallback(s32 key)
void BloodXL_KeyDownCallback(int32_t key)
{
m_pGame->KeyDown(key);
}
Expand All @@ -49,7 +49,7 @@ void BloodXL_DestroyGame()
}

//Dynamic library C interface.
extern "C" PLUGIN_API s32 ExitFunc()
extern "C" PLUGIN_API int32_t ExitFunc()
{
BloodXL_DestroyGame();

Expand Down
34 changes: 5 additions & 29 deletions CommonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#define COMMON_TYPES_H

#include "PlatformDef.h"
#include <string.h>
#include <cstring>
#include <cstdint>
#include <cstdbool>

#if PLATFORM_WIN

Expand Down Expand Up @@ -33,33 +35,9 @@
#define xlDelete delete
#endif

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

typedef char s8;
typedef short s16;
typedef int s32;
typedef long long s64;

typedef float f32;
typedef double f64;

#elif PLATFORM_LINUX

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

typedef char s8;
typedef short s16;
typedef int s32;
typedef long long s64;

typedef float f32;
typedef double f64;

#define stricmp strcasecmp
#define strnicmp strncasecmp
Expand All @@ -77,12 +55,10 @@ typedef double f64;

#endif

typedef s32 XL_BOOL;
#define XL_TRUE 1
#define XL_FALSE 0
typedef int32_t XL_BOOL;

#define XL_INVALID_TEXTURE 0xffffffff
typedef u32 TextureHandle;
typedef uint32_t TextureHandle;

//Make sure that the point is non-null before delete. Set to NULL.
#define SafeDeleteArr(p) if (p) { xlDelete [] (p); (p) = NULL; }
Expand Down
Loading

0 comments on commit 7ed464c

Please sign in to comment.