World of Might and Magic
0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
|
См. документацию.
52 FILE *copy_from = fopen(from.c_str(),
"rb");
54 FILE *copy_to = fopen(to.c_str(),
"wb+");
56 fseek(copy_from, 0, SEEK_END);
57 file_size = ftell(copy_from);
58 fseek(copy_from, 0, SEEK_SET);
60 unsigned char *
buf =
new unsigned char[file_size];
62 bytes_read = fread(
buf, 1, file_size, copy_from);
63 if (bytes_read == file_size) {
64 bytes_wrote = fwrite(
buf, 1, file_size, copy_to);
74 return file_size != -1 && bytes_read == bytes_wrote;
90 remove(to_file_path.c_str());
91 if (!
CopyFile(filename, to_file_path)) {
92 Error(
"Failed to copy: %s", filename.c_str());
99 if (header ==
nullptr) {
105 if (serialization ==
nullptr) {
111 for (
size_t i = 0; i < 4; i++) {
113 for (
size_t j = 0; j < 5; j++) {
128 if (serialization ==
nullptr) {
138 if (serialization ==
nullptr) {
148 if (serialization ==
nullptr) {
151 for (
unsigned int i = 0; i < 501; ++i) {
161 if (npcgroup ==
nullptr) {
173 for (
uint i = 0; i < 4; ++i) {
230 if (
engine->config->turn_speed > 0) {
238 void SaveGame(
bool IsAutoSAve,
bool NotSaveWorld) {
244 char *uncompressed_buff = (
char *)malloc(1000000);
264 unsigned int buf_size = 0;
265 render->PackScreenshot(150, 112, uncompressed_buff, 1000000, &buf_size);
291 if (
pNew_LOD->
Write(
"image.pcx", uncompressed_buff, buf_size, 0)) {
298 memset(save_header.
pName, 0, 20);
300 memset(save_header.
field_30, 0, 52);
312 if (
pNew_LOD->
Write(
"party.bin", &serialization,
sizeof(serialization), 0)) {
322 if (
pNew_LOD->
Write(
"clock.bin", &serialization,
sizeof(serialization), 0)) {
332 if (
pNew_LOD->
Write(
"overlay.bin", &serialization,
sizeof(serialization), 0)) {
340 for (
unsigned int i = 0; i < 501; ++i) {
344 if (
pNew_LOD->
Write(
"npcdata.bin", serialization,
sizeof(serialization), 0)) {
355 for (
size_t i = 0; i < 4; ++i) {
357 for (
size_t j = 0; j < 5; ++j) {
365 unsigned int pcx_data_size = 30000;
366 void *pcx_data = malloc(pcx_data_size);
368 pcx_data, pcx_data_size, &pcx_data_size);
381 char *compressed_buf = (
char *)malloc(1000000);
382 if (compressed_buf ==
nullptr) {
388 odm_data->
pMagic[0] =
'm';
389 odm_data->
pMagic[1] =
'v';
390 odm_data->
pMagic[2] =
'i';
391 odm_data->
pMagic[3] =
'i';
395 char *data_write_pos = uncompressed_buff;
403 data_write_pos += 875;
426 data_write_pos += 16000;
431 data_write_pos += 200;
433 data_write_pos += 56;
446 data_write_pos += 968;
449 data_write_pos += 968;
452 memcpy(data_write_pos, &(
face.uAttributes), 4);
474 data_write_pos += 200;
476 data_write_pos += 56;
479 unsigned int compressed_block_size = 1000000 -
sizeof(
ODMHeader);
480 size_t Size = data_write_pos - uncompressed_buff;
482 if (
res || (compressed_block_size > Size)) {
483 memcpy((
void *)(compressed_buf +
sizeof(
ODMHeader)), uncompressed_buff, Size);
484 compressed_block_size = Size;
491 size_t pos = file_name.find_last_of(
".");
492 file_name[pos + 1] =
'd';
497 free(compressed_buf);
499 free(uncompressed_buff);
552 std::vector<String> files =
OS_FindFiles(saves_dir,
"*.mm7");
572 remove(file_path.c_str());
GLenum GLuint GLint GLenum face
LOD::WriteableFile * pNew_LOD
int FixDirectoryOffsets()
void SetMasterVolume(int level)
const char * GetString(unsigned int index) const
std::array< LevelDecoration, 3000 > pLevelDecorations
bool LoadFile(const String &pFilename, bool bWriting)
size_t GetSubNodesCount() const
void SetUserInterface(PartyAlignment align, bool bReplace)
GameTime & GetPlayingTime()
void SetMusicVolume(int music_level)
void Serialize(struct OtherOverlayList *)
std::array< SpriteObject, MAX_SPRITE_OBJECTS > pSpriteObjects
void Encode16(const void *picture_data, unsigned int width, unsigned int height, void *pcx_data, int max_buff_size, unsigned int *packed_size)
unsigned char uFullyRevealedCellOnMap[88][11]
GUIWindow * pGUIWindow_CurrentMenu
int Compress(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen)
void PlaySound(SoundID eSoundID, int pid, unsigned int uNumRepeats, int x, int y, int a7)
std::shared_ptr< Engine > engine
uint16_t pGroups_copy[51]
bool DoesContainerExist(const String &filename)
Localization * localization
void DoSavegame(unsigned int uSlot)
std::array< unsigned int, MAX_SAVE_SLOTS > pSavegameUsedSlots
std::array< Player, 4 > pPlayers
unsigned int uNumSavegameFiles
GLsizei const GLchar *const * path
enum CURRENT_SCREEN current_screen_type
void Serialize(struct Party *)
std::vector< std::string > OS_FindFiles(const std::string &folder, const std::string &mask)
unsigned char uPartiallyRevealedCellOnMap[88][11]
void Deserialize(struct OtherOverlayList *)
int CreateNewLod(LOD::FileHeader *pHeader, const String &root_name, const String &Source)
GLenum GLuint GLenum GLsizei const GLchar * buf
LocationTime_stru1 loc_time
struct ViewingParams * viewparams
void Deserialize(struct NPCData *item)
struct DDM_DLV_Header dlv
void Warning(const wchar_t *pFormat,...)
std::array< Actor, 500 > pActors
char * ChestsSerialize(char *pData)
std::array< Image *, MAX_SAVE_SLOTS > pSavegameThumbnails
size_t uNumLevelDecorations
char _visible_outlines[875]
unsigned int Write(const String &file_name, const void *pDirData, size_t size, int a4)
void _476C60_on_load_game()
void Serialize(struct NPCData *item)
struct DDM_DLV_Header ddm
std::string s_SavedMapName
constexpr unsigned int MAX_SAVE_SLOTS
void Serialize(struct Timer *)
void Deserialize(struct Party *)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
struct OtherOverlayList * pOtherOverlayList
EGLImageKHR EGLint * name
uint16_t * ptr_0002B4_doors_ddata
std::string MakeDataPath(const char *file_rel_path)
static Image * Create(unsigned int width, unsigned int height, IMAGE_FORMAT format, const void *pixels=nullptr)
std::vector< LloydBeacon > vBeacons
unsigned int uActiveCharacter
String FormatString(unsigned int index,...) const
bool AppendDirectory(const String &file_name, const void *pData, size_t data_size)
void __cdecl __debugbreak(void)
struct NPCStats * pNPCStats
std::vector< ODMFace > pFaces
void GameUI_StatusBar_OnEvent(const String &str, unsigned int num_seconds)
const void * GetPixels(IMAGE_FORMAT format)
String GetSubNodeName(size_t index) const
int dword_6BE364_game_settings_1
void LoadGame(unsigned int uSlot)
LEVEL_TYPE uCurrentlyLoadedLevelType
bool CopyFile(const String &from, const String &to)
AudioPlayer * pAudioPlayer
stru123 stru_5E4C90_MapPersistVars
OutdoorLocation * pOutdoor
String StringPrintf(const char *fmt,...)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
std::array< String, 45 > pFileList
void * LoadRaw(const String &pContainer, size_t *data_size=nullptr)
void CompactLayingItemsList()
void SaveGame(bool IsAutoSAve, bool NotSaveWorld)
struct SavegameList * pSavegameList
void Deserialize(struct Timer *)
std::shared_ptr< IRender > render
std::array< SavegameHeader, MAX_SAVE_SLOTS > pSavegameHeader