mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Fix all compiler warnings in rwengine.
This commit is contained in:
parent
637a6b97ab
commit
185ba23f05
@ -16,4 +16,10 @@ target_link_libraries(rwengine
|
||||
mad
|
||||
${OPENRW_PLATFORM_LIBS})
|
||||
|
||||
include_directories(include ${BULLET_INCLUDE_DIR})
|
||||
include_directories(SYSTEM
|
||||
${BULLET_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
include
|
||||
)
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <SFML/Audio.hpp>
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <rw/defines.hpp>
|
||||
|
||||
static inline
|
||||
signed int scale(mad_fixed_t sample)
|
||||
@ -69,6 +70,8 @@ class MADStream : public sf::SoundStream
|
||||
static mad_flow ms_output(void* user, mad_header const* header,
|
||||
mad_pcm* pcm)
|
||||
{
|
||||
RW_UNUSED(header);
|
||||
|
||||
MADStream* self = static_cast<MADStream*>(user);
|
||||
|
||||
int nsamples = pcm->length;
|
||||
@ -92,6 +95,9 @@ class MADStream : public sf::SoundStream
|
||||
|
||||
static mad_flow ms_error(void* user, mad_stream* stream, mad_frame* frame)
|
||||
{
|
||||
RW_UNUSED(user);
|
||||
RW_UNUSED(frame);
|
||||
|
||||
sf::err() << "libmad error: " << mad_stream_errorstr(stream);
|
||||
return MAD_FLOW_BREAK;
|
||||
}
|
||||
@ -106,6 +112,7 @@ class MADStream : public sf::SoundStream
|
||||
|
||||
virtual void onSeek(sf::Time timeOffset)
|
||||
{
|
||||
RW_UNUSED(timeOffset);
|
||||
/// @todo support seeking.
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,20 @@ struct OnscreenText
|
||||
/// Help text (top left, black background)
|
||||
Help = 12
|
||||
};
|
||||
|
||||
OnscreenText(const std::string& id,
|
||||
const std::string& string,
|
||||
float start,
|
||||
float time,
|
||||
unsigned short style,
|
||||
const std::string& var = "")
|
||||
: id (id)
|
||||
, osTextString(string)
|
||||
, osTextStart(start)
|
||||
, osTextTime(time)
|
||||
, osTextStyle(style)
|
||||
, osTextVar(var)
|
||||
{ }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
constexpr size_t maxInventorySlots = 13;
|
||||
constexpr int maxInventorySlots = 13;
|
||||
|
||||
// Animation slots used for character animation blending
|
||||
constexpr unsigned int AnimIndexMovement = 0;
|
||||
|
@ -13,7 +13,7 @@ class CutsceneObject : public GameObject
|
||||
|
||||
public:
|
||||
|
||||
CutsceneObject(GameWorld* engine, const glm::vec3& pos, const ModelRef& model);
|
||||
CutsceneObject(GameWorld* engine, const glm::vec3& pos, const glm::quat& rot, const ModelRef& model);
|
||||
~CutsceneObject();
|
||||
|
||||
Type type() { return Cutscene; }
|
||||
|
@ -11,7 +11,6 @@ public:
|
||||
~DebugDraw();
|
||||
|
||||
void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color);
|
||||
void drawTriangle(const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &color, btScalar alpha);
|
||||
void drawContactPoint(const btVector3 &pointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color);
|
||||
void reportErrorWarning(const char *warningString);
|
||||
void draw3dText(const btVector3 &location, const char *textString);
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
/**
|
||||
* Renders a model (who'd have thought)
|
||||
*/
|
||||
void renderModel(Model*, const glm::mat4& modelMatrix, GameObject* = nullptr, Animator* animator = nullptr);
|
||||
void renderModel(Model*, const glm::mat4& modelMatrix, GameObject* = nullptr);
|
||||
|
||||
void renderGeometry(Model*, size_t geom, const glm::mat4& modelMatrix, float opacity, GameObject* = nullptr);
|
||||
|
||||
|
@ -12,14 +12,23 @@ class ScriptDisassembly
|
||||
{
|
||||
public:
|
||||
|
||||
enum
|
||||
{
|
||||
/// The opcode's conditional is negated
|
||||
OpcodeFlagNegatedConditional = 1
|
||||
};
|
||||
|
||||
/**
|
||||
* Information about a single call to a single opcode and
|
||||
* it's parameters
|
||||
*/
|
||||
struct InstructionInfo
|
||||
{
|
||||
/// Numeric Opcode ID
|
||||
SCMOpcode opcode;
|
||||
/// Parameter information
|
||||
SCMParams parameters;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
ScriptDisassembly(SCMOpcodes* codes, SCMFile* scm);
|
||||
@ -42,4 +51,4 @@ private:
|
||||
std::map<SCMAddress, InstructionInfo> instructions;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -152,6 +152,20 @@ struct SCMBreakpointInfo
|
||||
SCMThread::pc_t programCounter;
|
||||
char threadName[17];
|
||||
|
||||
bool operator == (const SCMBreakpointInfo& rhs) const
|
||||
{
|
||||
if (breakpointFlags != rhs.breakpointFlags) return false;
|
||||
if ((breakpointFlags & BP_ProgramCounter) != 0)
|
||||
{
|
||||
if (programCounter != rhs.programCounter) return false;
|
||||
}
|
||||
if ((breakpointFlags & BP_ThreadName) != 0)
|
||||
{
|
||||
if (strncmp(threadName, rhs.threadName, 17) != 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static SCMBreakpointInfo breakThreadName(char threadName[17])
|
||||
{
|
||||
SCMBreakpointInfo i;
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
template<class Tret> ScriptFunction conditional_facade(Tret(*f)(const ScriptArguments&)) { return f; }
|
||||
template<> ScriptFunction conditional_facade<bool>(bool(*f)(const ScriptArguments&));
|
||||
|
||||
template<class Tret> bool is_conditional(Tret(*f)(const ScriptArguments&)) { return false; }
|
||||
template<class Tret> bool is_conditional(Tret(*)(const ScriptArguments&)) { return false; }
|
||||
template<> bool is_conditional<bool>(bool(*f)(const ScriptArguments&));
|
||||
|
||||
// Macro to automatically use function name.
|
||||
@ -45,4 +45,4 @@ template<> bool is_conditional<bool>(bool(*f)(const ScriptArguments&));
|
||||
#define bindUnimplemented(id, func, argc, desc) \
|
||||
bind(id, 0, false, argc, #func, desc)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -98,7 +98,7 @@ void AIGraph::gatherExternalNodesNear(const glm::vec3& center, const float radiu
|
||||
for( int y = minGrid.y; y <= maxGrid.y; ++y )
|
||||
{
|
||||
int i = (x * WORLD_GRID_WIDTH) + y;
|
||||
if( i < 0 || i >= gridNodes.size() )
|
||||
if( i < 0 || i >= (int)gridNodes.size() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -146,6 +146,8 @@ bool Activities::GoTo::update(CharacterObject *character, CharacterController *c
|
||||
|
||||
bool Activities::Jump::update(CharacterObject* character, CharacterController* controller)
|
||||
{
|
||||
RW_UNUSED(controller);
|
||||
|
||||
if( !jumped )
|
||||
{
|
||||
character->jump();
|
||||
@ -163,6 +165,8 @@ bool Activities::Jump::update(CharacterObject* character, CharacterController* c
|
||||
|
||||
bool Activities::EnterVehicle::update(CharacterObject *character, CharacterController *controller)
|
||||
{
|
||||
RW_UNUSED(controller);
|
||||
|
||||
// Boats don't have any kind of entry animation unless you're onboard.
|
||||
if( vehicle->vehicle->type == VehicleData::BOAT ) {
|
||||
character->enterVehicle(vehicle, seat);
|
||||
@ -258,6 +262,8 @@ bool Activities::EnterVehicle::update(CharacterObject *character, CharacterContr
|
||||
|
||||
bool Activities::ExitVehicle::update(CharacterObject *character, CharacterController *controller)
|
||||
{
|
||||
RW_UNUSED(controller);
|
||||
|
||||
if( character->getCurrentVehicle() == nullptr ) return true;
|
||||
|
||||
auto vehicle = character->getCurrentVehicle();
|
||||
@ -305,6 +311,8 @@ bool Activities::ExitVehicle::update(CharacterObject *character, CharacterContro
|
||||
#include <data/Model.hpp>
|
||||
bool Activities::ShootWeapon::update(CharacterObject *character, CharacterController *controller)
|
||||
{
|
||||
RW_UNUSED(controller);
|
||||
|
||||
auto& wepdata = _item->getWeaponData();
|
||||
|
||||
// Instant hit weapons loop their anim
|
||||
|
@ -191,7 +191,6 @@ void GameData::addIDE(const std::string& name)
|
||||
|
||||
bool GameData::loadObjects(const std::string& name)
|
||||
{
|
||||
auto i = ideLocations.find(name);
|
||||
std::string path = name;
|
||||
|
||||
LoaderIDE idel;
|
||||
@ -226,6 +225,8 @@ uint16_t GameData::findModelObject(const std::string model)
|
||||
|
||||
void GameData::loadCOL(const size_t zone, const std::string& name)
|
||||
{
|
||||
RW_UNUSED(zone);
|
||||
|
||||
LoaderCOL col;
|
||||
|
||||
std::string realPath = fixPath(name);
|
||||
|
@ -1,29 +1,26 @@
|
||||
#include <engine/GameState.hpp>
|
||||
|
||||
GameState::GameState()
|
||||
: basic{}
|
||||
, playerInfo{}
|
||||
, gameStats{}
|
||||
, gameTime(0.f),
|
||||
currentProgress(0),
|
||||
maxProgress(1),
|
||||
maxWantedLevel(0)
|
||||
: gameTime(0.f)
|
||||
, currentProgress(0)
|
||||
, maxProgress(1)
|
||||
, maxWantedLevel(0)
|
||||
, playerObject(0)
|
||||
, scriptOnMissionFlag(nullptr),
|
||||
fadeOut(true),
|
||||
fadeStart(0.f),
|
||||
fadeTime(0.f),
|
||||
fadeSound(false),
|
||||
skipCutscene(false),
|
||||
isIntroPlaying(false),
|
||||
currentCutscene(nullptr),
|
||||
cutsceneStartTime(-1.f),
|
||||
isCinematic(false),
|
||||
cameraNear(0.1f),
|
||||
cameraFixed(false),
|
||||
cameraTarget(0),
|
||||
world(nullptr),
|
||||
script(nullptr)
|
||||
, scriptOnMissionFlag(nullptr)
|
||||
, fadeOut(true)
|
||||
, fadeStart(0.f)
|
||||
, fadeTime(0.f)
|
||||
, fadeSound(false)
|
||||
, skipCutscene(false)
|
||||
, isIntroPlaying(false)
|
||||
, currentCutscene(nullptr)
|
||||
, cutsceneStartTime(-1.f)
|
||||
, isCinematic(false)
|
||||
, cameraNear(0.1f)
|
||||
, cameraFixed(false)
|
||||
, cameraTarget(0)
|
||||
, world(nullptr)
|
||||
, script(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -311,6 +311,7 @@ CutsceneObject *GameWorld::createCutsceneObject(const uint16_t id, const glm::ve
|
||||
auto instance = new CutsceneObject(
|
||||
this,
|
||||
pos,
|
||||
rot,
|
||||
m);
|
||||
|
||||
cutscenePool.insert( instance );
|
||||
|
@ -471,59 +471,9 @@ struct Block19Data {
|
||||
|
||||
void SaveGame::writeGame(GameState& state, const std::string& file)
|
||||
{
|
||||
std::FILE* saveFile = std::fopen(file.c_str(), "w");
|
||||
|
||||
// BLOCK 0 - Variables
|
||||
BasicState stateCopy = state.basic;
|
||||
|
||||
BlockSize block0Size = sizeof(BasicState);
|
||||
fwrite(&block0Size, sizeof(BlockSize), 1, saveFile);
|
||||
fwrite(&state.basic, sizeof(BasicState), 1, saveFile);
|
||||
|
||||
// BLOCK 0 - 0 Script
|
||||
const char header[4] = "SCR";
|
||||
BlockSize block0ScriptSize = sizeof(Block0ScriptData);
|
||||
BlockSize block0ScriptHeaderSize = block0ScriptSize + sizeof(char) * 4 + sizeof(BlockDword);
|
||||
fwrite(header, sizeof(char), 4, saveFile);
|
||||
fwrite(&block0ScriptHeaderSize, sizeof(BlockSize), 1, saveFile);
|
||||
BlockDword scriptVariablesCount = state.script->getGlobalData().size();
|
||||
fwrite(&scriptVariablesCount, sizeof(BlockDword), 1, saveFile);
|
||||
fwrite(state.script->getGlobals(), sizeof(SCMByte), scriptVariablesCount, saveFile);
|
||||
|
||||
BlockDword scriptDataSize = 0x03C8;
|
||||
fwrite(&scriptDataSize, sizeof(BlockDword), 1, saveFile);
|
||||
|
||||
Block0ScriptData block0ScriptData = {};
|
||||
block0ScriptData.onMissionOffset = (BlockDword)((SCMByte*)state.scriptOnMissionFlag - state.script->getGlobals());
|
||||
block0ScriptData.lastMissionPassedTime = 0;
|
||||
block0ScriptData.scriptRunning = 1;
|
||||
block0ScriptData.mainSize = state.script->getFile()->getMainSize();
|
||||
block0ScriptData.largestMissionSize = state.script->getFile()->getLargestMissionSize();
|
||||
block0ScriptData.missionCount = state.script->getFile()->getMissionOffsets().size();
|
||||
fwrite(&block0ScriptData, sizeof(block0ScriptData), 1, saveFile);
|
||||
|
||||
BlockDword scriptCount = state.script->getThreads().size();
|
||||
fwrite(&scriptCount, sizeof(BlockDword), 1, saveFile);
|
||||
|
||||
for(SCMThread& thread : state.script->getThreads())
|
||||
{
|
||||
Block0RunningScript script = {};
|
||||
strcpy(script.name, thread.name);
|
||||
script.programCounter = thread.programCounter;
|
||||
for(int i = 0; i < SCM_STACK_DEPTH; i++) {
|
||||
script.stack[i] = thread.calls[i];
|
||||
}
|
||||
script.stackCounter = thread.stackDepth;
|
||||
for(int i = 0; i < sizeof(Block0RunningScript::variables); i++) {
|
||||
script.variables[i] = thread.locals[i];
|
||||
}
|
||||
script.timerA = *(BlockDword*)(thread.locals.data() + 16 * sizeof ( SCMByte ) * 4);
|
||||
script.timerB = *(BlockDword*)(thread.locals.data() + 16 * sizeof ( SCMByte ) * 4);
|
||||
script.ifFlag = thread.conditionResult;
|
||||
script.wakeTimer = thread.wakeCounter;
|
||||
script.ifNumber = thread.conditionCount;
|
||||
fwrite(&script, sizeof(block0ScriptData), 1, saveFile);
|
||||
}
|
||||
RW_UNUSED(state);
|
||||
RW_UNUSED(file);
|
||||
RW_UNIMPLEMENTED("Saving the game is not implemented yet.");
|
||||
}
|
||||
|
||||
template<class T> bool readBlock(std::FILE* str, T& out) {
|
||||
@ -605,18 +555,21 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
}
|
||||
|
||||
BlockDword scriptDataBlockSize;
|
||||
fread(&scriptDataBlockSize, sizeof(BlockDword), 1, loadFile);
|
||||
READ_SIZE(scriptDataBlockSize);
|
||||
if( scriptDataBlockSize != 0x03C8 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block0ScriptData scriptData;
|
||||
fread(&scriptData, sizeof(Block0ScriptData), 1, loadFile);
|
||||
READ_VALUE(scriptData);
|
||||
|
||||
BlockDword numScripts;
|
||||
READ_SIZE(numScripts)
|
||||
Block0RunningScript scripts[numScripts];
|
||||
fread(scripts, sizeof(Block0RunningScript), numScripts, loadFile);
|
||||
for (size_t i = 0; i < numScripts; ++i)
|
||||
{
|
||||
READ_VALUE(scripts[i]);
|
||||
}
|
||||
|
||||
// BLOCK 1
|
||||
BlockDword playerBlockSize;
|
||||
@ -668,7 +621,10 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
READ_VALUE(garageData.cars)
|
||||
|
||||
StructGarage garages[garageData.garageCount];
|
||||
fread(garages, sizeof(StructGarage), garageData.garageCount, loadFile);
|
||||
for (size_t i = 0; i < garageData.garageCount; ++i)
|
||||
{
|
||||
READ_VALUE(garages[i]);
|
||||
}
|
||||
|
||||
#if RW_DEBUG
|
||||
std::cout << "Garages: " << garageData.garageCount << std::endl;
|
||||
@ -697,7 +653,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
READ_VALUE(boatCount)
|
||||
|
||||
Block3Vehicle vehicles[vehicleCount];
|
||||
for(int v = 0; v < vehicleCount; ++v) {
|
||||
for(size_t v = 0; v < vehicleCount; ++v) {
|
||||
Block3Vehicle& veh = vehicles[v];
|
||||
READ_VALUE(veh.unknown1)
|
||||
READ_VALUE(veh.modelId)
|
||||
@ -708,7 +664,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
#endif
|
||||
}
|
||||
Block3Boat boats[boatCount];
|
||||
for(int v = 0; v < boatCount; ++v) {
|
||||
for(size_t v = 0; v < boatCount; ++v) {
|
||||
Block3Boat& veh = boats[v];
|
||||
READ_VALUE(veh.unknown1)
|
||||
READ_VALUE(veh.modelId)
|
||||
@ -729,7 +685,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
READ_VALUE(objectCount);
|
||||
|
||||
Block4Object objects[objectCount];
|
||||
for(int o = 0; o < objectCount; ++o)
|
||||
for(size_t o = 0; o < objectCount; ++o)
|
||||
{
|
||||
Block4Object &obj = objects[o];
|
||||
READ_VALUE(obj.modelId)
|
||||
@ -749,7 +705,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
|
||||
#if RW_DEBUG
|
||||
std::cout << "Objects " << objectCount << std::endl;
|
||||
for (int o = 0; o < objectCount; ++o) {
|
||||
for (size_t o = 0; o < objectCount; ++o) {
|
||||
std::cout << objects[o].modelId << " ";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
@ -763,7 +719,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
|
||||
BlockDword numPaths;
|
||||
READ_VALUE(numPaths)
|
||||
for (int b = 0; b < numPaths; ++b) {
|
||||
for (size_t b = 0; b < numPaths; ++b) {
|
||||
uint8_t bits;
|
||||
READ_VALUE(bits)
|
||||
}
|
||||
@ -777,14 +733,14 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
Block6Data craneData;
|
||||
READ_VALUE(craneData.numCranes)
|
||||
READ_VALUE(craneData.militaryCollected)
|
||||
for(int c = 0; c < craneData.numCranes; ++c) {
|
||||
for(size_t c = 0; c < craneData.numCranes; ++c) {
|
||||
Block6Crane &crane = craneData.cranes[c];
|
||||
READ_VALUE(crane)
|
||||
}
|
||||
|
||||
#if RW_DEBUG
|
||||
std::cout << "Cranes: " << craneData.numCranes << std::endl;
|
||||
for(int c = 0; c < craneData.numCranes; ++c) {
|
||||
for(size_t c = 0; c < craneData.numCranes; ++c) {
|
||||
Block6Crane &crane = craneData.cranes[c];
|
||||
std::cout << "pickup " << crane.x1Pickup << " " << crane.y1Pickup << " " << crane.x2Pickup << " " << crane.y2Pickup << std::endl;
|
||||
std::cout << "vehicles collected " << uint16_t(crane.vehiclesCollected) << std::endl;
|
||||
@ -817,14 +773,14 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
Block8Data phoneData;
|
||||
READ_VALUE(phoneData);
|
||||
Block8Phone phones[phoneData.numPhones];
|
||||
for (int p = 0; p < phoneData.numPhones; ++p) {
|
||||
for (size_t p = 0; p < phoneData.numPhones; ++p) {
|
||||
Block8Phone &phone = phones[p];
|
||||
READ_VALUE(phone)
|
||||
}
|
||||
|
||||
#if RW_DEBUG
|
||||
std::cout << "Phones: " << phoneData.numPhones << std::endl;
|
||||
for (int p = 0; p < phoneData.numPhones; ++p) {
|
||||
for (size_t p = 0; p < phoneData.numPhones; ++p) {
|
||||
Block8Phone &phone = phones[p];
|
||||
std::cout << " " << uint16_t(phone.state) << " " << phone.position.x << " " << phone.position.y << " " << phone.position.z << std::endl;
|
||||
}
|
||||
@ -967,13 +923,13 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
READ_VALUE(carGeneratorData);
|
||||
|
||||
Block13CarGenerator carGenerators[carGeneratorData.generatorCount];
|
||||
for(int g = 0; g < carGeneratorData.generatorCount; ++g) {
|
||||
for(size_t g = 0; g < carGeneratorData.generatorCount; ++g) {
|
||||
READ_VALUE(carGenerators[g])
|
||||
}
|
||||
|
||||
#if RW_DEBUG
|
||||
std::cout << "Car generators: " << carGeneratorData.generatorCount << std::endl;
|
||||
for(int g = 0; g < carGeneratorData.generatorCount; ++g) {
|
||||
for(size_t g = 0; g < carGeneratorData.generatorCount; ++g) {
|
||||
Block13CarGenerator &gen = carGenerators[g];
|
||||
std::cout << " " << gen.modelId << " " << gen.position.x << " "<< gen.position.y << " " << gen.position.z << std::endl;
|
||||
}
|
||||
@ -988,7 +944,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
BlockDword particleCount;
|
||||
READ_VALUE(particleCount);
|
||||
Block14Particle particles[particleCount];
|
||||
for(int p = 0; p < particleCount; ++p) {
|
||||
for(size_t p = 0; p < particleCount; ++p) {
|
||||
READ_VALUE(particles[p])
|
||||
}
|
||||
|
||||
@ -1008,7 +964,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
READ_VALUE(audioCount)
|
||||
|
||||
Block15AudioObject audioObjects[audioCount];
|
||||
for(int a = 0; a < audioCount; ++a) {
|
||||
for(size_t a = 0; a < audioCount; ++a) {
|
||||
READ_VALUE(audioObjects[a])
|
||||
}
|
||||
|
||||
@ -1153,7 +1109,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
state.scriptOnMissionFlag = (unsigned int*)state.script->getGlobals() + (size_t)scriptData.onMissionOffset;
|
||||
|
||||
auto& threads = state.script->getThreads();
|
||||
for(int s = 0; s < numScripts; ++s) {
|
||||
for(size_t s = 0; s < numScripts; ++s) {
|
||||
state.script->startThread(scripts[s].programCounter);
|
||||
SCMThread& thread = threads.back();
|
||||
// thread.baseAddress // ??
|
||||
@ -1166,7 +1122,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
}
|
||||
/* TODO not hardcode +33 ms */
|
||||
thread.wakeCounter = scripts[s].wakeTimer - state.basic.lastTick + 33;
|
||||
for(int i = 0; i < sizeof(Block0RunningScript::variables); ++i) {
|
||||
for(size_t i = 0; i < sizeof(Block0RunningScript::variables); ++i) {
|
||||
thread.locals[i] = scripts[s].variables[i];
|
||||
}
|
||||
}
|
||||
@ -1190,29 +1146,13 @@ bool SaveGame::loadGame(GameState& state, const std::string& file)
|
||||
|
||||
// TODO restore garage data
|
||||
// http://gtaforums.com/topic/758692-gta-iii-save-file-documentation/
|
||||
for(int g = 0; g < garageData.garageCount; ++g) {
|
||||
for(size_t g = 0; g < garageData.garageCount; ++g) {
|
||||
auto& garage = garages[g];
|
||||
state.garages.push_back({
|
||||
glm::vec3(garage.x1, garage.y1, garage.z1),
|
||||
glm::vec3(garage.x2, garage.y2, garage.z2),
|
||||
garage.type
|
||||
});
|
||||
auto& gameGarage = state.garages.back();
|
||||
auto center = (gameGarage.min + gameGarage.max)/2.f;
|
||||
// Find the nearest dynamic instance?
|
||||
float distance = std::numeric_limits<float>::max();
|
||||
GameObject* nearinst = nullptr;
|
||||
for(std::pair<GameObjectID, GameObject*> object : state.world->instancePool.objects) {
|
||||
auto instance = static_cast<InstanceObject*>(object.second);
|
||||
if( instance->dynamics ) {
|
||||
float idist = glm::distance(center, instance->getPosition());
|
||||
if( idist < distance ) {
|
||||
distance = idist;
|
||||
nearinst = instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Nearinst is probably the garage door.
|
||||
}
|
||||
for(int c = 0; c < 18; ++c) {
|
||||
if(garageData.cars[c].modelId == 0) continue;
|
||||
@ -1298,7 +1238,7 @@ std::vector< SaveGameInfo > SaveGame::getAllSaveGameInfo()
|
||||
realName = ep->d_name;
|
||||
if(realName.find(".b") != realName.npos) {
|
||||
std::string path = gamePath+"/"+realName;
|
||||
infos.emplace_back(SaveGameInfo{path, false, {}});
|
||||
infos.emplace_back(SaveGameInfo{path, false, BasicState()});
|
||||
infos.back().valid = getSaveInfo(infos.back().savePath, &infos.back().basicState);
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,6 @@ void WeaponItem::fireHitscan(CharacterObject* owner)
|
||||
auto handPos = glm::vec3(handMatrix * glm::vec4(0.f, 0.f, 0.f, 1.f));
|
||||
auto fireOrigin = owner->getPosition() +
|
||||
owner->getRotation() * handPos;
|
||||
auto flashDir = owner->getRotation() * glm::vec3{0.f, 0.f, 1.f};
|
||||
auto flashUp = owner->getRotation() * glm::vec3{0.f, -1.f, 0.f};
|
||||
|
||||
owner->engine->doWeaponScan(WeaponScan(_wepData->damage, fireOrigin, farTarget, _wepData.get()));
|
||||
|
||||
@ -34,6 +32,9 @@ void WeaponItem::fireHitscan(CharacterObject* owner)
|
||||
// - Some circle particle used for the tracer
|
||||
// - smoke emited at hit point
|
||||
// - gunflash
|
||||
#if 0 // Should be merged into the VisualFX system
|
||||
auto flashDir = owner->getRotation() * glm::vec3{0.f, 0.f, 1.f};
|
||||
auto flashUp = owner->getRotation() * glm::vec3{0.f, -1.f, 0.f};
|
||||
|
||||
auto tracerTex = owner->engine->data->findTexture("shad_exp")->getName();
|
||||
auto flashTex = owner->engine->data->findTexture("gunflash2")->getName();
|
||||
@ -91,6 +92,7 @@ void WeaponItem::fireHitscan(CharacterObject* owner)
|
||||
flashUp
|
||||
});
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void WeaponItem::fireProjectile(CharacterObject* owner)
|
||||
@ -137,7 +139,7 @@ void WeaponItem::primary(CharacterObject* owner)
|
||||
|
||||
void WeaponItem::secondary(CharacterObject* owner)
|
||||
{
|
||||
|
||||
RW_UNUSED(owner);
|
||||
}
|
||||
|
||||
void WeaponItem::fire(CharacterObject* owner)
|
||||
|
@ -18,13 +18,15 @@ CharacterObject::CharacterObject(GameWorld* engine, const glm::vec3& pos, const
|
||||
, currentState({})
|
||||
, currentVehicle(nullptr)
|
||||
, currentSeat(0)
|
||||
, ped(data)
|
||||
, physCharacter(nullptr)
|
||||
, running(false)
|
||||
, jumped(false)
|
||||
, controller(nullptr)
|
||||
, jumpSpeed(DefaultJumpSpeed)
|
||||
, motionBlockedByActivity(false)
|
||||
, ped(data)
|
||||
, physCharacter(nullptr)
|
||||
, physObject(nullptr)
|
||||
, physShape(nullptr)
|
||||
, controller(nullptr)
|
||||
{
|
||||
// TODO move AnimationGroup creation somewhere else.
|
||||
animations.idle = engine->data->animations["idle_stance"];
|
||||
@ -457,7 +459,7 @@ bool CharacterObject::enterVehicle(VehicleObject* vehicle, size_t seat)
|
||||
|
||||
bool CharacterObject::isStopped() const
|
||||
{
|
||||
RW_UNIMPLEMENTED("Checking if character is stopped")
|
||||
RW_UNIMPLEMENTED("Checking if character is stopped");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,10 @@
|
||||
#include <engine/Animator.hpp>
|
||||
#include <data/Skeleton.hpp>
|
||||
|
||||
CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos, const ModelRef& model)
|
||||
: GameObject(engine, pos, {}, model), _parent(nullptr), _bone(nullptr)
|
||||
CutsceneObject::CutsceneObject(GameWorld *engine, const glm::vec3 &pos, const glm::quat& rot, const ModelRef& model)
|
||||
: GameObject(engine, pos, rot, model)
|
||||
, _parent(nullptr)
|
||||
, _bone(nullptr)
|
||||
{
|
||||
skeleton = new Skeleton;
|
||||
animator = new Animator(model->resource, skeleton);
|
||||
|
@ -8,5 +8,6 @@ GenericPickup::GenericPickup(GameWorld* world, const glm::vec3& position, int mo
|
||||
|
||||
bool GenericPickup::onCharacterTouch(CharacterObject* character)
|
||||
{
|
||||
RW_UNUSED(character);
|
||||
return true;
|
||||
}
|
||||
|
@ -151,11 +151,14 @@ glm::quat VehicleObject::getRotation() const
|
||||
|
||||
void VehicleObject::tick(float dt)
|
||||
{
|
||||
RW_UNUSED(dt);
|
||||
// Moved to tickPhysics
|
||||
}
|
||||
|
||||
void VehicleObject::tickPhysics(float dt)
|
||||
{
|
||||
RW_UNUSED(dt);
|
||||
|
||||
if( physVehicle )
|
||||
{
|
||||
// todo: a real engine function
|
||||
@ -314,7 +317,7 @@ void VehicleObject::tickPhysics(float dt)
|
||||
if(it.second.body == nullptr) continue;
|
||||
auto inv = glm::inverse(getRotation());
|
||||
auto rot = it.second.body->getWorldTransform().getRotation();
|
||||
auto pos = it.second.body->getWorldTransform().getOrigin();
|
||||
//auto pos = it.second.body->getWorldTransform().getOrigin();
|
||||
auto r2 = inv * glm::quat(rot.w(), rot.x(), rot.y(), rot.z());
|
||||
//auto p2 = inv * (glm::vec3(pos.x(), pos.y(), pos.z()) - getPosition());
|
||||
|
||||
@ -603,7 +606,10 @@ void VehicleObject::registerPart(ModelFrame* mf)
|
||||
normal,
|
||||
damage,
|
||||
nullptr, nullptr,
|
||||
false, 0.f
|
||||
false,
|
||||
0.f,
|
||||
0.f,
|
||||
0.f
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -51,45 +51,13 @@ void DebugDraw::drawLine(const btVector3 &from, const btVector3 &to, const btVec
|
||||
});
|
||||
}
|
||||
|
||||
void DebugDraw::drawTriangle(const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &color, btScalar alpha)
|
||||
{
|
||||
/*glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
float img[] = {color.getX(), color.getY(), color.getZ()};
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0, GL_RGB, 1, 1,
|
||||
0, GL_RGB, GL_FLOAT, img
|
||||
);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
|
||||
GLint posAttrib = glGetAttribLocation(shaderProgram, "position");
|
||||
GLint uniModel = glGetUniformLocation(shaderProgram, "model");
|
||||
|
||||
float verts[] = {
|
||||
a.getX(), a.getY(), a.getZ(),
|
||||
b.getX(), b.getY(), b.getZ(),
|
||||
c.getX(), c.getY(), c.getZ(),
|
||||
};
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STREAM_DRAW);
|
||||
|
||||
glEnableVertexAttribArray(posAttrib);
|
||||
glVertexAttribPointer(posAttrib, 3, GL_FLOAT, GL_FALSE, 0, 0);
|
||||
|
||||
glm::mat4 model;
|
||||
glUniformMatrix4fv(uniModel, 1, GL_FALSE, glm::value_ptr(model));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);*/
|
||||
}
|
||||
|
||||
void DebugDraw::drawContactPoint(const btVector3 &pointOnB, const btVector3 &normalOnB, btScalar distance, int lifeTime, const btVector3 &color)
|
||||
{
|
||||
|
||||
RW_UNUSED(pointOnB);
|
||||
RW_UNUSED(normalOnB);
|
||||
RW_UNUSED(distance);
|
||||
RW_UNUSED(lifeTime);
|
||||
RW_UNUSED(color);
|
||||
}
|
||||
|
||||
void DebugDraw::flush(GameRenderer* renderer)
|
||||
@ -130,6 +98,7 @@ void DebugDraw::reportErrorWarning(const char *warningString)
|
||||
|
||||
void DebugDraw::draw3dText(const btVector3 &location, const char *textString)
|
||||
{
|
||||
RW_UNUSED(location);
|
||||
std::cout << textString << std::endl;
|
||||
}
|
||||
|
||||
|
@ -447,8 +447,9 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera &camera, float
|
||||
renderLetterbox();
|
||||
}
|
||||
|
||||
#if 0 // Disable while warnings are fixed
|
||||
float fadeTimer = world->getGameTime() - world->state->fadeStart;
|
||||
/*if( fadeTimer < world->state->fadeTime || !world->state->fadeOut ) {
|
||||
if( fadeTimer < world->state->fadeTime || !world->state->fadeOut ) {
|
||||
glUseProgram(ssRectProgram);
|
||||
glUniform2f(ssRectOffset, 0.f, 0.f);
|
||||
glUniform2f(ssRectSize, 1.f, 1.f);
|
||||
@ -476,7 +477,8 @@ void GameRenderer::renderWorld(GameWorld* world, const ViewCamera &camera, float
|
||||
|
||||
glBindVertexArray( ssRectDraw.getVAOName() );
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
if( (world->state->isCinematic || world->state->currentCutscene ) && splashTexName == 0 ) {
|
||||
renderLetterbox();
|
||||
@ -781,7 +783,7 @@ bool GameRenderer::renderFrame(Model* m, ModelFrame* f, const glm::mat4& matrix,
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameRenderer::renderModel(Model* model, const glm::mat4& modelMatrix, GameObject* object, Animator *animator)
|
||||
void GameRenderer::renderModel(Model* model, const glm::mat4& modelMatrix, GameObject* object)
|
||||
{
|
||||
renderFrame(model, model->frames[model->rootFrameIdx], modelMatrix, object, 1.f);
|
||||
}
|
||||
|
@ -54,7 +54,10 @@ MapRenderer::MapRenderer(Renderer* renderer, GameData* _data)
|
||||
std::vector<VertexP2> circleVerts;
|
||||
circleVerts.push_back({0.f, 0.f});
|
||||
for (int v = 0; v < 181; ++v) {
|
||||
circleVerts.push_back({0.5f*cos(2*(v/180.f)*M_PI), 0.5f*sin(2*(v/180.f)*M_PI)});
|
||||
circleVerts.push_back({
|
||||
0.5f * glm::cos(2*(v/180.f)*glm::pi<float>()),
|
||||
0.5f * glm::sin(2*(v/180.f)*glm::pi<float>())
|
||||
});
|
||||
}
|
||||
circleGeom.uploadVertices(circleVerts);
|
||||
circle.addGeometry(&circleGeom);
|
||||
|
@ -441,6 +441,8 @@ void renderPickup(GameWorld* world,
|
||||
float renderAlpha,
|
||||
RenderList& outList)
|
||||
{
|
||||
RW_UNUSED(renderAlpha);
|
||||
|
||||
if( ! pickup->isEnabled() ) return;
|
||||
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), pickup->getPosition());
|
||||
@ -495,6 +497,8 @@ void renderCutsceneObject(GameWorld* world,
|
||||
float renderAlpha,
|
||||
RenderList& outList)
|
||||
{
|
||||
RW_UNUSED(renderAlpha);
|
||||
|
||||
if(!world->state->currentCutscene) return;
|
||||
|
||||
if(!cutscene->model->resource)
|
||||
|
@ -281,6 +281,8 @@ void OpenGLRenderer::setUniform(Renderer::ShaderProgram* p, const std::string& n
|
||||
|
||||
void OpenGLRenderer::setUniform(Renderer::ShaderProgram* p, const std::string& name, float f)
|
||||
{
|
||||
useProgram(p);
|
||||
|
||||
glUniform1fv(currentProgram->getUniformLocation(name.c_str()), 1, &f);
|
||||
}
|
||||
|
||||
@ -424,6 +426,8 @@ void OpenGLRenderer::pushDebugGroup(const std::string& title)
|
||||
currentDebugDepth++;
|
||||
assert( currentDebugDepth < MAX_DEBUG_DEPTH );
|
||||
}
|
||||
#else
|
||||
RW_UNUSED(title);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ void TextRenderer::renderText(const TextRenderer::TextInfo& ti)
|
||||
|
||||
auto text = ti.text;
|
||||
|
||||
for( int i = 0; i < text.length(); ++i )
|
||||
for (size_t i = 0; i < text.length(); ++i)
|
||||
{
|
||||
char c = text[i];
|
||||
|
||||
|
@ -72,6 +72,9 @@ void WaterRenderer::setWaterTable(float* waterHeights, unsigned int nHeights, ui
|
||||
int xi = x * WATER_HQ_DATA_SIZE;
|
||||
for( int y = 0; y < edgeNum; y++ )
|
||||
{
|
||||
RW_CHECK (tiles[xi + y] < nHeights, "Tile index out of bounds");
|
||||
if (tiles[xi+y] >= nHeights) continue;
|
||||
|
||||
// Tiles with the magic value contain no water.
|
||||
if( tiles[xi + y] >= NO_WATER_INDEX ) continue;
|
||||
float h = waterHeights[tiles[xi + y]];
|
||||
|
@ -13,10 +13,15 @@ void ScriptDisassembly::disassemble(SCMAddress startAddress)
|
||||
for( SCMAddress a = startAddress; a < scm->getMainSize(); )
|
||||
{
|
||||
auto opcode = scm->read<SCMOpcode>(a);
|
||||
auto opcorg = opcode;
|
||||
uint8_t flags = 0;
|
||||
|
||||
bool isNegatedConditional = ((opcode & SCM_NEGATE_CONDITIONAL_MASK) == SCM_NEGATE_CONDITIONAL_MASK);
|
||||
opcode = opcode & ~SCM_NEGATE_CONDITIONAL_MASK;
|
||||
|
||||
if (isNegatedConditional)
|
||||
{
|
||||
flags |= OpcodeFlagNegatedConditional;
|
||||
}
|
||||
|
||||
ScriptFunctionMeta* foundcode;
|
||||
if( ! codes->findOpcode(opcode, &foundcode) )
|
||||
@ -59,13 +64,13 @@ void ScriptDisassembly::disassemble(SCMAddress startAddress)
|
||||
break;
|
||||
case TGlobal: {
|
||||
auto v = scm->read<std::uint16_t>(a);
|
||||
parameters.back().globalPtr = (void*)v; //* SCM_VARIABLE_SIZE;
|
||||
parameters.back().globalPtr = reinterpret_cast<void*>(v); //* SCM_VARIABLE_SIZE;
|
||||
a += sizeof(SCMByte) * 2;
|
||||
}
|
||||
break;
|
||||
case TLocal: {
|
||||
auto v = scm->read<std::uint16_t>(a);
|
||||
parameters.back().globalPtr = (void*)(v * SCM_VARIABLE_SIZE);
|
||||
parameters.back().globalPtr = reinterpret_cast<void*>(v * SCM_VARIABLE_SIZE);
|
||||
a += sizeof(SCMByte) * 2;
|
||||
}
|
||||
break;
|
||||
@ -87,6 +92,6 @@ void ScriptDisassembly::disassemble(SCMAddress startAddress)
|
||||
break;
|
||||
};
|
||||
}
|
||||
instructions[instructionAddress] = InstructionInfo { opcode, parameters };
|
||||
instructions[instructionAddress] = InstructionInfo { opcode, parameters, flags };
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ void ScriptMachine::executeThread(SCMThread &t, int msPassed)
|
||||
// Handle conditional results for IF statements.
|
||||
if( t.conditionCount > 0 && opcode != 0x00D6 ) /// @todo add conditional flag to opcodes instead of checking for 0x00D6
|
||||
{
|
||||
auto cI = --t.conditionCount;
|
||||
--t.conditionCount;
|
||||
if ( t.conditionAND )
|
||||
{
|
||||
if ( t.conditionResult == false )
|
||||
@ -201,7 +201,7 @@ ScriptMachine::ScriptMachine(GameState* _state, SCMFile *file, SCMOpcodes *ops)
|
||||
{
|
||||
auto globals = _file->getGlobalsSize();
|
||||
globalData.resize(globals);
|
||||
for(int i = 0; i < globals; ++i)
|
||||
for(size_t i = 0; i < globals; ++i)
|
||||
{
|
||||
globalData[i] = 0;
|
||||
}
|
||||
@ -286,7 +286,14 @@ void ScriptMachine::addBreakpoint(const SCMBreakpointInfo& bpi)
|
||||
|
||||
void ScriptMachine::removeBreakpoint(const SCMBreakpointInfo& bpi)
|
||||
{
|
||||
//breakpoints.erase(pc);
|
||||
for (size_t i = 0; i < breakpoints.size(); ++i)
|
||||
{
|
||||
if (bpi == breakpoints[i])
|
||||
{
|
||||
breakpoints.erase(breakpoints.begin() + i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,4 +30,4 @@ bool ScriptModule::findOpcode(ScriptFunctionID id, ScriptFunctionMeta** out)
|
||||
template<> ScriptFunction conditional_facade<bool>(bool(*f)(const ScriptArguments&))
|
||||
{ return [=](const ScriptArguments& a) { return a.getThread()->conditionResult = f(a); }; }
|
||||
|
||||
template<> bool is_conditional<bool>(bool(*f)(const ScriptArguments&)) { return true; }
|
||||
template<> bool is_conditional<bool>(bool(*)(const ScriptArguments&)) { return true; }
|
||||
|
@ -30,13 +30,13 @@ void game_print_big(const ScriptArguments& args)
|
||||
std::string id(args[0].string);
|
||||
std::string str = args.getWorld()->data->texts.text(id);
|
||||
unsigned short style = args[2].integer;
|
||||
args.getWorld()->state->text.push_back({
|
||||
args.getWorld()->state->text.emplace_back(
|
||||
id,
|
||||
str,
|
||||
args.getWorld()->getGameTime(),
|
||||
args[1].integer / 1000.f,
|
||||
style
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
void game_print_now(const ScriptArguments& args)
|
||||
@ -44,13 +44,15 @@ void game_print_now(const ScriptArguments& args)
|
||||
std::string id(args[0].string);
|
||||
std::string str = args.getWorld()->data->texts.text(id);
|
||||
int flags = args[2].integer;
|
||||
args.getWorld()->state->text.push_back({
|
||||
RW_UNUSED(flags);
|
||||
RW_UNIMPLEMENTED("game_print_now(): flags");
|
||||
args.getWorld()->state->text.emplace_back(
|
||||
id,
|
||||
str,
|
||||
args.getWorld()->getGameTime(),
|
||||
args[1].integer / 1000.f,
|
||||
0
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
void game_clear_prints(const ScriptArguments& args)
|
||||
@ -73,6 +75,8 @@ void game_set_time(const ScriptArguments& args)
|
||||
bool game_is_button_pressed(const ScriptArguments& args)
|
||||
{
|
||||
/// @todo implement
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_is_button_pressed()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -80,8 +84,11 @@ void game_set_dead_or_arrested(const ScriptArguments& args)
|
||||
{
|
||||
*args.getWorld()->state->scriptOnMissionFlag = args[0].integer;
|
||||
}
|
||||
|
||||
bool game_has_death_or_arrest_finished(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_is_button_pressed()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -129,7 +136,7 @@ void game_set_zone_car_info(const ScriptArguments& args)
|
||||
if( it != args.getWorld()->data->zones.end() )
|
||||
{
|
||||
auto day = args[1].integer == 1;
|
||||
for(int i = 2; i < args.getParameters().size() && i - 2 < ZONE_GANG_COUNT; ++i)
|
||||
for (size_t i = 2; i < args.getParameters().size() && i - 2 < ZONE_GANG_COUNT; ++i)
|
||||
{
|
||||
if( day )
|
||||
{
|
||||
@ -164,7 +171,7 @@ void game_set_zone_ped_info(const ScriptArguments& args)
|
||||
if( it != args.getWorld()->data->zones.end() )
|
||||
{
|
||||
auto day = args[1].integer == 1;
|
||||
for(int i = 2; i < args.getParameters().size(); ++i)
|
||||
for(size_t i = 2; i < args.getParameters().size(); ++i)
|
||||
{
|
||||
if( day )
|
||||
{
|
||||
@ -187,10 +194,14 @@ void game_camera_fixed_position(const ScriptArguments& args)
|
||||
args.getWorld()->state->cameraPosition = position;
|
||||
args.getWorld()->state->cameraRotation = glm::quat(angles);
|
||||
}
|
||||
|
||||
void game_camera_lookat_position(const ScriptArguments& args)
|
||||
{
|
||||
glm::vec3 position( args[0].real, args[1].real, args[2].real );
|
||||
int switchmode = args[3].integer;
|
||||
RW_UNUSED(switchmode);
|
||||
RW_UNIMPLEMENTED("game_camera_lookat_position(): camera switch mode");
|
||||
|
||||
|
||||
auto direction = glm::normalize(position - args.getWorld()->state->cameraPosition);
|
||||
auto right = glm::normalize(glm::cross(glm::vec3(0.f, 0.f, 1.f), direction));
|
||||
@ -493,7 +504,7 @@ static const char* sprite_names[] = {
|
||||
void game_add_contact_blip(const ScriptArguments& args)
|
||||
{
|
||||
glm::vec3 c( args[0].real, args[1].real, args[2].real );
|
||||
int sprite = args[3].integer;
|
||||
unsigned int sprite = args[3].integer;
|
||||
|
||||
// Look up the sprite ID.
|
||||
std::string spriteName = "";
|
||||
@ -513,7 +524,7 @@ void game_add_contact_blip(const ScriptArguments& args)
|
||||
void game_add_sprite_blip(const ScriptArguments& args)
|
||||
{
|
||||
glm::vec3 c( args[0].real, args[1].real, args[2].real );
|
||||
int sprite = args[3].integer;
|
||||
unsigned int sprite = args[3].integer;
|
||||
|
||||
// Look up the sprite ID.
|
||||
std::string spriteName = "";
|
||||
@ -539,7 +550,7 @@ void game_create_cutscene_object(const ScriptArguments& args)
|
||||
{
|
||||
auto id = args[0].integer;
|
||||
|
||||
GameObject* object = object = args.getWorld()->createCutsceneObject(id, args.getWorld()->state->currentCutscene->meta.sceneOffset );
|
||||
GameObject* object = args.getWorld()->createCutsceneObject(id, args.getWorld()->state->currentCutscene->meta.sceneOffset );
|
||||
|
||||
if( object == nullptr ) {
|
||||
args.getWorld()->logger->error("SCM", "Could not create cutscene object " + std::to_string(id));
|
||||
@ -745,6 +756,8 @@ bool game_collision_loaded(const ScriptArguments& args)
|
||||
// The paramter to this is actually the island number.
|
||||
// Not sure how that will fit into the scheme of full paging
|
||||
/// @todo use the current player zone island number to return the correct value.
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_collision_loaded()");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -785,6 +798,8 @@ bool game_is_audio_finished(const ScriptArguments& args)
|
||||
void game_play_music_id(const ScriptArguments& args)
|
||||
{
|
||||
int id = args[0].integer;
|
||||
RW_UNUSED(id);
|
||||
RW_UNIMPLEMENTED("game_play_music_id(): should be play mission passed tune");
|
||||
GameWorld* gw = args.getWorld();
|
||||
std::string name = "Miscom";
|
||||
|
||||
@ -806,7 +821,7 @@ void game_clear_print(const ScriptArguments& args)
|
||||
{
|
||||
std::string id(args[0].string);
|
||||
|
||||
for( int i = 0; i < args.getWorld()->state->text.size(); )
|
||||
for( size_t i = 0; i < args.getWorld()->state->text.size(); )
|
||||
{
|
||||
if( args.getWorld()->state->text[i].id == id )
|
||||
{
|
||||
@ -822,6 +837,8 @@ void game_clear_print(const ScriptArguments& args)
|
||||
bool game_did_game_save(const ScriptArguments& args)
|
||||
{
|
||||
// TODO not sure what could be false about this.
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_did_game_save(): Saving the game");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -846,7 +863,7 @@ void game_display_help(const ScriptArguments& args)
|
||||
|
||||
void game_clear_help(const ScriptArguments& args)
|
||||
{
|
||||
for( int i = 0; i < args.getWorld()->state->text.size(); )
|
||||
for( size_t i = 0; i < args.getWorld()->state->text.size(); )
|
||||
{
|
||||
auto& texts = args.getWorld()->state->text;
|
||||
if( texts[i].osTextStyle == OnscreenText::Help )
|
||||
@ -862,12 +879,16 @@ void game_clear_help(const ScriptArguments& args)
|
||||
|
||||
bool game_can_player_move(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_can_player_move()");
|
||||
return true;
|
||||
}
|
||||
|
||||
void game_load_collision(const ScriptArguments& args)
|
||||
{
|
||||
// Collision is loaded when required, not sure what this is supposed to mean.
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_load_collision();");
|
||||
}
|
||||
|
||||
void game_set_rampages(const ScriptArguments& args)
|
||||
@ -906,6 +927,8 @@ void game_set_is_intro_playing(const ScriptArguments& args)
|
||||
|
||||
bool game_are_vehicle_cheats_enabled(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_are_vehicle_cheats_enabled()");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,11 @@ glm::vec3 spawnMagic( 0.f, 0.f, 1.f );
|
||||
|
||||
void game_create_player(const ScriptArguments& args)
|
||||
{
|
||||
auto id = args[0].integer;
|
||||
auto id = args[0].integer;
|
||||
if (id != 0) {
|
||||
RW_UNIMPLEMENTED("Multiple player characters not supported");
|
||||
}
|
||||
|
||||
glm::vec3 position(args[1].real, args[2].real, args[3].real);
|
||||
|
||||
if( position.z < -99.f ) {
|
||||
@ -104,7 +108,8 @@ void game_create_character(const ScriptArguments& args)
|
||||
}
|
||||
|
||||
auto character = args.getWorld()->createPedestrian(id, position + spawnMagic);
|
||||
auto controller = new DefaultAIController(character);
|
||||
/* Controller will give ownership to character */
|
||||
new DefaultAIController(character);
|
||||
|
||||
if ( args.getThread()->isMission )
|
||||
{
|
||||
@ -299,6 +304,7 @@ bool game_player_near_point_in_vehicle_3D(const ScriptArguments& args)
|
||||
glm::vec3 center(args[1].real, args[2].real, args[3].real);
|
||||
glm::vec3 size(args[4].real, args[5].real, args[6].real);
|
||||
bool unkown = !!args[7].integer;
|
||||
RW_UNUSED(unkown);
|
||||
|
||||
auto vehicle = character->getCurrentVehicle();
|
||||
if( vehicle ) {
|
||||
@ -340,7 +346,8 @@ bool game_character_near_point_in_vehicle(const ScriptArguments& args)
|
||||
glm::vec3 center(args[1].real, args[2].real, args[3].real);
|
||||
glm::vec3 size(args[4].real, args[5].real, args[6].real);
|
||||
bool unkown = !!args[7].integer;
|
||||
|
||||
RW_UNUSED(unkown);
|
||||
|
||||
auto vehicle = character->getCurrentVehicle();
|
||||
if( vehicle ) {
|
||||
auto distance = center - character->getPosition();
|
||||
@ -359,6 +366,7 @@ bool game_character_near_character_2D(const ScriptArguments& args)
|
||||
glm::vec2 center(target->getPosition());
|
||||
glm::vec2 size(args[2].real, args[3].real);
|
||||
bool unkown = !!args[4].integer;
|
||||
RW_UNUSED(unkown);
|
||||
|
||||
auto distance = center - glm::vec2(character->getPosition());
|
||||
distance /= size;
|
||||
@ -374,7 +382,8 @@ bool game_character_near_character_in_vehicle_2D(const ScriptArguments& args)
|
||||
glm::vec2 center(target->getPosition());
|
||||
glm::vec2 size(args[2].real, args[3].real);
|
||||
bool unkown = !!args[4].integer;
|
||||
|
||||
RW_UNUSED(unkown);
|
||||
|
||||
auto vehicle = character->getCurrentVehicle();
|
||||
if( vehicle ) {
|
||||
auto distance = center - glm::vec2(character->getPosition());
|
||||
@ -391,7 +400,8 @@ bool game_character_near_point_on_foot_2D(const ScriptArguments& args)
|
||||
glm::vec2 center(args[1].real, args[2].real);
|
||||
glm::vec2 size(args[3].real, args[4].real);
|
||||
bool unkown = !!args[5].integer;
|
||||
|
||||
RW_UNUSED(unkown);
|
||||
|
||||
auto vehicle = character->getCurrentVehicle();
|
||||
if( !vehicle ) {
|
||||
auto distance = center - glm::vec2(character->getPosition());
|
||||
@ -462,10 +472,12 @@ void game_create_character_in_vehicle(const ScriptArguments& args)
|
||||
{
|
||||
auto vehicle = static_cast<VehicleObject*>(args.getObject<VehicleObject>(0));
|
||||
auto type = args[1].integer;
|
||||
RW_UNUSED(type);
|
||||
RW_UNIMPLEMENTED("game_create_character_in_vehicle(): character type");
|
||||
auto id = args[2].integer;
|
||||
|
||||
auto character = args.getWorld()->createPedestrian(id, vehicle->getPosition() + spawnMagic);
|
||||
auto controller = new DefaultAIController(character);
|
||||
new DefaultAIController(character);
|
||||
|
||||
character->setCurrentVehicle(vehicle, 0);
|
||||
vehicle->setOccupant(0, character);
|
||||
@ -527,6 +539,7 @@ void game_dont_remove_object(const ScriptArguments& args)
|
||||
|
||||
bool game_character_in_area_on_foot(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
/// @todo
|
||||
return false;
|
||||
}
|
||||
@ -611,6 +624,7 @@ bool game_is_character_stopped(const ScriptArguments& args)
|
||||
|
||||
bool game_character_in_area_9(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -626,6 +640,8 @@ bool game_objects_in_volume(const ScriptArguments& args)
|
||||
bool actors = args[8].integer;
|
||||
bool objects = args[9].integer;
|
||||
bool particles = args[10].integer;
|
||||
RW_UNUSED(objects);
|
||||
RW_UNUSED(particles);
|
||||
|
||||
for(auto& object : args.getWorld()->allObjects)
|
||||
{
|
||||
@ -744,6 +760,10 @@ void game_create_pickup(const ScriptArguments& args)
|
||||
case TInt16:
|
||||
id = (std::int16_t)args[0].integer;
|
||||
break;
|
||||
default:
|
||||
RW_ERROR("Unhandled integer type");
|
||||
*args[5].globalInteger = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( id < 0 )
|
||||
@ -823,6 +843,8 @@ bool game_vehicle_in_air(const ScriptArguments& args)
|
||||
{
|
||||
/// @todo IS vehicle in air.
|
||||
auto vehicle = static_cast<VehicleObject*>(args.getObject<VehicleObject>(0));
|
||||
RW_UNUSED(vehicle);
|
||||
RW_UNIMPLEMENTED("game_vehicle_in_air()");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -832,7 +854,9 @@ bool game_character_near_car_2d(const ScriptArguments& args)
|
||||
auto vehicle = static_cast<VehicleObject*>(args.getObject<VehicleObject>(1));
|
||||
glm::vec2 radius(args[2].real, args[3].real);
|
||||
bool drawMarker = !!args[4].integer;
|
||||
|
||||
RW_UNUSED(drawMarker);
|
||||
RW_UNIMPLEMENTED("Draw marker in game_character_near_car_2D");
|
||||
|
||||
auto charVehicle = character->getCurrentVehicle();
|
||||
if( charVehicle ) {
|
||||
auto dist = charVehicle->getPosition() - vehicle->getPosition();
|
||||
@ -863,6 +887,9 @@ void game_create_object_world(const ScriptArguments& args)
|
||||
case TInt16:
|
||||
id = (std::int16_t)args[0].integer;
|
||||
break;
|
||||
default:
|
||||
RW_ERROR("Unhandled integer type");
|
||||
break;
|
||||
}
|
||||
|
||||
if( id < 0 ) {
|
||||
@ -890,6 +917,8 @@ void game_destroy_object(const ScriptArguments& args)
|
||||
|
||||
bool game_is_boat(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_is_boat()");
|
||||
/*auto vehicle = (VehicleObject*)(*args[0].handle);
|
||||
* if( vehicle )
|
||||
* {
|
||||
@ -900,6 +929,8 @@ bool game_is_boat(const ScriptArguments& args)
|
||||
|
||||
bool game_character_in_range(const ScriptArguments& args)
|
||||
{
|
||||
RW_UNUSED(args);
|
||||
RW_UNIMPLEMENTED("game_character_in_range()");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -917,6 +948,9 @@ void game_set_close_object_visible(const ScriptArguments& args)
|
||||
case TInt16:
|
||||
modelid = (std::int16_t)args[4].integer;
|
||||
break;
|
||||
default:
|
||||
RW_ERROR("Unhandled integer type");
|
||||
break;
|
||||
}
|
||||
|
||||
if( std::abs(modelid) > 178 ) {
|
||||
@ -957,6 +991,9 @@ void game_change_nearest_model(const ScriptArguments& args)
|
||||
case TInt16:
|
||||
oldid = (std::int16_t)args[4].integer;
|
||||
break;
|
||||
default:
|
||||
RW_ERROR("Unhandled integer type");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(args[5].type) {
|
||||
@ -966,6 +1003,9 @@ void game_change_nearest_model(const ScriptArguments& args)
|
||||
case TInt16:
|
||||
newid = (std::int16_t)args[5].integer;
|
||||
break;
|
||||
default:
|
||||
RW_ERROR("Unhandled integer type");
|
||||
break;
|
||||
}
|
||||
|
||||
if( std::abs(newid) > 178 || std::abs(oldid) > 178 ) {
|
||||
@ -1009,6 +1049,7 @@ bool game_rotate_object(const ScriptArguments& args)
|
||||
{
|
||||
float start = args[2].real;
|
||||
float finish = args[1].real;
|
||||
RW_UNUSED(start);
|
||||
|
||||
// @todo INTERPOLATE instead of just setting the heading.
|
||||
object->setHeading(finish);
|
||||
|
@ -17,7 +17,12 @@ add_executable(rwgame
|
||||
debug/HttpServer.cpp
|
||||
)
|
||||
|
||||
include_directories("${CMAKE_SOURCE_DIR}/rwengine/include" ${BULLET_INCLUDE_DIR})
|
||||
include_directories(SYSTEM
|
||||
${BULLET_INCLUDE_DIR}
|
||||
)
|
||||
include_directories(
|
||||
"${CMAKE_SOURCE_DIR}/rwengine/include"
|
||||
)
|
||||
|
||||
target_link_libraries( rwgame
|
||||
rwengine
|
||||
|
@ -3,15 +3,23 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define RW_UNIMPLEMENTED(msg) \
|
||||
std::cout << "Unimplemented: " << msg << std::endl;
|
||||
|
||||
#if RW_DEBUG
|
||||
#define RW_MESSAGE(msg) \
|
||||
std::cout << __FILE__ << ":"<< __LINE__ << ": " << msg << std::endl
|
||||
#define RW_ERROR(msg) \
|
||||
std::cout << __FILE__ << ":"<< __LINE__ << ": " << msg << std::endl
|
||||
#define RW_CHECK(cond, msg) \
|
||||
if(!(cond)) std::cerr << "Check Failed: " << msg << std::endl
|
||||
if(!(cond)) RW_ERROR(msg)
|
||||
#else
|
||||
#define RW_MESSAGE(msg)
|
||||
#define RW_ERROR(msg)
|
||||
#define RW_CHECK(cond, msg)
|
||||
#endif
|
||||
|
||||
#define RW_UNUSED(var) \
|
||||
(void) var
|
||||
|
||||
#define RW_UNIMPLEMENTED(msg) \
|
||||
RW_MESSAGE("Unimplemented" << msg)
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user