mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-02 00:42:33 +01:00
Cleanup SCMFile
This commit is contained in:
parent
81c1bb947d
commit
d9aded5415
@ -11,14 +11,14 @@ void SCMFile::loadFile(char *data, unsigned int size)
|
|||||||
|
|
||||||
_target = static_cast<SCMTarget>(_data[jumpOpSize]);
|
_target = static_cast<SCMTarget>(_data[jumpOpSize]);
|
||||||
globalSectionOffset = jumpOpSize+1u;
|
globalSectionOffset = jumpOpSize+1u;
|
||||||
modelSectionOffset = read<uint32>(jumpParamSize) + jumpOpSize + 1u;
|
modelSectionOffset = read<uint32_t>(jumpParamSize) + jumpOpSize + 1u;
|
||||||
missionSectionOffset = read<uint32>(modelSectionOffset-jumpOpSize-1u+jumpParamSize) + jumpOpSize + 1u;
|
missionSectionOffset = read<uint32_t>(modelSectionOffset-jumpOpSize-1u+jumpParamSize) + jumpOpSize + 1u;
|
||||||
codeSectionOffset = read<uint32>(missionSectionOffset-jumpOpSize-1u+jumpParamSize);
|
codeSectionOffset = read<uint32_t>(missionSectionOffset-jumpOpSize-1u+jumpParamSize);
|
||||||
|
|
||||||
unsigned int model_count = read<uint32>(modelSectionOffset);
|
unsigned int model_count = read<uint32_t>(modelSectionOffset);
|
||||||
models.reserve(model_count);
|
models.reserve(model_count);
|
||||||
|
|
||||||
int i = modelSectionOffset + sizeof(uint32);
|
int i = modelSectionOffset + sizeof(uint32_t);
|
||||||
for(unsigned int m = 0; m < model_count; ++m) {
|
for(unsigned int m = 0; m < model_count; ++m) {
|
||||||
char model_name[24];
|
char model_name[24];
|
||||||
for(size_t c = 0; c < 24; ++c) {
|
for(size_t c = 0; c < 24; ++c) {
|
||||||
@ -28,16 +28,16 @@ void SCMFile::loadFile(char *data, unsigned int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
i = missionSectionOffset;
|
i = missionSectionOffset;
|
||||||
mainSize = read<uint32>(i);
|
mainSize = read<uint32_t>(i);
|
||||||
i += sizeof(uint32);
|
i += sizeof(uint32_t);
|
||||||
missionLargestSize = read<uint32>(i);
|
missionLargestSize = read<uint32_t>(i);
|
||||||
i += sizeof(uint32);
|
i += sizeof(uint32_t);
|
||||||
unsigned int missionCount = read<uint32>(i);
|
unsigned int missionCount = read<uint32_t>(i);
|
||||||
missionOffsets.reserve(missionCount);
|
missionOffsets.reserve(missionCount);
|
||||||
i += sizeof(uint32);
|
i += sizeof(uint32_t);
|
||||||
|
|
||||||
for(unsigned int m = 0; m < missionCount; ++m) {
|
for(unsigned int m = 0; m < missionCount; ++m) {
|
||||||
missionOffsets.push_back(read<uint32>(i));
|
missionOffsets.push_back(read<uint32_t>(i));
|
||||||
i += sizeof(uint32);
|
i += sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#ifndef RWENGINE_SCMFILE_HPP
|
||||||
#ifndef _SCMFILE_HPP_
|
#define RWENGINE_SCMFILE_HPP
|
||||||
#define _SCMFILE_HPP_
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <script/ScriptTypes.hpp>
|
#include <script/ScriptTypes.hpp>
|
||||||
@ -11,10 +10,6 @@
|
|||||||
class SCMFile {
|
class SCMFile {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::uint32_t uint32;
|
|
||||||
typedef std::uint16_t u16;
|
|
||||||
typedef std::uint8_t u8;
|
|
||||||
|
|
||||||
enum SCMTarget {
|
enum SCMTarget {
|
||||||
NoTarget = 0,
|
NoTarget = 0,
|
||||||
GTAIII = 0xC6,
|
GTAIII = 0xC6,
|
||||||
@ -41,17 +36,17 @@ public:
|
|||||||
return *(T*)(_data+offset);
|
return *(T*)(_data+offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 getMainSize() const { return mainSize; }
|
uint32_t getMainSize() const { return mainSize; }
|
||||||
uint32 getLargestMissionSize() const { return missionLargestSize; }
|
uint32_t getLargestMissionSize() const { return missionLargestSize; }
|
||||||
|
|
||||||
const std::vector<std::string>& getModels() const { return models; }
|
const std::vector<std::string>& getModels() const { return models; }
|
||||||
|
|
||||||
const std::vector<unsigned int>& getMissionOffsets() const { return missionOffsets; }
|
const std::vector<unsigned int>& getMissionOffsets() const { return missionOffsets; }
|
||||||
|
|
||||||
std::uint32_t getGlobalSection() const { return globalSectionOffset; }
|
uint32_t getGlobalSection() const { return globalSectionOffset; }
|
||||||
std::uint32_t getModelSection() const { return modelSectionOffset; }
|
uint32_t getModelSection() const { return modelSectionOffset; }
|
||||||
std::uint32_t getMissionSection() const { return missionSectionOffset; }
|
uint32_t getMissionSection() const { return missionSectionOffset; }
|
||||||
std::uint32_t getCodeSection() const { return codeSectionOffset; }
|
uint32_t getCodeSection() const { return codeSectionOffset; }
|
||||||
|
|
||||||
unsigned int getGlobalsSize() const { return modelSectionOffset - globalSectionOffset; }
|
unsigned int getGlobalsSize() const { return modelSectionOffset - globalSectionOffset; }
|
||||||
|
|
||||||
@ -65,13 +60,13 @@ private:
|
|||||||
|
|
||||||
std::vector<unsigned int> missionOffsets;
|
std::vector<unsigned int> missionOffsets;
|
||||||
|
|
||||||
uint32 mainSize;
|
uint32_t mainSize;
|
||||||
uint32 missionLargestSize;
|
uint32_t missionLargestSize;
|
||||||
|
|
||||||
uint32 globalSectionOffset;
|
uint32_t globalSectionOffset;
|
||||||
uint32 modelSectionOffset;
|
uint32_t modelSectionOffset;
|
||||||
uint32 missionSectionOffset;
|
uint32_t missionSectionOffset;
|
||||||
uint32 codeSectionOffset;
|
uint32_t codeSectionOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user