mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-03 09:09:47 +02:00
Fix compiler errors and test problems
This commit is contained in:
parent
f289b6d0b0
commit
c5451f5fd4
@ -4,6 +4,9 @@ project(OpenRW)
|
||||
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11 -Wall" )
|
||||
|
||||
# Make GLM use radians
|
||||
add_definitions(-DGLM_FORCE_RADIANS)
|
||||
|
||||
add_subdirectory(datadump)
|
||||
add_subdirectory(rwgame)
|
||||
add_subdirectory(rwviewer)
|
||||
|
@ -58,8 +58,8 @@ int main(int argc, char** argv)
|
||||
for (int i = 0; i < 16; i++) {
|
||||
uint8_t pixelIndex = 4 * (j*16 + i);
|
||||
|
||||
for (int y = 0; y < scaleUp; y++) {
|
||||
for (int x = 0; x < scaleUp; x++) {
|
||||
for (u_int32_t y = 0; y < scaleUp; y++) {
|
||||
for (u_int32_t x = 0; x < scaleUp; x++) {
|
||||
img.setPixel((i*scaleUp)+x, (j*scaleUp)+y, {
|
||||
tex.body.palette[pixelIndex + 0],
|
||||
tex.body.palette[pixelIndex + 1],
|
||||
|
@ -163,7 +163,7 @@ void dumpModelFile(char* data)
|
||||
}
|
||||
}
|
||||
|
||||
for(int j = 0; j < geom.numtris; ++j)
|
||||
for(size_t j = 0; j < geom.numtris; ++j)
|
||||
{
|
||||
auto tri = readStructure<BSGeometryTriangle>(data, dataI);
|
||||
std::cout << " Triangle " << std::dec
|
||||
|
@ -71,7 +71,7 @@ namespace RW
|
||||
{
|
||||
BSTMatrix rotation;
|
||||
BSTVector3 position;
|
||||
uint32_t index;
|
||||
int32_t index;
|
||||
uint32_t matrixflags; // UNUSED BY ANYTHING.
|
||||
};
|
||||
|
||||
@ -111,7 +111,7 @@ namespace RW
|
||||
};
|
||||
};
|
||||
|
||||
typedef glm::detail::tvec4<uint8_t> BSColor;
|
||||
typedef glm::u8vec4 BSColor;
|
||||
|
||||
struct BSGeometryColor
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
|
||||
struct Material {
|
||||
std::vector<Texture> textures;
|
||||
glm::detail::tvec4<uint8_t> colour;
|
||||
glm::u8vec4 colour;
|
||||
|
||||
uint8_t flags;
|
||||
|
||||
|
@ -188,7 +188,7 @@ void GameData::loadIMG(const std::string& name)
|
||||
std::string archivePath = datpath + name;
|
||||
|
||||
if (imgLoader.load(archivePath)) {
|
||||
for (int i = 0; i < imgLoader.getAssetCount(); i++) {
|
||||
for (size_t i = 0; i < imgLoader.getAssetCount(); i++) {
|
||||
auto &asset = imgLoader.getAssetInfoByIndex(i);
|
||||
|
||||
std::string filename = asset.name;
|
||||
|
@ -108,7 +108,7 @@ Model* LoaderDFF::loadFromMemory(char *data, GameData *gameData)
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < geometry.numtris; ++j) {
|
||||
for (size_t j = 0; j < geometry.numtris; ++j) {
|
||||
readStructure<RW::BSGeometryTriangle>(data, dataI);
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ Model* LoaderDFF::loadFromMemory(char *data, GameData *gameData)
|
||||
geom->subgeom[i].numIndices = plgHeader.numverts;
|
||||
geom->subgeom[i].start = sgstart;
|
||||
sgstart += plgHeader.numverts;
|
||||
for (int j = 0; j < plgHeader.numverts; ++j) {
|
||||
for (size_t j = 0; j < plgHeader.numverts; ++j) {
|
||||
geom->subgeom[i].indices[j] = extsec.readSubStructure<uint32_t>(meshplgI);
|
||||
meshplgI += sizeof(uint32_t);
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ bool LoaderIDE::load(const std::string &filename)
|
||||
std::stringstream strstream(line);
|
||||
|
||||
switch (section) {
|
||||
default: break;
|
||||
case OBJS:
|
||||
case TOBJ: { // Supports Type 1, 2 and 3
|
||||
std::shared_ptr<ObjectData> objs(new ObjectData);
|
||||
|
@ -59,7 +59,7 @@ bool LoaderIFP::loadFromMemory(char *data)
|
||||
ANPK* fileRoot = read<ANPK>(data, dataI);
|
||||
std::string listname = readString(data, dataI);
|
||||
|
||||
for( size_t a = 0; a < fileRoot->info.entries; ++a ) {
|
||||
for( int a = 0; a < fileRoot->info.entries; ++a ) {
|
||||
// something about a name?
|
||||
/*NAME* n =*/ read<NAME>(data, dataI);
|
||||
std::string animname = readString(data, dataI);
|
||||
@ -72,7 +72,7 @@ bool LoaderIFP::loadFromMemory(char *data)
|
||||
DGAN* animroot = read<DGAN>(data, dataI);
|
||||
std::string infoname = readString(data, dataI);
|
||||
|
||||
for( size_t c = 0; c < animroot->info.entries; ++c ) {
|
||||
for( int c = 0; c < animroot->info.entries; ++c ) {
|
||||
size_t start = data_offs;
|
||||
CPAN* cpan = read<CPAN>(data, dataI);
|
||||
ANIM* frames = read<ANIM>(data, dataI);
|
||||
@ -90,7 +90,7 @@ bool LoaderIFP::loadFromMemory(char *data)
|
||||
|
||||
if(type == "KR00") {
|
||||
bonedata->type = AnimationBone::R00;
|
||||
for( size_t d = 0; d < frames->frames; ++d ) {
|
||||
for( int d = 0; d < frames->frames; ++d ) {
|
||||
glm::quat q = glm::conjugate(*read<glm::quat>(data, dataI));
|
||||
time = *read<float>(data,dataI);
|
||||
bonedata->frames.push_back({
|
||||
@ -103,7 +103,7 @@ bool LoaderIFP::loadFromMemory(char *data)
|
||||
}
|
||||
else if(type == "KRT0") {
|
||||
bonedata->type = AnimationBone::RT0;
|
||||
for( size_t d = 0; d < frames->frames; ++d ) {
|
||||
for( int d = 0; d < frames->frames; ++d ) {
|
||||
glm::quat q = glm::conjugate(*read<glm::quat>(data, dataI));
|
||||
glm::vec3 p = *read<glm::vec3>(data, dataI);
|
||||
time = *read<float>(data,dataI);
|
||||
@ -117,7 +117,7 @@ bool LoaderIFP::loadFromMemory(char *data)
|
||||
}
|
||||
else if(type == "KRTS") {
|
||||
bonedata->type = AnimationBone::RTS;
|
||||
for( size_t d = 0; d < frames->frames; ++d ) {
|
||||
for( int d = 0; d < frames->frames; ++d ) {
|
||||
glm::quat q = glm::conjugate(*read<glm::quat>(data, dataI));
|
||||
glm::vec3 p = *read<glm::vec3>(data, dataI);
|
||||
glm::vec3 s = *read<glm::vec3>(data, dataI);
|
||||
|
@ -144,7 +144,7 @@ glm::quat GTAVehicle::getRotation() const
|
||||
void GTAVehicle::tick(float dt)
|
||||
{
|
||||
if(physVehicle) {
|
||||
for(size_t w = 0; w < physVehicle->getNumWheels(); ++w) {
|
||||
for(int w = 0; w < physVehicle->getNumWheels(); ++w) {
|
||||
btWheelInfo& wi = physVehicle->getWheelInfo(w);
|
||||
if( info->handling.driveType == VehicleHandlingInfo::All ||
|
||||
(info->handling.driveType == VehicleHandlingInfo::Forward && wi.m_bIsFrontWheel) ||
|
||||
|
@ -405,7 +405,6 @@ void GTARenderer::renderWorld()
|
||||
|
||||
void GTARenderer::renderNamedFrame(Model* model, const glm::mat4 &matrix, const std::string& name)
|
||||
{
|
||||
size_t n = 0;
|
||||
for (const ModelFrame* f : model->frames)
|
||||
{
|
||||
const std::string& fname = f->getName();
|
||||
|
@ -62,6 +62,7 @@ struct State
|
||||
break;
|
||||
case sf::Event::KeyPressed:
|
||||
switch(e.key.code) {
|
||||
default: break;
|
||||
case sf::Keyboard::Up:
|
||||
m->move(-1);
|
||||
break;
|
||||
@ -140,4 +141,4 @@ struct StateManager
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -135,7 +135,7 @@ std::map<std::string, std::function<void (std::string)>> Commands = {
|
||||
}
|
||||
|
||||
auto spawnpos = hit + normal;
|
||||
auto vehicle = gta->createVehicle(it->first, spawnpos, glm::quat(glm::vec3(0.f, 0.f, -plyLook.x * PiOver180)));
|
||||
gta->createVehicle(it->first, spawnpos, glm::quat(glm::vec3(0.f, 0.f, -plyLook.x * PiOver180)));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -42,7 +42,7 @@ QModelIndex DFFFramesTreeModel::parent(const QModelIndex& child) const
|
||||
if(c->getParent()) {
|
||||
auto cp = c->getParent();
|
||||
if(cp->getParent()) {
|
||||
for(int i = 0; i < cp->getParent()->getChildren().size(); ++i) {
|
||||
for(size_t i = 0; i < cp->getParent()->getChildren().size(); ++i) {
|
||||
if(cp->getParent()->getChildren()[i] == c->getParent()) {
|
||||
return createIndex(i, 0, c->getParent());
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ BOOST_AUTO_TEST_CASE(test_open_archive)
|
||||
{
|
||||
LoaderIMG loader;
|
||||
|
||||
BOOST_REQUIRE( loader.load("test_data/models/gta3") );
|
||||
BOOST_REQUIRE( loader.load(Global::getGamePath() + "/models/gta3") );
|
||||
|
||||
BOOST_CHECK( loader.getAssetCount() > 0 );
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <SFML/Window.hpp>
|
||||
#include <engine/GameWorld.hpp>
|
||||
|
||||
// Many tests require OpenGL be functional, seems like a reasonable solution.
|
||||
#define ENV_GAME_PATH_NAME ("OPENRW_GAME_PATH")
|
||||
|
||||
class Global
|
||||
{
|
||||
@ -16,7 +16,7 @@ public:
|
||||
wnd.create(sf::VideoMode(640, 360), "Testing");
|
||||
glewExperimental = GL_TRUE;
|
||||
glewInit();
|
||||
e = new GameWorld("test_data");
|
||||
e = new GameWorld(getGamePath());
|
||||
|
||||
e->gameData.loadIMG("/models/gta3");
|
||||
e->load();
|
||||
@ -31,6 +31,13 @@ public:
|
||||
wnd.close();
|
||||
delete e;
|
||||
}
|
||||
|
||||
static std::string getGamePath()
|
||||
{
|
||||
// TODO: Is this "the way to do it" on windows.
|
||||
auto v = getenv(ENV_GAME_PATH_NAME);
|
||||
return v ? v : "";
|
||||
}
|
||||
|
||||
static Global& get()
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ BOOST_AUTO_TEST_CASE(test_open_dff)
|
||||
{
|
||||
LoaderIMG loader;
|
||||
|
||||
BOOST_REQUIRE( loader.load("test_data/models/gta3") );
|
||||
BOOST_REQUIRE( loader.load(Global::getGamePath() + "/models/gta3") );
|
||||
|
||||
auto d = loader.loadToMemory("landstal.dff");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user