diff --git a/CMakeLists.txt b/CMakeLists.txt index a8335aa..4b202fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,229 +2,229 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) -project(fallout2-ce LANGUAGES C) +project(fallout2-ce LANGUAGES CXX) add_executable(fallout2-ce WIN32 - "src/actions.c" + "src/actions.cc" "src/actions.h" - "src/animation.c" + "src/animation.cc" "src/animation.h" - "src/args.c" + "src/args.cc" "src/args.h" - "src/art.c" + "src/art.cc" "src/art.h" - "src/audio_file.c" + "src/audio_file.cc" "src/audio_file.h" - "src/audio.c" + "src/audio.cc" "src/audio.h" - "src/automap.c" + "src/automap.cc" "src/automap.h" - "src/autorun.c" + "src/autorun.cc" "src/autorun.h" - "src/cache.c" + "src/cache.cc" "src/cache.h" - "src/character_editor.c" + "src/character_editor.cc" "src/character_editor.h" - "src/character_selector.c" + "src/character_selector.cc" "src/character_selector.h" - "src/color.c" + "src/color.cc" "src/color.h" "src/combat_ai_defs.h" - "src/combat_ai.c" + "src/combat_ai.cc" "src/combat_ai.h" "src/combat_defs.h" - "src/combat.c" + "src/combat.cc" "src/combat.h" - "src/config.c" + "src/config.cc" "src/config.h" - "src/core.c" + "src/core.cc" "src/core.h" - "src/credits.c" + "src/credits.cc" "src/credits.h" - "src/critter.c" + "src/critter.cc" "src/critter.h" - "src/cycle.c" + "src/cycle.cc" "src/cycle.h" - "src/datafile.c" + "src/datafile.cc" "src/datafile.h" - "src/db.c" + "src/db.cc" "src/db.h" - "src/dbox.c" + "src/dbox.cc" "src/dbox.h" - "src/debug.c" + "src/debug.cc" "src/debug.h" - "src/dfile.c" + "src/dfile.cc" "src/dfile.h" - "src/dialog.c" + "src/dialog.cc" "src/dialog.h" - "src/dictionary.c" + "src/dictionary.cc" "src/dictionary.h" - "src/dinput.c" + "src/dinput.cc" "src/dinput.h" - "src/display_monitor.c" + "src/display_monitor.cc" "src/display_monitor.h" - "src/draw.c" + "src/draw.cc" "src/draw.h" - "src/electronic_registration.c" + "src/electronic_registration.cc" "src/electronic_registration.h" - "src/elevator.c" + "src/elevator.cc" "src/elevator.h" - "src/endgame.c" + "src/endgame.cc" "src/endgame.h" - "src/export.c" + "src/export.cc" "src/export.h" - "src/file_find.c" + "src/file_find.cc" "src/file_find.h" - "src/file_utils.c" + "src/file_utils.cc" "src/file_utils.h" - "src/font_manager.c" + "src/font_manager.cc" "src/font_manager.h" - "src/game_config.c" + "src/game_config.cc" "src/game_config.h" - "src/game_dialog.c" + "src/game_dialog.cc" "src/game_dialog.h" - "src/game_memory.c" + "src/game_memory.cc" "src/game_memory.h" - "src/game_mouse.c" + "src/game_mouse.cc" "src/game_mouse.h" - "src/game_movie.c" + "src/game_movie.cc" "src/game_movie.h" - "src/game_palette.c" + "src/game_palette.cc" "src/game_palette.h" - "src/game_sound.c" + "src/game_sound.cc" "src/game_sound.h" "src/game_vars.h" - "src/game.c" + "src/game.cc" "src/game.h" - "src/geometry.c" + "src/geometry.cc" "src/geometry.h" - "src/graph_lib.c" + "src/graph_lib.cc" "src/graph_lib.h" - "src/grayscale.c" + "src/grayscale.cc" "src/grayscale.h" - "src/heap.c" + "src/heap.cc" "src/heap.h" - "src/interface.c" + "src/interface.cc" "src/interface.h" - "src/interpreter_extra.c" + "src/interpreter_extra.cc" "src/interpreter_extra.h" - "src/interpreter_lib.c" + "src/interpreter_lib.cc" "src/interpreter_lib.h" - "src/interpreter.c" + "src/interpreter.cc" "src/interpreter.h" - "src/inventory.c" + "src/inventory.cc" "src/inventory.h" - "src/item.c" + "src/item.cc" "src/item.h" - "src/light.c" + "src/light.cc" "src/light.h" - "src/lips.c" + "src/lips.cc" "src/lips.h" - "src/loadsave.c" + "src/loadsave.cc" "src/loadsave.h" - "src/main.c" + "src/main.cc" "src/main.h" "src/map_defs.h" - "src/map.c" + "src/map.cc" "src/map.h" "src/memory_defs.h" - "src/memory_manager.c" + "src/memory_manager.cc" "src/memory_manager.h" - "src/memory.c" + "src/memory.cc" "src/memory.h" - "src/message.c" + "src/message.cc" "src/message.h" - "src/mmx.c" + "src/mmx.cc" "src/mmx.h" - "src/mouse_manager.c" + "src/mouse_manager.cc" "src/mouse_manager.h" - "src/movie_effect.c" + "src/movie_effect.cc" "src/movie_effect.h" - "src/movie_lib.c" + "src/movie_lib.cc" "src/movie_lib.h" - "src/movie.c" + "src/movie.cc" "src/movie.h" - "src/nevs.c" + "src/nevs.cc" "src/nevs.h" "src/obj_types.h" - "src/object.c" + "src/object.cc" "src/object.h" - "src/options.c" + "src/options.cc" "src/options.h" - "src/palette.c" + "src/palette.cc" "src/palette.h" - "src/party_member.c" + "src/party_member.cc" "src/party_member.h" "src/perk_defs.h" - "src/perk.c" + "src/perk.cc" "src/perk.h" - "src/pipboy.c" + "src/pipboy.cc" "src/pipboy.h" - "src/proto_instance.c" + "src/proto_instance.cc" "src/proto_instance.h" "src/proto_types.h" - "src/proto.c" + "src/proto.cc" "src/proto.h" - "src/queue.c" + "src/queue.cc" "src/queue.h" - "src/random.c" + "src/random.cc" "src/random.h" - "src/reaction.c" + "src/reaction.cc" "src/reaction.h" - "src/region.c" + "src/region.cc" "src/region.h" - "src/scripts.c" + "src/scripts.cc" "src/scripts.h" - "src/select_file_list.c" + "src/select_file_list.cc" "src/select_file_list.h" - "src/selfrun.c" + "src/selfrun.cc" "src/selfrun.h" "src/skill_defs.h" - "src/skill.c" + "src/skill.cc" "src/skill.h" - "src/skilldex.c" + "src/skilldex.cc" "src/skilldex.h" - "src/sound_decoder.c" + "src/sound_decoder.cc" "src/sound_decoder.h" - "src/sound_effects_cache.c" + "src/sound_effects_cache.cc" "src/sound_effects_cache.h" - "src/sound_effects_list.c" + "src/sound_effects_list.cc" "src/sound_effects_list.h" - "src/sound.c" + "src/sound.cc" "src/sound.h" "src/stat_defs.h" - "src/stat.c" + "src/stat.cc" "src/stat.h" - "src/string_parsers.c" + "src/string_parsers.cc" "src/string_parsers.h" - "src/text_font.c" + "src/text_font.cc" "src/text_font.h" - "src/text_object.c" + "src/text_object.cc" "src/text_object.h" - "src/tile.c" + "src/tile.cc" "src/tile.h" "src/trait_defs.h" - "src/trait.c" + "src/trait.cc" "src/trait.h" - "src/trap.c" + "src/trap.cc" "src/trap.h" - "src/version.c" + "src/version.cc" "src/version.h" - "src/widget.c" + "src/widget.cc" "src/widget.h" - "src/win32.c" + "src/win32.cc" "src/win32.h" - "src/window_manager_private.c" + "src/window_manager_private.cc" "src/window_manager_private.h" - "src/window_manager.c" + "src/window_manager.cc" "src/window_manager.h" - "src/window.c" + "src/window.cc" "src/window.h" - "src/word_wrap.c" + "src/word_wrap.cc" "src/word_wrap.h" - "src/world_map.c" + "src/world_map.cc" "src/world_map.h" - "src/xfile.c" + "src/xfile.cc" "src/xfile.h" ) diff --git a/src/actions.c b/src/actions.cc similarity index 99% rename from src/actions.c rename to src/actions.cc index 73c2e16..e5c4d91 100644 --- a/src/actions.c +++ b/src/actions.cc @@ -1488,7 +1488,7 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object* return -2; } - Attack* attack = internal_malloc(sizeof(*attack)); + Attack* attack = (Attack*)internal_malloc(sizeof(*attack)); if (attack == NULL) { return -1; } @@ -1794,7 +1794,7 @@ int _talk_to(Object* a1, Object* a2) // 0x413494 void _action_dmg(int tile, int elevation, int minDamage, int maxDamage, int damageType, bool animated, bool bypassArmor) { - Attack* attack = internal_malloc(sizeof(*attack)); + Attack* attack = (Attack*)internal_malloc(sizeof(*attack)); if (attack == NULL) { return; } diff --git a/src/animation.c b/src/animation.cc similarity index 100% rename from src/animation.c rename to src/animation.cc diff --git a/src/args.c b/src/args.cc similarity index 96% rename from src/args.c rename to src/args.cc index 3ef301d..bb9448f 100644 --- a/src/args.c +++ b/src/args.cc @@ -43,7 +43,7 @@ bool argsParse(CommandLineArguments* commandLineArguments, char* commandLine) argc++; commandLineArguments->argc = argc; - commandLineArguments->argv = malloc(sizeof(*commandLineArguments->argv) * argc); + commandLineArguments->argv = (char**)malloc(sizeof(*commandLineArguments->argv) * argc); if (commandLineArguments->argv == NULL) { argsFree(commandLineArguments); return false; diff --git a/src/art.c b/src/art.cc similarity index 98% rename from src/art.c rename to src/art.cc index 17e3624..4fc1b3b 100644 --- a/src/art.c +++ b/src/art.cc @@ -124,7 +124,7 @@ int artInit() } } - _anon_alias = internal_malloc(sizeof(*_anon_alias) * gArtListDescriptions[1].fileNamesLength); + _anon_alias = (int*)internal_malloc(sizeof(*_anon_alias) * gArtListDescriptions[1].fileNamesLength); if (_anon_alias == NULL) { gArtListDescriptions[1].fileNamesLength = 0; debugPrint("Out of memory for anon_alias in art_init\n"); @@ -132,7 +132,7 @@ int artInit() return -1; } - gArtCritterFidShoudRunData = internal_malloc(sizeof(*gArtCritterFidShoudRunData) * gArtListDescriptions[1].fileNamesLength); + gArtCritterFidShoudRunData = (int*)internal_malloc(sizeof(*gArtCritterFidShoudRunData) * gArtListDescriptions[1].fileNamesLength); if (gArtCritterFidShoudRunData == NULL) { gArtListDescriptions[1].fileNamesLength = 0; debugPrint("Out of memory for artCritterFidShouldRunData in art_init\n"); @@ -207,7 +207,7 @@ int artInit() } } - gHeadDescriptions = internal_malloc(sizeof(HeadDescription) * gArtListDescriptions[8].fileNamesLength); + gHeadDescriptions = (HeadDescription*)internal_malloc(sizeof(HeadDescription) * gArtListDescriptions[8].fileNamesLength); if (gHeadDescriptions == NULL) { gArtListDescriptions[8].fileNamesLength = 0; debugPrint("Out of memory for head_info in art_init\n"); @@ -632,7 +632,7 @@ int artReadList(const char* path, char** out_arr, int* out_count) *out_count = count; - arr = internal_malloc(13 * count); + arr = (char*)internal_malloc(13 * count); *out_arr = arr; if (arr == NULL) { goto err; diff --git a/src/audio.c b/src/audio.cc similarity index 91% rename from src/audio.c rename to src/audio.cc index 1ee0bfe..becff56 100644 --- a/src/audio.c +++ b/src/audio.cc @@ -85,9 +85,9 @@ int audioOpen(const char* fname, int flags, ...) if (index == gAudioListLength) { if (gAudioList != NULL) { - gAudioList = internal_realloc_safe(gAudioList, sizeof(*gAudioList) * (gAudioListLength + 1), __FILE__, __LINE__); // "..\int\audio.c", 216 + gAudioList = (AudioFile*)internal_realloc_safe(gAudioList, sizeof(*gAudioList) * (gAudioListLength + 1), __FILE__, __LINE__); // "..\int\audio.c", 216 } else { - gAudioList = internal_malloc_safe(sizeof(*gAudioList), __FILE__, __LINE__); // "..\int\audio.c", 218 + gAudioList = (AudioFile*)internal_malloc_safe(sizeof(*gAudioList), __FILE__, __LINE__); // "..\int\audio.c", 218 } gAudioListLength++; } @@ -142,7 +142,7 @@ int audioRead(int fileHandle, void* buffer, unsigned int size) } // 0x41A5E0 -int audioSeek(int fileHandle, long offset, int origin) +long audioSeek(int fileHandle, long offset, int origin) { int pos; unsigned char* buf; @@ -173,7 +173,7 @@ int audioSeek(int fileHandle, long offset, int origin) audioFile->fileSize *= 2; if (pos != 0) { - buf = internal_malloc_safe(4096, __FILE__, __LINE__); // "..\int\audio.c", 361 + buf = (unsigned char*)internal_malloc_safe(4096, __FILE__, __LINE__); // "..\int\audio.c", 361 while (pos > 4096) { pos -= 4096; audioRead(fileHandle, buf, 4096); @@ -186,7 +186,7 @@ int audioSeek(int fileHandle, long offset, int origin) internal_free_safe(buf, __FILE__, __LINE__); // // "..\int\audio.c", 367 } } else { - buf = internal_malloc_safe(1024, __FILE__, __LINE__); // "..\int\audio.c", 321 + buf = (unsigned char*)internal_malloc_safe(1024, __FILE__, __LINE__); // "..\int\audio.c", 321 v10 = audioFile->position - pos; while (v10 > 1024) { v10 -= 1024; diff --git a/src/audio.h b/src/audio.h index 388c88a..64a18f3 100644 --- a/src/audio.h +++ b/src/audio.h @@ -13,7 +13,7 @@ int audioSoundDecoderReadHandler(int fileHandle, void* buf, unsigned int size); int audioOpen(const char* fname, int mode, ...); int audioClose(int fileHandle); int audioRead(int fileHandle, void* buffer, unsigned int size); -int audioSeek(int fileHandle, long offset, int origin); +long audioSeek(int fileHandle, long offset, int origin); long audioGetSize(int fileHandle); long audioTell(int fileHandle); int audioWrite(int handle, const void* buf, unsigned int size); diff --git a/src/audio_file.c b/src/audio_file.cc similarity index 94% rename from src/audio_file.c rename to src/audio_file.cc index 59342ee..c6fcca9 100644 --- a/src/audio_file.c +++ b/src/audio_file.cc @@ -88,9 +88,9 @@ int audioFileOpen(const char* fname, int flags, ...) if (index == gAudioFileListLength) { if (gAudioFileList != NULL) { - gAudioFileList = internal_realloc_safe(gAudioFileList, sizeof(*gAudioFileList) * (gAudioFileListLength + 1), __FILE__, __LINE__); // "..\int\audiof.c", 207 + gAudioFileList = (AudioFile*)internal_realloc_safe(gAudioFileList, sizeof(*gAudioFileList) * (gAudioFileListLength + 1), __FILE__, __LINE__); // "..\int\audiof.c", 207 } else { - gAudioFileList = internal_malloc_safe(sizeof(*gAudioFileList), __FILE__, __LINE__); // "..\int\audiof.c", 209 + gAudioFileList = (AudioFile*)internal_malloc_safe(sizeof(*gAudioFileList), __FILE__, __LINE__); // "..\int\audiof.c", 209 } gAudioFileListLength++; } @@ -147,7 +147,7 @@ int audioFileRead(int fileHandle, void* buffer, unsigned int size) } // 0x41AB74 -int audioFileSeek(int fileHandle, long offset, int origin) +long audioFileSeek(int fileHandle, long offset, int origin) { void* buf; int remaining; diff --git a/src/audio_file.h b/src/audio_file.h index 96cf75e..59f7504 100644 --- a/src/audio_file.h +++ b/src/audio_file.h @@ -32,7 +32,7 @@ int audioFileSoundDecoderReadHandler(int fileHandle, void* buffer, unsigned int int audioFileOpen(const char* fname, int flags, ...); int audioFileClose(int a1); int audioFileRead(int a1, void* buf, unsigned int size); -int audioFileSeek(int handle, long offset, int origin); +long audioFileSeek(int handle, long offset, int origin); long audioFileGetSize(int a1); long audioFileTell(int a1); int audioFileWrite(int handle, const void* buf, unsigned int size); diff --git a/src/automap.c b/src/automap.cc similarity index 99% rename from src/automap.c rename to src/automap.cc index 1a0e7f8..33bcdfd 100644 --- a/src/automap.c +++ b/src/automap.cc @@ -555,7 +555,7 @@ int automapRenderInPipboyWindow(int window, int map, int elevation) unsigned char wallColor = _colorTable[992]; unsigned char sceneryColor = _colorTable[480]; - gAutomapEntry.data = internal_malloc(11024); + gAutomapEntry.data = (unsigned char*)internal_malloc(11024); if (gAutomapEntry.data == NULL) { debugPrint("\nAUTOMAP: Error allocating data buffer!\n"); return -1; @@ -623,9 +623,9 @@ int automapSaveCurrent() debugPrint("\nAUTOMAP: Saving AutoMap DB index %d, level %d\n", map, elevation); bool dataBuffersAllocated = false; - gAutomapEntry.data = internal_malloc(11024); + gAutomapEntry.data = (unsigned char*)internal_malloc(11024); if (gAutomapEntry.data != NULL) { - gAutomapEntry.compressedData = internal_malloc(11024); + gAutomapEntry.compressedData = (unsigned char*)internal_malloc(11024); if (gAutomapEntry.compressedData != NULL) { dataBuffersAllocated = true; } @@ -905,7 +905,7 @@ int automapLoadEntry(int map, int elevation) } if (gAutomapEntry.isCompressed == 1) { - gAutomapEntry.compressedData = internal_malloc(11024); + gAutomapEntry.compressedData = (unsigned char*)internal_malloc(11024); if (gAutomapEntry.compressedData == NULL) { debugPrint("\nAUTOMAP: Error allocating decompression buffer!\n"); fileClose(stream); diff --git a/src/autorun.c b/src/autorun.cc similarity index 100% rename from src/autorun.c rename to src/autorun.cc diff --git a/src/cache.c b/src/cache.cc similarity index 96% rename from src/cache.c rename to src/cache.cc index 110ac4a..4fd1a31 100644 --- a/src/cache.c +++ b/src/cache.cc @@ -27,7 +27,7 @@ bool cacheInit(Cache* cache, CacheSizeProc* sizeProc, CacheReadProc* readProc, C cache->entriesLength = 0; cache->entriesCapacity = CACHE_ENTRIES_INITIAL_CAPACITY; cache->hits = 0; - cache->entries = internal_malloc(sizeof(*cache->entries) * cache->entriesCapacity); + cache->entries = (CacheEntry**)internal_malloc(sizeof(*cache->entries) * cache->entriesCapacity); cache->sizeProc = sizeProc; cache->readProc = readProc; cache->freeProc = freeProc; @@ -191,7 +191,7 @@ bool cachePrintStats(Cache* cache, char* dest) // 0x4203AC bool cacheFetchEntryForKey(Cache* cache, int key, int* indexPtr) { - CacheEntry* cacheEntry = internal_malloc(sizeof(*cacheEntry)); + CacheEntry* cacheEntry = (CacheEntry*)internal_malloc(sizeof(*cacheEntry)); if (cacheEntry == NULL) { return false; } @@ -405,7 +405,7 @@ bool cacheResetStatistics(Cache* cache) return false; } - CacheEntry** entries = internal_malloc(sizeof(*entries) * cache->entriesLength); + CacheEntry** entries = (CacheEntry**)internal_malloc(sizeof(*entries) * cache->entriesLength); if (entries == NULL) { return false; } @@ -442,7 +442,7 @@ bool cacheEnsureSize(Cache* cache, int size) return true; } - CacheEntry** entries = internal_malloc(sizeof(*entries) * cache->entriesLength); + CacheEntry** entries = (CacheEntry**)internal_malloc(sizeof(*entries) * cache->entriesLength); if (entries != NULL) { memcpy(entries, cache->entries, sizeof(*entries) * cache->entriesLength); qsort(entries, cache->entriesLength, sizeof(*entries), cacheEntriesCompareByUsage); @@ -542,7 +542,7 @@ bool cacheSetCapacity(Cache* cache, int newCapacity) return false; } - CacheEntry** entries = internal_realloc(cache->entries, sizeof(*cache->entries) * newCapacity); + CacheEntry** entries = (CacheEntry**)internal_realloc(cache->entries, sizeof(*cache->entries) * newCapacity); if (entries == NULL) { return false; } diff --git a/src/cache.h b/src/cache.h index bb47a8a..dfe371a 100644 --- a/src/cache.h +++ b/src/cache.h @@ -33,7 +33,7 @@ typedef struct CacheEntry { // lifetime. unsigned int hits; - CacheEntryFlags flags; + unsigned int flags; // The most recent hit in terms of cache hit counter. Used to track most // recently used entries in eviction strategy. diff --git a/src/character_editor.c b/src/character_editor.cc similarity index 99% rename from src/character_editor.c rename to src/character_editor.cc index 4d9a7aa..55acb42 100644 --- a/src/character_editor.c +++ b/src/character_editor.cc @@ -1110,7 +1110,7 @@ int characterEditorWindowInit() for (i = 0; i < EDITOR_GRAPHIC_COUNT; i++) { if (_copyflag[i]) { - _grphcpy[i] = internal_malloc(_GInfo[i].width * _GInfo[i].height); + _grphcpy[i] = (unsigned char*)internal_malloc(_GInfo[i].width * _GInfo[i].height); if (_grphcpy[i] == NULL) { break; } @@ -3559,13 +3559,13 @@ int _OptionWindow() } do { - down[index] = internal_malloc(size); + down[index] = (unsigned char*)internal_malloc(size); if (down[index] == NULL) { err = 1; break; } - up[index] = internal_malloc(size); + up[index] = (unsigned char*)internal_malloc(size); if (up[index] == NULL) { err = 2; break; @@ -6571,7 +6571,7 @@ int karmaInit() entry.description = atoi(tok); - KarmaEntry* entries = internal_realloc(gKarmaEntries, sizeof(*entries) * (gKarmaEntriesLength + 1)); + KarmaEntry* entries = (KarmaEntry*)internal_realloc(gKarmaEntries, sizeof(*entries) * (gKarmaEntriesLength + 1)); if (entries == NULL) { fileClose(stream); @@ -6656,7 +6656,7 @@ int genericReputationInit() entry.name = atoi(tok); - GenericReputationEntry* entries = internal_realloc(gGenericReputationEntries, sizeof(*entries) * (gGenericReputationEntriesLength + 1)); + GenericReputationEntry* entries = (GenericReputationEntry*)internal_realloc(gGenericReputationEntries, sizeof(*entries) * (gGenericReputationEntriesLength + 1)); if (entries == NULL) { fileClose(stream); diff --git a/src/character_selector.c b/src/character_selector.cc similarity index 99% rename from src/character_selector.c rename to src/character_selector.cc index 6d55303..233ae3d 100644 --- a/src/character_selector.c +++ b/src/character_selector.cc @@ -269,7 +269,7 @@ bool characterSelectorWindowInit() gCharacterSelectorWindowBuffer, CS_WINDOW_WIDTH); - gCharacterSelectorBackground = internal_malloc(CS_WINDOW_BACKGROUND_WIDTH * CS_WINDOW_BACKGROUND_HEIGHT); + gCharacterSelectorBackground = (unsigned char*)internal_malloc(CS_WINDOW_BACKGROUND_WIDTH * CS_WINDOW_BACKGROUND_HEIGHT); if (gCharacterSelectorBackground == NULL) goto err; diff --git a/src/color.c b/src/color.cc similarity index 100% rename from src/color.c rename to src/color.cc diff --git a/src/combat.c b/src/combat.cc similarity index 99% rename from src/combat.c rename to src/combat.cc index c2563bc..f161eb4 100644 --- a/src/combat.c +++ b/src/combat.cc @@ -1955,7 +1955,7 @@ int combatLoad(File* stream) int i; int j; - if (fileReadInt32(stream, &gCombatState) == -1) return -1; + if (fileReadUInt32(stream, &gCombatState) == -1) return -1; if (!isInCombat()) { obj = objectFindFirst(); @@ -2030,7 +2030,7 @@ int combatLoad(File* stream) internal_free(_aiInfoList); } - _aiInfoList = internal_malloc(sizeof(*_aiInfoList) * _list_total); + _aiInfoList = (STRUCT_510948*)internal_malloc(sizeof(*_aiInfoList) * _list_total); if (_aiInfoList == NULL) { return -1; } @@ -2405,7 +2405,7 @@ void _combat_begin(Object* a1) _list_total = objectListCreate(-1, _combat_elev, OBJ_TYPE_CRITTER, &_combat_list); _list_noncom = _list_total; _list_com = 0; - _aiInfoList = internal_malloc(sizeof(*_aiInfoList) * _list_total); + _aiInfoList = (STRUCT_510948*)internal_malloc(sizeof(*_aiInfoList) * _list_total); if (_aiInfoList == NULL) { return; } diff --git a/src/combat_ai.c b/src/combat_ai.cc similarity index 99% rename from src/combat_ai.c rename to src/combat_ai.cc index fe7403f..2c17431 100644 --- a/src/combat_ai.c +++ b/src/combat_ai.cc @@ -282,7 +282,7 @@ int aiInit() return -1; } - gAiPackets = internal_malloc(sizeof(*gAiPackets) * config.entriesLength); + gAiPackets = (AiPacket*)internal_malloc(sizeof(*gAiPackets) * config.entriesLength); if (gAiPackets == NULL) { goto err; } @@ -2656,7 +2656,7 @@ void _combat_ai_begin(int a1, void* a2) _curr_crit_num = a1; if (a1 != 0) { - _curr_crit_list = internal_malloc(sizeof(Object*) * a1); + _curr_crit_list = (Object**)internal_malloc(sizeof(Object*) * a1); if (_curr_crit_list) { memcpy(_curr_crit_list, a2, sizeof(Object*) * a1); } else { diff --git a/src/config.c b/src/config.cc similarity index 96% rename from src/config.c rename to src/config.cc index e01642a..7a14978 100644 --- a/src/config.c +++ b/src/config.cc @@ -37,11 +37,11 @@ void configFree(Config* config) for (int sectionIndex = 0; sectionIndex < config->entriesLength; sectionIndex++) { DictionaryEntry* sectionEntry = &(config->entries[sectionIndex]); - ConfigSection* section = sectionEntry->value; + ConfigSection* section = (ConfigSection*)sectionEntry->value; for (int keyValueIndex = 0; keyValueIndex < section->entriesLength; keyValueIndex++) { DictionaryEntry* keyValueEntry = &(section->entries[keyValueIndex]); - char** value = keyValueEntry->value; + char** value = (char**)keyValueEntry->value; internal_free(*value); *value = NULL; } @@ -120,7 +120,7 @@ bool configGetString(Config* config, const char* sectionKey, const char* key, ch } DictionaryEntry* sectionEntry = &(config->entries[sectionIndex]); - ConfigSection* section = sectionEntry->value; + ConfigSection* section = (ConfigSection*)sectionEntry->value; int index = dictionaryGetIndexByKey(section, key); if (index == -1) { @@ -151,13 +151,13 @@ bool configSetString(Config* config, const char* sectionKey, const char* key, co } DictionaryEntry* sectionEntry = &(config->entries[sectionIndex]); - ConfigSection* section = sectionEntry->value; + ConfigSection* section = (ConfigSection*)sectionEntry->value; int index = dictionaryGetIndexByKey(section, key); if (index != -1) { DictionaryEntry* keyValueEntry = &(section->entries[index]); - char** existingValue = keyValueEntry->value; + char** existingValue = (char**)keyValueEntry->value; internal_free(*existingValue); *existingValue = NULL; @@ -303,7 +303,7 @@ bool configWrite(Config* config, const char* filePath, bool isDb) DictionaryEntry* sectionEntry = &(config->entries[sectionIndex]); filePrintFormatted(stream, "[%s]\n", sectionEntry->key); - ConfigSection* section = sectionEntry->value; + ConfigSection* section = (ConfigSection*)sectionEntry->value; for (int index = 0; index < section->entriesLength; index++) { DictionaryEntry* keyValueEntry = &(section->entries[index]); filePrintFormatted(stream, "%s=%s\n", keyValueEntry->key, *(char**)keyValueEntry->value); @@ -323,7 +323,7 @@ bool configWrite(Config* config, const char* filePath, bool isDb) DictionaryEntry* sectionEntry = &(config->entries[sectionIndex]); fprintf(stream, "[%s]\n", sectionEntry->key); - ConfigSection* section = sectionEntry->value; + ConfigSection* section = (ConfigSection*)sectionEntry->value; for (int index = 0; index < section->entriesLength; index++) { DictionaryEntry* keyValueEntry = &(section->entries[index]); fprintf(stream, "%s=%s\n", keyValueEntry->key, *(char**)keyValueEntry->value); diff --git a/src/core.c b/src/core.cc similarity index 99% rename from src/core.c rename to src/core.cc index 05d5a45..d94efcc 100644 --- a/src/core.c +++ b/src/core.cc @@ -593,7 +593,7 @@ void tickersAdd(TickerProc* proc) curr = curr->next; } - curr = internal_malloc(sizeof(*curr)); + curr = (TickerListNode*)internal_malloc(sizeof(*curr)); curr->flags = 0; curr->proc = proc; curr->next = gTickerListHead; @@ -692,7 +692,7 @@ void takeScreenshot() { int width = _scr_size.right - _scr_size.left + 1; int height = _scr_size.bottom - _scr_size.top + 1; - gScreenshotBuffer = internal_malloc(width * height); + gScreenshotBuffer = (unsigned char*)internal_malloc(width * height); if (gScreenshotBuffer == NULL) { return; } @@ -1527,7 +1527,7 @@ int mouseSetFrame(unsigned char* a1, int width, int height, int pitch, int a5, i } if (width != gMouseCursorWidth || height != gMouseCursorHeight) { - unsigned char* buf = internal_malloc(width * height); + unsigned char* buf = (unsigned char*)internal_malloc(width * height); if (buf == NULL) { if (!cursorWasHidden) { mouseShowCursor(); @@ -4449,7 +4449,7 @@ bool _vcr_record(const char* fileName) return false; } - _vcr_buffer = internal_malloc(sizeof(*_vcr_buffer) * 4096); + _vcr_buffer = (STRUCT_51E2F0*)internal_malloc(sizeof(*_vcr_buffer) * 4096); if (_vcr_buffer == NULL) { return false; } @@ -4492,15 +4492,13 @@ bool _vcr_record(const char* fileName) } // 0x4D28F4 -int _vcr_stop(void) +void _vcr_stop() { if (_vcr_state == 0 || _vcr_state == 1) { _vcr_state |= 0x80000000; } keyboardReset(); - - return 1; } // 0x4D2918 diff --git a/src/core.h b/src/core.h index 9896668..4ffc913 100644 --- a/src/core.h +++ b/src/core.h @@ -626,7 +626,7 @@ void keyboardBuildSpanishConfiguration(); void _kb_init_lock_status(); int keyboardPeekEvent(int index, KeyboardEvent** keyboardEventPtr); bool _vcr_record(const char* fileName); -int _vcr_stop(void); +void _vcr_stop(); int _vcr_status(); int _vcr_update(); bool _vcr_clear_buffer(); diff --git a/src/credits.c b/src/credits.cc similarity index 96% rename from src/credits.c rename to src/credits.cc index b12ab37..34e4270 100644 --- a/src/credits.c +++ b/src/credits.cc @@ -73,7 +73,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle) if (window != -1) { unsigned char* windowBuffer = windowGetBuffer(window); if (windowBuffer != NULL) { - unsigned char* backgroundBuffer = internal_malloc(CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT); + unsigned char* backgroundBuffer = (unsigned char*)internal_malloc(CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT); if (backgroundBuffer) { soundContinueAll(); @@ -96,7 +96,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle) } } - unsigned char* intermediateBuffer = internal_malloc(CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT); + unsigned char* intermediateBuffer = (unsigned char*)internal_malloc(CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT); if (intermediateBuffer != NULL) { memset(intermediateBuffer, 0, CREDITS_WINDOW_WIDTH * CREDITS_WINDOW_HEIGHT); @@ -108,7 +108,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle) int lineHeight = nameFontLineHeight + (titleFontLineHeight >= nameFontLineHeight ? titleFontLineHeight - nameFontLineHeight : 0); int stringBufferSize = CREDITS_WINDOW_WIDTH * lineHeight; - unsigned char* stringBuffer = internal_malloc(stringBufferSize); + unsigned char* stringBuffer = (unsigned char*)internal_malloc(stringBufferSize); if (stringBuffer != NULL) { blitBufferToBuffer(backgroundBuffer, CREDITS_WINDOW_WIDTH, diff --git a/src/critter.c b/src/critter.cc similarity index 98% rename from src/critter.c rename to src/critter.cc index 7b76fc8..968e5e2 100644 --- a/src/critter.c +++ b/src/critter.cc @@ -472,7 +472,7 @@ int _critter_check_rads(Object* obj) if (radiationLevel > _old_rad_level) { // Create timer event for applying radiation damage. - RadiationEvent* radiationEvent = internal_malloc(sizeof(*radiationEvent)); + RadiationEvent* radiationEvent = (RadiationEvent*)internal_malloc(sizeof(*radiationEvent)); if (radiationEvent == NULL) { return 0; } @@ -490,7 +490,7 @@ int _critter_check_rads(Object* obj) // 0x42D618 int _get_rad_damage_level(Object* obj, void* data) { - RadiationEvent* radiationEvent = data; + RadiationEvent* radiationEvent = (RadiationEvent*)data; _old_rad_level = radiationEvent->radiationLevel; @@ -500,7 +500,7 @@ int _get_rad_damage_level(Object* obj, void* data) // 0x42D624 int _clear_rad_damage(Object* obj, void* data) { - RadiationEvent* radiationEvent = data; + RadiationEvent* radiationEvent = (RadiationEvent*)data; if (radiationEvent->isHealing) { _process_rads(obj, radiationEvent->radiationLevel, true); @@ -564,10 +564,10 @@ void _process_rads(Object* obj, int radiationLevel, bool isHealing) // 0x42D740 int radiationEventProcess(Object* obj, void* data) { - RadiationEvent* radiationEvent = data; + RadiationEvent* radiationEvent = (RadiationEvent*)data; if (!radiationEvent->isHealing) { // Schedule healing stats event in 7 days. - RadiationEvent* newRadiationEvent = internal_malloc(sizeof(*newRadiationEvent)); + RadiationEvent* newRadiationEvent = (RadiationEvent*)internal_malloc(sizeof(*newRadiationEvent)); if (newRadiationEvent != NULL) { _queue_clear_type(EVENT_TYPE_RADIATION, _clear_rad_damage); newRadiationEvent->radiationLevel = radiationEvent->radiationLevel; @@ -584,7 +584,7 @@ int radiationEventProcess(Object* obj, void* data) // 0x42D7A0 int radiationEventRead(File* stream, void** dataPtr) { - RadiationEvent* radiationEvent = internal_malloc(sizeof(*radiationEvent)); + RadiationEvent* radiationEvent = (RadiationEvent*)internal_malloc(sizeof(*radiationEvent)); if (radiationEvent == NULL) { return -1; } @@ -604,7 +604,7 @@ err: // 0x42D7FC int radiationEventWrite(File* stream, void* data) { - RadiationEvent* radiationEvent = data; + RadiationEvent* radiationEvent = (RadiationEvent*)data; if (fileWriteInt32(stream, radiationEvent->radiationLevel) == -1) return -1; if (fileWriteInt32(stream, radiationEvent->isHealing) == -1) return -1; diff --git a/src/cycle.c b/src/cycle.cc similarity index 100% rename from src/cycle.c rename to src/cycle.cc diff --git a/src/datafile.c b/src/datafile.cc similarity index 100% rename from src/datafile.c rename to src/datafile.cc diff --git a/src/db.c b/src/db.cc similarity index 99% rename from src/db.c rename to src/db.cc index f66f0d1..c7a511f 100644 --- a/src/db.c +++ b/src/db.cc @@ -601,7 +601,7 @@ int fileWriteUInt32List(File* stream, unsigned int* arr, int count) // 0x4C6628 int fileNameListInit(const char* pattern, char*** fileNameListPtr, int a3, int a4) { - FileList* fileList = malloc(sizeof(*fileList)); + FileList* fileList = (FileList*)malloc(sizeof(*fileList)); if (fileList == NULL) { return 0; } diff --git a/src/dbox.c b/src/dbox.cc similarity index 100% rename from src/dbox.c rename to src/dbox.cc diff --git a/src/debug.c b/src/debug.cc similarity index 97% rename from src/debug.c rename to src/debug.cc index feda03d..6e7f2a2 100644 --- a/src/debug.c +++ b/src/debug.cc @@ -76,7 +76,7 @@ void _debug_register_env() return; } - char* copy = internal_malloc(strlen(type) + 1); + char* copy = (char*)internal_malloc(strlen(type) + 1); if (copy == NULL) { return; } @@ -205,7 +205,7 @@ int _debug_screen(char* string) } // 0x4C709C -void _debug_putc() +void _debug_putc(char ch) { // TODO: Something with segments. } diff --git a/src/debug.h b/src/debug.h index a1b59b7..bc32c54 100644 --- a/src/debug.h +++ b/src/debug.h @@ -22,7 +22,7 @@ void _debug_clear(); int _debug_mono(char* string); int _debug_log(char* string); int _debug_screen(char* string); -void _debug_putc(); +void _debug_putc(char ch); void _debug_exit(void); #endif /* DEBUG_H */ diff --git a/src/dfile.c b/src/dfile.cc similarity index 96% rename from src/dfile.c rename to src/dfile.cc index ccb49d2..f397bcf 100644 --- a/src/dfile.c +++ b/src/dfile.cc @@ -25,7 +25,7 @@ DBase* dbaseOpen(const char* filePath) return NULL; } - DBase* dbase = malloc(sizeof(*dbase)); + DBase* dbase = (DBase*)malloc(sizeof(*dbase)); if (dbase == NULL) { fclose(stream); return NULL; @@ -64,7 +64,7 @@ DBase* dbaseOpen(const char* filePath) goto err; } - dbase->entries = malloc(sizeof(*dbase->entries) * dbase->entriesLength); + dbase->entries = (DBaseEntry*)malloc(sizeof(*dbase->entries) * dbase->entriesLength); if (dbase->entries == NULL) { goto err; } @@ -81,7 +81,7 @@ DBase* dbaseOpen(const char* filePath) break; } - entry->path = malloc(pathLength + 1); + entry->path = (char*)malloc(pathLength + 1); if (entry->path == NULL) { break; } @@ -415,7 +415,7 @@ size_t dfileRead(void* ptr, size_t size, size_t count, DFile* stream) size_t extraBytesRead = 0; if ((stream->flags & DFILE_HAS_UNGETC) != 0) { - unsigned char* byteBuffer = ptr; + unsigned char* byteBuffer = (unsigned char*)ptr; *byteBuffer++ = stream->ungotten & 0xFF; ptr = byteBuffer; @@ -602,7 +602,7 @@ int dbaseFindEntryByFilePath(const void* a1, const void* a2) // 0x4E5D9C DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char* mode, DFile* dfile) { - DBaseEntry* entry = bsearch(filePath, dbase->entries, dbase->entriesLength, sizeof(*dbase->entries), dbaseFindEntryByFilePath); + DBaseEntry* entry = (DBaseEntry*)bsearch(filePath, dbase->entries, dbase->entriesLength, sizeof(*dbase->entries), dbaseFindEntryByFilePath); if (entry == NULL) { goto err; } @@ -612,7 +612,7 @@ DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char* mode, D } if (dfile == NULL) { - dfile = malloc(sizeof(*dfile)); + dfile = (DFile*)malloc(sizeof(*dfile)); if (dfile == NULL) { return NULL; } @@ -655,12 +655,12 @@ DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char* mode, D // passed via parameter, which might already have stream and // buffer allocated. if (dfile->decompressionStream == NULL) { - dfile->decompressionStream = malloc(sizeof(*dfile->decompressionStream)); + dfile->decompressionStream = (z_streamp)malloc(sizeof(*dfile->decompressionStream)); if (dfile->decompressionStream == NULL) { goto err; } - dfile->decompressionBuffer = malloc(DFILE_DECOMPRESSION_BUFFER_SIZE); + dfile->decompressionBuffer = (unsigned char*)malloc(DFILE_DECOMPRESSION_BUFFER_SIZE); if (dfile->decompressionBuffer == NULL) { goto err; } @@ -765,7 +765,7 @@ int dfileReadCharInternal(DFile* stream) bool dfileReadCompressed(DFile* stream, void* ptr, size_t size) { if ((stream->flags & DFILE_HAS_COMPRESSED_UNGETC) != 0) { - unsigned char* byteBuffer = ptr; + unsigned char* byteBuffer = (unsigned char*)ptr; *byteBuffer++ = stream->compressedUngotten & 0xFF; ptr = byteBuffer; @@ -779,7 +779,7 @@ bool dfileReadCompressed(DFile* stream, void* ptr, size_t size) } } - stream->decompressionStream->next_out = ptr; + stream->decompressionStream->next_out = (Bytef*)ptr; stream->decompressionStream->avail_out = size; do { diff --git a/src/dialog.c b/src/dialog.cc similarity index 94% rename from src/dialog.c rename to src/dialog.cc index 4473122..50dd167 100644 --- a/src/dialog.c +++ b/src/dialog.cc @@ -170,10 +170,10 @@ STRUCT_56DAE0_FIELD_4* _getReply() v0 = &(_dialog[_tods].field_4[_dialog[_tods].field_C]); if (v0->field_C == NULL) { v0->field_14 = 1; - v1 = internal_malloc_safe(sizeof(STRUCT_56DAE0_FIELD_4_FIELD_C), __FILE__, __LINE__); // "..\\int\\DIALOG.C", 789 + v1 = (STRUCT_56DAE0_FIELD_4_FIELD_C*)internal_malloc_safe(sizeof(STRUCT_56DAE0_FIELD_4_FIELD_C), __FILE__, __LINE__); // "..\\int\\DIALOG.C", 789 } else { v0->field_14++; - v1 = internal_realloc_safe(v0->field_C, sizeof(STRUCT_56DAE0_FIELD_4_FIELD_C) * v0->field_14, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 793 + v1 = (STRUCT_56DAE0_FIELD_4_FIELD_C*)internal_realloc_safe(v0->field_C, sizeof(STRUCT_56DAE0_FIELD_4_FIELD_C) * v0->field_14, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 793 } v0->field_C = v1; @@ -193,7 +193,7 @@ void _replyAddOption(const char* a1, const char* a2, int a3) v18->field_C[v17].field_8 = 2; if (a1 != NULL) { - v14 = internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 805 + v14 = (char*)internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 805 strcpy(v14, a1); v18->field_C[v17].field_0 = v14; } else { @@ -201,7 +201,7 @@ void _replyAddOption(const char* a1, const char* a2, int a3) } if (a2 != NULL) { - v15 = internal_malloc_safe(strlen(a2) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 810 + v15 = (char*)internal_malloc_safe(strlen(a2) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 810 strcpy(v15, a2); v18->field_C[v17].field_4 = v15; } else { @@ -226,7 +226,7 @@ void _replyAddOptionProc(const char* a1, const char* a2, int a3) v5->field_C[v13].field_8 = 1; if (a1 != NULL) { - v11 = internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 830 + v11 = (char*)internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 830 strcpy(v11, a1); v5->field_C[v13].field_0 = v11; } else { @@ -472,7 +472,7 @@ int dialogSetReplyTitle(const char* a1) } if (a1 != NULL) { - gDialogReplyTitle = internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2564 + gDialogReplyTitle = (char*)internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2564 strcpy(gDialogReplyTitle, a1); } else { gDialogReplyTitle = NULL; diff --git a/src/dictionary.c b/src/dictionary.cc similarity index 95% rename from src/dictionary.c rename to src/dictionary.cc index 06c363b..39ca87f 100644 --- a/src/dictionary.c +++ b/src/dictionary.cc @@ -56,7 +56,7 @@ int dictionaryInit(Dictionary* dictionary, int initialCapacity, size_t valueSize int rc = 0; if (initialCapacity != 0) { - dictionary->entries = gDictionaryMallocProc(sizeof(*dictionary->entries) * initialCapacity); + dictionary->entries = (DictionaryEntry*)gDictionaryMallocProc(sizeof(*dictionary->entries) * initialCapacity); if (dictionary->entries == NULL) { rc = -1; } @@ -82,7 +82,7 @@ int dictionarySetCapacity(Dictionary* dictionary, int newCapacity) return -1; } - DictionaryEntry* entries = gDictionaryReallocProc(dictionary->entries, sizeof(*dictionary->entries) * newCapacity); + DictionaryEntry* entries = (DictionaryEntry*)gDictionaryReallocProc(dictionary->entries, sizeof(*dictionary->entries) * newCapacity); if (entries == NULL) { return -1; } @@ -215,7 +215,7 @@ int dictionaryAddValue(Dictionary* dictionary, const char* key, const void* valu } // Make a copy of the key. - char* keyCopy = gDictionaryMallocProc(strlen(key) + 1); + char* keyCopy = (char*)gDictionaryMallocProc(strlen(key) + 1); if (keyCopy == NULL) { return -1; } diff --git a/src/dinput.c b/src/dinput.cc similarity index 99% rename from src/dinput.c rename to src/dinput.cc index dea7d05..7f5864e 100644 --- a/src/dinput.c +++ b/src/dinput.cc @@ -512,7 +512,7 @@ bool mouseDeviceInit() { HRESULT hr; - hr = IDirectInput_CreateDevice(gDirectInput, &GUID_SysMouse, &gMouseDevice, NULL); + hr = IDirectInput_CreateDevice(gDirectInput, GUID_SysMouse, &gMouseDevice, NULL); if (hr != DI_OK) { goto err; } @@ -552,7 +552,7 @@ bool keyboardDeviceInit() { HRESULT hr; - hr = IDirectInput_CreateDevice(gDirectInput, &GUID_SysKeyboard, &gKeyboardDevice, NULL); + hr = IDirectInput_CreateDevice(gDirectInput, GUID_SysKeyboard, &gKeyboardDevice, NULL); if (hr != DI_OK) { goto err; } diff --git a/src/display_monitor.c b/src/display_monitor.cc similarity index 98% rename from src/display_monitor.c rename to src/display_monitor.cc index 0773c18..e514f63 100644 --- a/src/display_monitor.c +++ b/src/display_monitor.cc @@ -73,7 +73,7 @@ int displayMonitorInit() _disp_curr = 0; fontSetCurrent(oldFont); - gDisplayMonitorBackgroundFrmData = internal_malloc(DISPLAY_MONITOR_WIDTH * DISPLAY_MONITOR_HEIGHT); + gDisplayMonitorBackgroundFrmData = (unsigned char*)internal_malloc(DISPLAY_MONITOR_WIDTH * DISPLAY_MONITOR_HEIGHT); if (gDisplayMonitorBackgroundFrmData == NULL) { return -1; } diff --git a/src/draw.c b/src/draw.cc similarity index 100% rename from src/draw.c rename to src/draw.cc diff --git a/src/electronic_registration.c b/src/electronic_registration.cc similarity index 100% rename from src/electronic_registration.c rename to src/electronic_registration.cc diff --git a/src/elevator.c b/src/elevator.cc similarity index 100% rename from src/elevator.c rename to src/elevator.cc diff --git a/src/endgame.c b/src/endgame.cc similarity index 98% rename from src/endgame.c rename to src/endgame.cc index b8a378c..8462148 100644 --- a/src/endgame.c +++ b/src/endgame.cc @@ -515,7 +515,7 @@ int endgameEndingSlideshowWindowInit() sprintf(gEndgameEndingSubtitlesLocalizedPath, "text\\%s\\cuts\\", language); - gEndgameEndingSubtitles = internal_malloc(sizeof(*gEndgameEndingSubtitles) * ENDGAME_ENDING_MAX_SUBTITLES); + gEndgameEndingSubtitles = (char**)internal_malloc(sizeof(*gEndgameEndingSubtitles) * ENDGAME_ENDING_MAX_SUBTITLES); if (gEndgameEndingSubtitles == NULL) { gEndgameEndingSubtitlesEnabled = false; return 0; @@ -525,7 +525,7 @@ int endgameEndingSlideshowWindowInit() gEndgameEndingSubtitles[index] = NULL; } - gEndgameEndingSubtitlesTimings = internal_malloc(sizeof(*gEndgameEndingSubtitlesTimings) * ENDGAME_ENDING_MAX_SUBTITLES); + gEndgameEndingSubtitlesTimings = (unsigned int*)internal_malloc(sizeof(*gEndgameEndingSubtitlesTimings) * ENDGAME_ENDING_MAX_SUBTITLES); if (gEndgameEndingSubtitlesTimings == NULL) { internal_free(gEndgameEndingSubtitles); gEndgameEndingSubtitlesEnabled = false; @@ -879,7 +879,7 @@ int endgameEndingInit() entry.direction = 1; } - entries = internal_realloc(gEndgameEndings, sizeof(*entries) * (gEndgameEndingsLength + 1)); + entries = (EndgameEnding*)internal_realloc(gEndgameEndings, sizeof(*entries) * (gEndgameEndingsLength + 1)); if (entries == NULL) { goto err; } @@ -1001,7 +1001,7 @@ int endgameDeathEndingInit() entry.voiceOverBaseName[narrator_file_len - 1] = '\0'; } - entries = internal_realloc(gEndgameDeathEndings, sizeof(*entries) * (gEndgameDeathEndingsLength + 1)); + entries = (EndgameDeathEnding*)internal_realloc(gEndgameDeathEndings, sizeof(*entries) * (gEndgameDeathEndingsLength + 1)); if (entries == NULL) { goto err; } diff --git a/src/export.c b/src/export.cc similarity index 96% rename from src/export.c rename to src/export.cc index 517daec..e40644e 100644 --- a/src/export.c +++ b/src/export.cc @@ -163,7 +163,7 @@ int externalVariableSetValue(Program* program, const char* name, opcode_t opcode const char* stringValue = programGetString(program, opcode, data); exportedVariable->type = VALUE_TYPE_DYNAMIC_STRING; - exportedVariable->stringValue = internal_malloc_safe(strlen(stringValue) + 1, __FILE__, __LINE__); // "..\\int\\EXPORT.C", 175 + exportedVariable->stringValue = (char*)internal_malloc_safe(strlen(stringValue) + 1, __FILE__, __LINE__); // "..\\int\\EXPORT.C", 175 strcpy(exportedVariable->stringValue, stringValue); } } else { @@ -215,7 +215,7 @@ int externalVariableCreate(Program* program, const char* identifier) strncpy(exportedVariable->name, identifier, 31); - exportedVariable->programName = internal_malloc_safe(strlen(programName) + 1, __FILE__, __LINE__); // // "..\\int\\EXPORT.C", 243 + exportedVariable->programName = (char*)internal_malloc_safe(strlen(programName) + 1, __FILE__, __LINE__); // // "..\\int\\EXPORT.C", 243 strcpy(exportedVariable->programName, programName); } diff --git a/src/file_find.c b/src/file_find.cc similarity index 100% rename from src/file_find.c rename to src/file_find.cc diff --git a/src/file_utils.c b/src/file_utils.cc similarity index 100% rename from src/file_utils.c rename to src/file_utils.cc diff --git a/src/font_manager.c b/src/font_manager.cc similarity index 98% rename from src/font_manager.c rename to src/font_manager.cc index 31029a8..fc69afc 100644 --- a/src/font_manager.c +++ b/src/font_manager.cc @@ -124,7 +124,7 @@ int interfaceFontLoad(int font_index) fileSize -= sizeof(InterfaceFontDescriptor); - fontDescriptor->data = internal_malloc_safe(fileSize, __FILE__, __LINE__); // FONTMGR.C, 259 + fontDescriptor->data = (unsigned char*)internal_malloc_safe(fileSize, __FILE__, __LINE__); // FONTMGR.C, 259 if (fontDescriptor->data == NULL) goto err; if (fileRead(fontDescriptor->data, fileSize, 1, stream) != 1) { diff --git a/src/game.c b/src/game.cc similarity index 99% rename from src/game.c rename to src/game.cc index fdd946d..d6e5ff9 100644 --- a/src/game.c +++ b/src/game.cc @@ -933,7 +933,7 @@ int globalVarsRead(const char* path, const char* section, int* out_vars_num, int } *out_vars_num = *out_vars_num + 1; - *out_vars = internal_realloc(*out_vars, sizeof(int) * *out_vars_num); + *out_vars = (int*)internal_realloc(*out_vars, sizeof(int) * *out_vars_num); if (*out_vars == NULL) { exit(1); @@ -1239,13 +1239,13 @@ void showSplash() return; } - unsigned char* palette = internal_malloc(768); + unsigned char* palette = (unsigned char*)internal_malloc(768); if (palette == NULL) { fileClose(stream); return; } - unsigned char* data = internal_malloc(SPLASH_WIDTH * SPLASH_HEIGHT); + unsigned char* data = (unsigned char*)internal_malloc(SPLASH_WIDTH * SPLASH_HEIGHT); if (data == NULL) { internal_free(palette); fileClose(stream); diff --git a/src/game_config.c b/src/game_config.cc similarity index 100% rename from src/game_config.c rename to src/game_config.cc diff --git a/src/game_dialog.c b/src/game_dialog.cc similarity index 99% rename from src/game_dialog.c rename to src/game_dialog.cc index e46c75f..b1381e8 100644 --- a/src/game_dialog.c +++ b/src/game_dialog.cc @@ -1488,7 +1488,7 @@ int gameDialogAddReviewText(const char* string) entry->replyText = NULL; } - entry->replyText = internal_malloc(strlen(string) + 1); + entry->replyText = (char*)internal_malloc(strlen(string) + 1); strcpy(entry->replyText, string); entry->optionMessageListId = -3; @@ -1528,7 +1528,7 @@ int gameDialogSetReviewOptionText(const char* string) entry->optionMessageListId = -4; entry->optionMessageId = -4; - entry->optionText = internal_malloc(strlen(string) + 1); + entry->optionText = (char*)internal_malloc(strlen(string) + 1); strcpy(entry->optionText, string); return 0; @@ -2180,7 +2180,7 @@ int _gdCreateHeadWindow() Rect* rect = &(_backgrndRects[index]); int width = rect->right - rect->left; int height = rect->bottom - rect->top; - _backgrndBufs[index] = internal_malloc(width * height); + _backgrndBufs[index] = (unsigned char*)internal_malloc(width * height); if (_backgrndBufs[index] == NULL) { return -1; } diff --git a/src/game_memory.c b/src/game_memory.cc similarity index 100% rename from src/game_memory.c rename to src/game_memory.cc diff --git a/src/game_mouse.c b/src/game_mouse.cc similarity index 100% rename from src/game_mouse.c rename to src/game_mouse.cc diff --git a/src/game_movie.c b/src/game_movie.cc similarity index 100% rename from src/game_movie.c rename to src/game_movie.cc diff --git a/src/game_palette.c b/src/game_palette.cc similarity index 100% rename from src/game_palette.c rename to src/game_palette.cc diff --git a/src/game_sound.c b/src/game_sound.cc similarity index 99% rename from src/game_sound.c rename to src/game_sound.cc index 865aedd..132f396 100644 --- a/src/game_sound.c +++ b/src/game_sound.cc @@ -1932,7 +1932,7 @@ int _gsound_get_music_path(char** out_value, const char* key) return 0; } - v4 = internal_malloc(v3 - 1 + 2); + v4 = (char*)internal_malloc(v3 - 1 + 2); if (v4 == NULL) { if (gGameSoundDebugEnabled) { debugPrint("Out of memory in gsound_get_music_path.\n"); @@ -2057,7 +2057,7 @@ int ambientSoundEffectEventProcess(Object* a1, void* data) { _queue_clear_type(EVENT_TYPE_GSOUND_SFX_EVENT, NULL); - AmbientSoundEffectEvent* soundEffectEvent = data; + AmbientSoundEffectEvent* soundEffectEvent = (AmbientSoundEffectEvent*)data; int ambientSoundEffectIndex = -1; if (soundEffectEvent != NULL) { ambientSoundEffectIndex = soundEffectEvent->ambientSoundEffectIndex; @@ -2067,7 +2067,7 @@ int ambientSoundEffectEventProcess(Object* a1, void* data) } } - AmbientSoundEffectEvent* nextSoundEffectEvent = internal_malloc(sizeof(*nextSoundEffectEvent)); + AmbientSoundEffectEvent* nextSoundEffectEvent = (AmbientSoundEffectEvent*)internal_malloc(sizeof(*nextSoundEffectEvent)); if (nextSoundEffectEvent == NULL) { return -1; } diff --git a/src/geometry.c b/src/geometry.cc similarity index 94% rename from src/geometry.c rename to src/geometry.cc index 5ca5e37..8f03204 100644 --- a/src/geometry.c +++ b/src/geometry.cc @@ -2,6 +2,7 @@ #include "memory.h" +#include #include // 0x51DEF4 @@ -108,7 +109,7 @@ RectListNode* _rect_malloc() { if (_rectList == NULL) { for (int index = 0; index < 10; index++) { - RectListNode* rectListNode = internal_malloc(sizeof(*rectListNode)); + RectListNode* rectListNode = (RectListNode*)internal_malloc(sizeof(*rectListNode)); if (rectListNode == NULL) { break; } @@ -141,10 +142,10 @@ void _rect_free(RectListNode* rectListNode) // 0x4C6C18 void rectUnion(const Rect* s1, const Rect* s2, Rect* r) { - r->left = min(s1->left, s2->left); - r->top = min(s1->top, s2->top); - r->right = max(s1->right, s2->right); - r->bottom = max(s1->bottom, s2->bottom); + r->left = std::min(s1->left, s2->left); + r->top = std::min(s1->top, s2->top); + r->right = std::max(s1->right, s2->right); + r->bottom = std::max(s1->bottom, s2->bottom); } // Calculates intersection of two source rectangles and places it into third diff --git a/src/graph_lib.c b/src/graph_lib.cc similarity index 95% rename from src/graph_lib.c rename to src/graph_lib.cc index da4f89f..6141ee0 100644 --- a/src/graph_lib.c +++ b/src/graph_lib.cc @@ -39,10 +39,10 @@ int graphCompress(unsigned char* a1, unsigned char* a2, int a3) // NOTE: Original code is slightly different, it uses deep nesting or a // bunch of gotos. - _lson = internal_malloc(sizeof(*_lson) * 4104); - _rson = internal_malloc(sizeof(*_rson) * 4376); - _dad_2 = internal_malloc(sizeof(*_dad_2) * 4104); - _text_buf = internal_malloc(sizeof(*_text_buf) * 4122); + _lson = (int*)internal_malloc(sizeof(*_lson) * 4104); + _rson = (int*)internal_malloc(sizeof(*_rson) * 4376); + _dad_2 = (int*)internal_malloc(sizeof(*_dad_2) * 4104); + _text_buf = (unsigned char*)internal_malloc(sizeof(*_text_buf) * 4122); if (_lson == NULL || _rson == NULL || _dad_2 == NULL || _text_buf == NULL) { debugPrint("\nGRAPHLIB: Error allocating compression buffers!\n"); @@ -323,7 +323,7 @@ void _DeleteNode(int a1) // 0x44F92C int graphDecompress(unsigned char* src, unsigned char* dest, int length) { - _text_buf = internal_malloc(sizeof(*_text_buf) * 4122); + _text_buf = (unsigned char*)internal_malloc(sizeof(*_text_buf) * 4122); if (_text_buf == NULL) { debugPrint("\nGRAPHLIB: Error allocating decompression buffer!\n"); return -1; diff --git a/src/grayscale.c b/src/grayscale.cc similarity index 76% rename from src/grayscale.c rename to src/grayscale.cc index 090eab1..725e305 100644 --- a/src/grayscale.c +++ b/src/grayscale.cc @@ -2,6 +2,8 @@ #include "color.h" +#include + // 0x596D90 unsigned char _GreyTable[256]; @@ -13,8 +15,8 @@ void grayscalePaletteUpdate(int a1, int a2) // NOTE: The only way to explain so much calls to [_Color2RGB_] with // the same repeated pattern is by the use of min/max macros. - int v1 = max((_Color2RGB_(index) & 0x7C00) >> 10, max((_Color2RGB_(index) & 0x3E0) >> 5, _Color2RGB_(index) & 0x1F)); - int v2 = min((_Color2RGB_(index) & 0x7C00) >> 10, min((_Color2RGB_(index) & 0x3E0) >> 5, _Color2RGB_(index) & 0x1F)); + int v1 = std::max((_Color2RGB_(index) & 0x7C00) >> 10, std::max((_Color2RGB_(index) & 0x3E0) >> 5, _Color2RGB_(index) & 0x1F)); + int v2 = std::min((_Color2RGB_(index) & 0x7C00) >> 10, std::min((_Color2RGB_(index) & 0x3E0) >> 5, _Color2RGB_(index) & 0x1F)); int v3 = v1 + v2; int v4 = (int)((double)v3 * 240.0 / 510.0); diff --git a/src/heap.c b/src/heap.cc similarity index 95% rename from src/heap.c rename to src/heap.cc index 72f76a8..c7f5215 100644 --- a/src/heap.c +++ b/src/heap.cc @@ -69,26 +69,26 @@ bool heapInternalsInit() // bunch of goto's to free alloc'ed buffers one by one starting from where // it has failed. do { - gHeapFreeBlocks = internal_malloc(sizeof(*gHeapFreeBlocks) * HEAP_FREE_BLOCKS_INITIAL_LENGTH); + gHeapFreeBlocks = (unsigned char**)internal_malloc(sizeof(*gHeapFreeBlocks) * HEAP_FREE_BLOCKS_INITIAL_LENGTH); if (gHeapFreeBlocks == NULL) { break; } gHeapFreeBlocksLength = HEAP_FREE_BLOCKS_INITIAL_LENGTH; - gHeapMoveableExtents = internal_malloc(sizeof(*gHeapMoveableExtents) * HEAP_MOVEABLE_EXTENTS_INITIAL_LENGTH); + gHeapMoveableExtents = (HeapMoveableExtent*)internal_malloc(sizeof(*gHeapMoveableExtents) * HEAP_MOVEABLE_EXTENTS_INITIAL_LENGTH); if (gHeapMoveableExtents == NULL) { break; } gHeapMoveableExtentsLength = HEAP_MOVEABLE_EXTENTS_INITIAL_LENGTH; - gHeapMoveableBlocks = internal_malloc(sizeof(*gHeapMoveableBlocks) * HEAP_MOVEABLE_BLOCKS_INITIAL_LENGTH); + gHeapMoveableBlocks = (unsigned char**)internal_malloc(sizeof(*gHeapMoveableBlocks) * HEAP_MOVEABLE_BLOCKS_INITIAL_LENGTH); if (gHeapMoveableBlocks == NULL) { break; } gHeapMoveableBlocksLength = HEAP_MOVEABLE_BLOCKS_INITIAL_LENGTH; - gHeapReservedFreeBlockIndexes = internal_malloc(sizeof(*gHeapReservedFreeBlockIndexes) * HEAP_RESERVED_FREE_BLOCK_INDEXES_INITIAL_LENGTH); + gHeapReservedFreeBlockIndexes = (int*)internal_malloc(sizeof(*gHeapReservedFreeBlockIndexes) * HEAP_RESERVED_FREE_BLOCK_INDEXES_INITIAL_LENGTH); if (gHeapReservedFreeBlockIndexes == NULL) { break; } @@ -148,7 +148,7 @@ bool heapInit(Heap* heap, int a2) if (heapHandleListInit(heap)) { int size = (a2 >> 10) + a2; - heap->data = internal_malloc(size); + heap->data = (unsigned char*)internal_malloc(size); if (heap->data != NULL) { heap->size = size; heap->freeBlocks = 1; @@ -213,7 +213,7 @@ bool heapFree(Heap* heap) // 0x453430 bool heapHandleListInit(Heap* heap) { - heap->handles = internal_malloc(sizeof(*heap->handles) * HEAP_HANDLES_INITIAL_LENGTH); + heap->handles = (HeapHandle*)internal_malloc(sizeof(*heap->handles) * HEAP_HANDLES_INITIAL_LENGTH); if (heap->handles == NULL) { debugPrint("Heap Error : Could not initialize handles.\n"); return false; @@ -241,7 +241,7 @@ bool heapBlockAllocate(Heap* heap, int* handleIndexPtr, int size, int a4) a4 = 0; } - unsigned char* block; + void* block; if (!heapFindFreeBlock(heap, size, &block, a4)) { goto err; } @@ -263,7 +263,7 @@ bool heapBlockAllocate(Heap* heap, int* handleIndexPtr, int size, int a4) // Bind handle to block and mark it as system handle->state = HEAP_BLOCK_STATE_SYSTEM; - handle->data = block; + handle->data = (unsigned char*)block; // Update heap stats heap->systemBlocks++; @@ -283,11 +283,11 @@ bool heapBlockAllocate(Heap* heap, int* handleIndexPtr, int size, int a4) blockSize = size; // - HeapBlockFooter* blockFooter = (HeapBlockFooter*)(block + blockHeader->size + HEAP_BLOCK_HEADER_SIZE); + HeapBlockFooter* blockFooter = (HeapBlockFooter*)((unsigned char*)block + blockHeader->size + HEAP_BLOCK_HEADER_SIZE); blockFooter->guard = HEAP_BLOCK_FOOTER_GUARD; // Obtain beginning of the next block. - unsigned char* nextBlock = block + blockHeader->size + HEAP_BLOCK_OVERHEAD_SIZE; + unsigned char* nextBlock = (unsigned char*)block + blockHeader->size + HEAP_BLOCK_OVERHEAD_SIZE; // Setup next block's header... HeapBlockHeader* nextBlockHeader = (HeapBlockHeader*)nextBlock; @@ -311,7 +311,7 @@ bool heapBlockAllocate(Heap* heap, int* handleIndexPtr, int size, int a4) // Bind handle to block and mark it as moveable handle->state = HEAP_BLOCK_STATE_MOVABLE; - handle->data = block; + handle->data = (unsigned char*)block; // Update heap stats heap->freeBlocks--; @@ -572,7 +572,7 @@ bool heapFindFreeHandle(Heap* heap, int* handleIndexPtr) } // If we're here the search above failed, we have to allocate more handles. - HeapHandle* handles = internal_realloc(heap->handles, sizeof(*handles) * (heap->handlesLength + HEAP_HANDLES_INITIAL_LENGTH)); + HeapHandle* handles = (HeapHandle*)internal_realloc(heap->handles, sizeof(*handles) * (heap->handlesLength + HEAP_HANDLES_INITIAL_LENGTH)); if (handles == NULL) { return false; } @@ -640,7 +640,7 @@ bool heapFindFreeBlock(Heap* heap, int size, void** blockPtr, int a4) // Ensure the length of [gHeapReservedFreeBlockIndexes] array is big enough // to index all blocks for longest moveable extent. if (maxBlocksCount > gHeapReservedFreeBlockIndexesLength) { - int* indexes = internal_realloc(gHeapReservedFreeBlockIndexes, sizeof(*gHeapReservedFreeBlockIndexes) * maxBlocksCount); + int* indexes = (int*)internal_realloc(gHeapReservedFreeBlockIndexes, sizeof(*gHeapReservedFreeBlockIndexes) * maxBlocksCount); if (indexes == NULL) { goto system; } @@ -836,7 +836,7 @@ system: if (a4 == 0) { debugPrint("Allocating block from system memory...\n"); - unsigned char* block = internal_malloc(size + HEAP_BLOCK_OVERHEAD_SIZE); + unsigned char* block = (unsigned char*)internal_malloc(size + HEAP_BLOCK_OVERHEAD_SIZE); if (block == NULL) { debugPrint("fatal error: internal_malloc() failed in heap_find_free_block()!\n"); return false; @@ -867,7 +867,7 @@ bool heapBuildMoveableBlocksList(int extentIndex) { HeapMoveableExtent* extent = &(gHeapMoveableExtents[extentIndex]); if (extent->moveableBlocksLength > gHeapMoveableBlocksLength) { - unsigned char** moveableBlocks = internal_realloc(gHeapMoveableBlocks, sizeof(*gHeapMoveableBlocks) * extent->moveableBlocksLength); + unsigned char** moveableBlocks = (unsigned char**)internal_realloc(gHeapMoveableBlocks, sizeof(*gHeapMoveableBlocks) * extent->moveableBlocksLength); if (moveableBlocks == NULL) { return false; } @@ -905,7 +905,7 @@ bool heapBuildFreeBlocksList(Heap* heap) } if (heap->freeBlocks > gHeapFreeBlocksLength) { - unsigned char** freeBlocks = internal_realloc(gHeapFreeBlocks, sizeof(*freeBlocks) * heap->freeBlocks); + unsigned char** freeBlocks = (unsigned char**)internal_realloc(gHeapFreeBlocks, sizeof(*freeBlocks) * heap->freeBlocks); if (freeBlocks == NULL) { return false; } @@ -978,7 +978,7 @@ bool heapBuildMoveableExtentsList(Heap* heap, int* moveableExtentsLengthPtr, int } if (maxExtentsCount > gHeapMoveableExtentsLength) { - HeapMoveableExtent* moveableExtents = internal_realloc(gHeapMoveableExtents, sizeof(*gHeapMoveableExtents) * maxExtentsCount); + HeapMoveableExtent* moveableExtents = (HeapMoveableExtent*)internal_realloc(gHeapMoveableExtents, sizeof(*gHeapMoveableExtents) * maxExtentsCount); if (moveableExtents == NULL) { return false; } diff --git a/src/heap.h b/src/heap.h index 740aed5..4795fae 100644 --- a/src/heap.h +++ b/src/heap.h @@ -41,7 +41,7 @@ typedef enum HeapBlockState { typedef struct HeapBlockHeader { int guard; int size; - HeapBlockState state; + unsigned int state; int handle_index; } HeapBlockHeader; @@ -50,7 +50,7 @@ typedef struct HeapBlockFooter { } HeapBlockFooter; typedef struct HeapHandle { - HeapBlockState state; + unsigned int state; unsigned char* data; } HeapHandle; diff --git a/src/interface.c b/src/interface.cc similarity index 99% rename from src/interface.c rename to src/interface.cc index 5ceeb56..0f8271b 100644 --- a/src/interface.c +++ b/src/interface.cc @@ -2349,7 +2349,7 @@ int indicatorBarInit() for (int index = 0; index < INDICATOR_COUNT; index++) { IndicatorDescription* indicatorDescription = &(gIndicatorDescriptions[index]); - indicatorDescription->data = internal_malloc(INDICATOR_BOX_WIDTH * INDICATOR_BOX_HEIGHT); + indicatorDescription->data = (unsigned char*)internal_malloc(INDICATOR_BOX_WIDTH * INDICATOR_BOX_HEIGHT); if (indicatorDescription->data == NULL) { debugPrint("\nINTRFACE: Error initializing indicator box graphics! **"); diff --git a/src/interpreter.c b/src/interpreter.cc similarity index 98% rename from src/interpreter.c rename to src/interpreter.cc index 9686cfb..826b606 100644 --- a/src/interpreter.c +++ b/src/interpreter.cc @@ -415,25 +415,25 @@ Program* programCreateByPath(const char* path) } int fileSize = fileGetSize(stream); - unsigned char* data = internal_malloc_safe(fileSize, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 458 + unsigned char* data = (unsigned char*)internal_malloc_safe(fileSize, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 458 fileRead(data, 1, fileSize, stream); fileClose(stream); - Program* program = internal_malloc_safe(sizeof(Program), __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 463 + Program* program = (Program*)internal_malloc_safe(sizeof(Program), __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 463 memset(program, 0, sizeof(Program)); - program->name = internal_malloc_safe(strlen(path) + 1, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 466 + program->name = (char*)internal_malloc_safe(strlen(path) + 1, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 466 strcpy(program->name, path); program->child = NULL; program->parent = NULL; program->field_78 = -1; - program->stack = internal_calloc_safe(1, 4096, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 472 + program->stack = (unsigned char*)internal_calloc_safe(1, 4096, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 472 program->exited = false; program->basePointer = -1; program->framePointer = -1; - program->returnStack = internal_calloc_safe(1, 4096, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 473 + program->returnStack = (unsigned char*)internal_calloc_safe(1, 4096, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 473 program->data = data; program->procedures = data + 42; program->identifiers = 24 * stackReadInt32(program->procedures, 0) + program->procedures + 4; @@ -564,13 +564,13 @@ int programPushString(Program* program, char* string) heap += v2 + 4; } } else { - program->dynamicStrings = internal_malloc_safe(8, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 631 + program->dynamicStrings = (unsigned char*)internal_malloc_safe(8, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 631 *(int*)(program->dynamicStrings) = 0; *(short*)(program->dynamicStrings + 4) = 0x8000; *(short*)(program->dynamicStrings + 6) = 1; } - program->dynamicStrings = internal_realloc_safe(program->dynamicStrings, *(int*)(program->dynamicStrings) + 8 + 4 + v27, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 640 + program->dynamicStrings = (unsigned char*)internal_realloc_safe(program->dynamicStrings, *(int*)(program->dynamicStrings) + 8 + 4 + v27, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 640 v20 = program->dynamicStrings + *(int*)(program->dynamicStrings) + 4; if ((*(short*)v20 & 0xFFFF) != 0x8000) { @@ -1498,20 +1498,20 @@ void opAdd(Program* program) case VALUE_TYPE_STRING: case VALUE_TYPE_DYNAMIC_STRING: t = programGetString(program, opcodes[0], values[0]); - str_ptr[0] = internal_malloc_safe(strlen(t) + 1, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1002 + str_ptr[0] = (char*)internal_malloc_safe(strlen(t) + 1, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1002 strcpy(str_ptr[0], t); break; case VALUE_TYPE_FLOAT: - str_ptr[0] = internal_malloc_safe(80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1011 + str_ptr[0] = (char*)internal_malloc_safe(80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1011 sprintf(str_ptr[0], "%.5f", floats[0]); break; case VALUE_TYPE_INT: - str_ptr[0] = internal_malloc_safe(80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1007 + str_ptr[0] = (char*)internal_malloc_safe(80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1007 sprintf(str_ptr[0], "%d", values[0]); break; } - t = internal_malloc_safe(strlen(str_ptr[1]) + strlen(str_ptr[0]) + 1, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1015 + t = (char*)internal_malloc_safe(strlen(str_ptr[1]) + strlen(str_ptr[0]) + 1, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1015 strcpy(t, str_ptr[1]); strcat(t, str_ptr[0]); @@ -1526,7 +1526,7 @@ void opAdd(Program* program) case VALUE_TYPE_STRING: case VALUE_TYPE_DYNAMIC_STRING: str_ptr[0] = programGetString(program, opcodes[0], values[0]); - t = internal_malloc_safe(strlen(str_ptr[0]) + 80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1039 + t = (char*)internal_malloc_safe(strlen(str_ptr[0]) + 80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1039 sprintf(t, "%.5f", floats[1]); strcat(t, str_ptr[0]); @@ -1552,7 +1552,7 @@ void opAdd(Program* program) case VALUE_TYPE_STRING: case VALUE_TYPE_DYNAMIC_STRING: str_ptr[0] = programGetString(program, opcodes[0], values[0]); - t = internal_malloc_safe(strlen(str_ptr[0]) + 80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1070 + t = (char*)internal_malloc_safe(strlen(str_ptr[0]) + 80, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 1070 sprintf(t, "%d", values[1]); strcat(t, str_ptr[0]); @@ -3412,7 +3412,7 @@ void programListNodeCreate(Program* program) { program->flags |= PROGRAM_FLAG_0x02; - ProgramListNode* programListNode = internal_malloc_safe(sizeof(*programListNode), __FILE__, __LINE__); // .\\int\\INTRPRET.C, 2907 + ProgramListNode* programListNode = (ProgramListNode*)internal_malloc_safe(sizeof(*programListNode), __FILE__, __LINE__); // .\\int\\INTRPRET.C, 2907 programListNode->program = program; programListNode->next = gInterpreterProgramListHead; programListNode->prev = NULL; diff --git a/src/interpreter_extra.c b/src/interpreter_extra.cc similarity index 100% rename from src/interpreter_extra.c rename to src/interpreter_extra.cc diff --git a/src/interpreter_lib.c b/src/interpreter_lib.cc similarity index 99% rename from src/interpreter_lib.c rename to src/interpreter_lib.cc index 9210eeb..0cc94b7 100644 --- a/src/interpreter_lib.c +++ b/src/interpreter_lib.cc @@ -1523,9 +1523,9 @@ void _interpretRegisterProgramDeleteCallback(OFF_59E160 fn) if (index == _numCallbacks) { if (_callbacks != NULL) { - _callbacks = internal_realloc_safe(_callbacks, sizeof(*_callbacks) * (_numCallbacks + 1), __FILE__, __LINE__); // ..\\int\\INTLIB.C, 2110 + _callbacks = (OFF_59E160*)internal_realloc_safe(_callbacks, sizeof(*_callbacks) * (_numCallbacks + 1), __FILE__, __LINE__); // ..\\int\\INTLIB.C, 2110 } else { - _callbacks = internal_malloc_safe(sizeof(*_callbacks), __FILE__, __LINE__); // ..\\int\\INTLIB.C, 2112 + _callbacks = (OFF_59E160*)internal_malloc_safe(sizeof(*_callbacks), __FILE__, __LINE__); // ..\\int\\INTLIB.C, 2112 } _numCallbacks++; } diff --git a/src/inventory.c b/src/inventory.cc similarity index 100% rename from src/inventory.c rename to src/inventory.cc diff --git a/src/item.c b/src/item.cc similarity index 98% rename from src/item.c rename to src/item.cc index d51c148..5545fcc 100644 --- a/src/item.c +++ b/src/item.cc @@ -241,7 +241,7 @@ int itemAdd(Object* owner, Object* itemToAdd, int quantity) if (index == inventory->length) { if (inventory->length == inventory->capacity || inventory->items == NULL) { - InventoryItem* inventoryItems = internal_realloc(inventory->items, sizeof(InventoryItem) * (inventory->capacity + 10)); + InventoryItem* inventoryItems = (InventoryItem*)internal_realloc(inventory->items, sizeof(InventoryItem) * (inventory->capacity + 10)); if (inventoryItems == NULL) { return -1; } @@ -2548,7 +2548,7 @@ int _insert_drug_effect(Object* critter, Object* item, int a3, int* stats, int* return -1; } - DrugEffectEvent* drugEffectEvent = internal_malloc(sizeof(*drugEffectEvent)); + DrugEffectEvent* drugEffectEvent = (DrugEffectEvent*)internal_malloc(sizeof(*drugEffectEvent)); if (drugEffectEvent == NULL) { return -1; } @@ -2701,7 +2701,7 @@ bool _drug_effect_allowed(Object* critter, int pid) // TODO: Probably right, but let's check it once. int count = 0; - DrugEffectEvent* drugEffectEvent = queueFindFirstEvent(critter, EVENT_TYPE_DRUG); + DrugEffectEvent* drugEffectEvent = (DrugEffectEvent*)queueFindFirstEvent(critter, EVENT_TYPE_DRUG); while (drugEffectEvent != NULL) { if (drugEffectEvent->drugPid == pid) { count++; @@ -2709,7 +2709,7 @@ bool _drug_effect_allowed(Object* critter, int pid) return false; } } - drugEffectEvent = queueFindNextEvent(critter, EVENT_TYPE_DRUG); + drugEffectEvent = (DrugEffectEvent*)queueFindNextEvent(critter, EVENT_TYPE_DRUG); } return true; @@ -2805,7 +2805,7 @@ int _item_d_clear(Object* obj, void* data) // 0x47A198 int drugEffectEventProcess(Object* obj, void* data) { - DrugEffectEvent* drugEffectEvent = data; + DrugEffectEvent* drugEffectEvent = (DrugEffectEvent*)data; if (obj == NULL) { return 0; @@ -2827,7 +2827,7 @@ int drugEffectEventProcess(Object* obj, void* data) // 0x47A1D0 int drugEffectEventRead(File* stream, void** dataPtr) { - DrugEffectEvent* drugEffectEvent = internal_malloc(sizeof(*drugEffectEvent)); + DrugEffectEvent* drugEffectEvent = (DrugEffectEvent*)internal_malloc(sizeof(*drugEffectEvent)); if (drugEffectEvent == NULL) { return -1; } @@ -2847,7 +2847,7 @@ err: // 0x47A254 int drugEffectEventWrite(File* stream, void* data) { - DrugEffectEvent* drugEffectEvent = data; + DrugEffectEvent* drugEffectEvent = (DrugEffectEvent*)data; if (fileWriteInt32List(stream, drugEffectEvent->stats, 3) == -1) return -1; if (fileWriteInt32List(stream, drugEffectEvent->modifiers, 3) == -1) return -1; @@ -2858,7 +2858,7 @@ int drugEffectEventWrite(File* stream, void* data) // 0x47A290 int _insert_withdrawal(Object* obj, int a2, int duration, int perk, int pid) { - WithdrawalEvent* withdrawalEvent = internal_malloc(sizeof(*withdrawalEvent)); + WithdrawalEvent* withdrawalEvent = (WithdrawalEvent*)internal_malloc(sizeof(*withdrawalEvent)); if (withdrawalEvent == NULL) { return -1; } @@ -2878,7 +2878,7 @@ int _insert_withdrawal(Object* obj, int a2, int duration, int perk, int pid) // 0x47A2FC int _item_wd_clear(Object* obj, void* data) { - WithdrawalEvent* withdrawalEvent = data; + WithdrawalEvent* withdrawalEvent = (WithdrawalEvent*)data; if (objectIsPartyMember(obj)) { return 0; @@ -2894,7 +2894,7 @@ int _item_wd_clear(Object* obj, void* data) // 0x47A324 int _item_wd_clear_all(Object* a1, void* data) { - WithdrawalEvent* withdrawalEvent = data; + WithdrawalEvent* withdrawalEvent = (WithdrawalEvent*)data; if (a1 != _wd_obj) { return 0; @@ -2918,7 +2918,7 @@ int _item_wd_clear_all(Object* a1, void* data) // 0x47A384 int withdrawalEventProcess(Object* obj, void* data) { - WithdrawalEvent* withdrawalEvent = data; + WithdrawalEvent* withdrawalEvent = (WithdrawalEvent*)data; if (withdrawalEvent->field_0) { performWithdrawalStart(obj, withdrawalEvent->perk, withdrawalEvent->pid); @@ -2946,7 +2946,7 @@ int withdrawalEventProcess(Object* obj, void* data) // 0x47A404 int withdrawalEventRead(File* stream, void** dataPtr) { - WithdrawalEvent* withdrawalEvent = internal_malloc(sizeof(*withdrawalEvent)); + WithdrawalEvent* withdrawalEvent = (WithdrawalEvent*)internal_malloc(sizeof(*withdrawalEvent)); if (withdrawalEvent == NULL) { return -1; } @@ -2967,7 +2967,7 @@ err: // 0x47A484 int withdrawalEventWrite(File* stream, void* data) { - WithdrawalEvent* withdrawalEvent = data; + WithdrawalEvent* withdrawalEvent = (WithdrawalEvent*)data; if (fileWriteInt32(stream, withdrawalEvent->field_0) == -1) return -1; if (fileWriteInt32(stream, withdrawalEvent->pid) == -1) return -1; diff --git a/src/light.c b/src/light.cc similarity index 100% rename from src/light.c rename to src/light.cc diff --git a/src/lips.c b/src/lips.cc similarity index 98% rename from src/lips.c rename to src/lips.cc index c4fd516..fa8b2a0 100644 --- a/src/lips.c +++ b/src/lips.cc @@ -292,7 +292,7 @@ int lipsLoad(const char* audioFileName, const char* headFileName) } } - gLipsData.phonemes = internal_malloc(gLipsData.field_24); + gLipsData.phonemes = (unsigned char*)internal_malloc(gLipsData.field_24); if (gLipsData.phonemes == NULL) { debugPrint("Out of memory in lips_load_file.'\n"); return -1; @@ -314,7 +314,7 @@ int lipsLoad(const char* audioFileName, const char* headFileName) } } - gLipsData.markers = internal_malloc(sizeof(*speech_marker) * gLipsData.field_2C); + gLipsData.markers = (SpeechMarker*)internal_malloc(sizeof(*speech_marker) * gLipsData.field_2C); if (gLipsData.markers == NULL) { debugPrint("Out of memory in lips_load_file.'\n"); return -1; diff --git a/src/loadsave.c b/src/loadsave.cc similarity index 99% rename from src/loadsave.c rename to src/loadsave.cc index edf34a8..052b7ed 100644 --- a/src/loadsave.c +++ b/src/loadsave.cc @@ -602,7 +602,7 @@ int lsgSaveGame(int mode) // 0x47C5B4 int _QuickSnapShot() { - _snapshot = internal_malloc(LS_PREVIEW_SIZE); + _snapshot = (unsigned char*)internal_malloc(LS_PREVIEW_SIZE); if (_snapshot == NULL) { return -1; } @@ -1052,7 +1052,7 @@ int lsgWindowInit(int windowType) return -1; } - _snapshot = internal_malloc(61632); + _snapshot = (unsigned char*)internal_malloc(61632); if (_snapshot == NULL) { messageListFree(&gLoadSaveMessageList); fontSetCurrent(gLoadSaveWindowOldFont); diff --git a/src/main.c b/src/main.cc similarity index 100% rename from src/main.c rename to src/main.cc diff --git a/src/map.c b/src/map.cc similarity index 98% rename from src/map.c rename to src/map.cc index bf9732e..c829cad 100644 --- a/src/map.c +++ b/src/map.cc @@ -418,7 +418,7 @@ int _map_malloc_local_var(int a1) int oldMapLocalVarsLength = gMapLocalVarsLength; gMapLocalVarsLength += a1; - int* vars = internal_realloc(gMapLocalVars, sizeof(*vars) * gMapLocalVarsLength); + int* vars = (int*)internal_realloc(gMapLocalVars, sizeof(*vars) * gMapLocalVarsLength); if (vars == NULL) { debugPrint("\nError: Ran out of memory!"); } @@ -813,7 +813,7 @@ int mapLoad(File* stream) mapGlobalVariablesFree(); if (gMapHeader.globalVariablesCount != 0) { - gMapGlobalVars = internal_malloc(sizeof(*gMapGlobalVars) * gMapHeader.globalVariablesCount); + gMapGlobalVars = (int*)internal_malloc(sizeof(*gMapGlobalVars) * gMapHeader.globalVariablesCount); if (gMapGlobalVars == NULL) { goto err; } @@ -829,7 +829,7 @@ int mapLoad(File* stream) mapLocalVariablesFree(); if (gMapHeader.localVariablesCount != 0) { - gMapLocalVars = internal_malloc(sizeof(*gMapLocalVars) * gMapHeader.localVariablesCount); + gMapLocalVars = (int*)internal_malloc(sizeof(*gMapLocalVars) * gMapHeader.localVariablesCount); if (gMapLocalVars == NULL) { goto err; } @@ -1076,7 +1076,7 @@ int _map_age_dead_critters() int capacity = 100; int count = 0; - Object** objects = internal_malloc(sizeof(*objects) * capacity); + Object** objects = (Object**)internal_malloc(sizeof(*objects) * capacity); obj = objectFindFirst(); while (obj != NULL) { @@ -1088,7 +1088,7 @@ int _map_age_dead_critters() if (count >= capacity) { capacity *= 2; - objects = internal_realloc(objects, sizeof(*objects) * capacity); + objects = (Object**)internal_realloc(objects, sizeof(*objects) * capacity); if (objects == NULL) { debugPrint("\nError: Out of Memory!"); return -1; @@ -1100,7 +1100,7 @@ int _map_age_dead_critters() objects[count++] = obj; if (count >= capacity) { capacity *= 2; - objects = internal_realloc(objects, sizeof(*objects) * capacity); + objects = (Object**)internal_realloc(objects, sizeof(*objects) * capacity); if (objects == NULL) { debugPrint("\nError: Out of Memory!"); return -1; diff --git a/src/memory.c b/src/memory.cc similarity index 96% rename from src/memory.c rename to src/memory.cc index 9673eb3..cefcd5a 100644 --- a/src/memory.c +++ b/src/memory.cc @@ -32,7 +32,7 @@ char* internal_strdup(const char* string) { char* copy = NULL; if (string != NULL) { - copy = gMallocProc(strlen(string) + 1); + copy = (char*)gMallocProc(strlen(string) + 1); strcpy(copy, string); } return copy; @@ -52,7 +52,7 @@ void* memoryBlockMallocImpl(size_t size) if (size != 0) { size += sizeof(MemoryBlockHeader) + sizeof(MemoryBlockFooter); - unsigned char* block = malloc(size); + unsigned char* block = (unsigned char*)malloc(size); if (block != NULL) { MemoryBlockHeader* header = (MemoryBlockHeader*)block; header->size = size; @@ -101,7 +101,7 @@ void* memoryBlockReallocImpl(void* ptr, size_t size) size += sizeof(MemoryBlockHeader) + sizeof(MemoryBlockFooter); } - unsigned char* newBlock = realloc(block, size); + unsigned char* newBlock = (unsigned char*)realloc(block, size); if (newBlock != NULL) { MemoryBlockHeader* newHeader = (MemoryBlockHeader*)newBlock; newHeader->size = size; diff --git a/src/memory_manager.c b/src/memory_manager.cc similarity index 98% rename from src/memory_manager.c rename to src/memory_manager.cc index 710ff21..1abf8df 100644 --- a/src/memory_manager.c +++ b/src/memory_manager.cc @@ -126,7 +126,7 @@ void* internal_calloc_safe(int count, int size, const char* file, int line) char* strdup_safe(const char* string, const char* file, int line) { size_t size = strlen(string) + 1; - char* copy = gMemoryManagerMallocProc(size); + char* copy = (char*)gMemoryManagerMallocProc(size); if (copy == NULL) { memoryManagerFatalAllocationError("strdup", size, file, line); } diff --git a/src/message.c b/src/message.cc similarity index 96% rename from src/message.c rename to src/message.cc index f842472..c0f6260 100644 --- a/src/message.c +++ b/src/message.cc @@ -50,13 +50,13 @@ int badwordsInit() gBadwordsCount++; } - gBadwords = internal_malloc(sizeof(*gBadwords) * gBadwordsCount); + gBadwords = (char**)internal_malloc(sizeof(*gBadwords) * gBadwordsCount); if (gBadwords == NULL) { fileClose(stream); return -1; } - gBadwordsLengths = internal_malloc(sizeof(*gBadwordsLengths) * gBadwordsCount); + gBadwordsLengths = (int*)internal_malloc(sizeof(*gBadwordsLengths) * gBadwordsCount); if (gBadwordsLengths == NULL) { internal_free(gBadwords); fileClose(stream); @@ -353,7 +353,7 @@ bool _message_add(MessageList* msg, MessageListItem* new_entry) } } else { if (msg->entries != NULL) { - entries = internal_realloc(msg->entries, sizeof(MessageListItem) * (msg->entries_num + 1)); + entries = (MessageListItem*)internal_realloc(msg->entries, sizeof(MessageListItem) * (msg->entries_num + 1)); if (entries == NULL) { return false; } @@ -365,7 +365,7 @@ bool _message_add(MessageList* msg, MessageListItem* new_entry) memmove(&(msg->entries[index + 1]), &(msg->entries[index]), sizeof(MessageListItem) * (msg->entries_num - index)); } } else { - msg->entries = internal_malloc(sizeof(MessageListItem)); + msg->entries = (MessageListItem*)internal_malloc(sizeof(MessageListItem)); if (msg->entries == NULL) { return false; } diff --git a/src/mmx.c b/src/mmx.cc similarity index 100% rename from src/mmx.c rename to src/mmx.cc diff --git a/src/mouse_manager.c b/src/mouse_manager.cc similarity index 100% rename from src/mouse_manager.c rename to src/mouse_manager.cc diff --git a/src/movie.c b/src/movie.cc similarity index 98% rename from src/movie.c rename to src/movie.cc index 0bc7155..2cb3990 100644 --- a/src/movie.c +++ b/src/movie.cc @@ -88,7 +88,7 @@ int _lastMovieY; MovieSubtitleListNode* gMovieSubtitleHead; // 0x638E78 -MovieExtendedFlags gMovieFlags; +unsigned int gMovieFlags; // 0x638E7C int _movieAlphaFlag; @@ -361,7 +361,7 @@ void _cleanupMovie(int a1) DDSURFACEDESC ddsd; ddsd.dwSize = sizeof(DDSURFACEDESC); if (IDirectDrawSurface_Lock(gMovieDirectDrawSurface, 0, &ddsd, 1, NULL) == DD_OK) { - _lastMovieBuffer = internal_malloc_safe(_lastMovieBH * _lastMovieBW, __FILE__, __LINE__); // "..\\int\\MOVIE.C", 802 + _lastMovieBuffer = (unsigned char*)internal_malloc_safe(_lastMovieBH * _lastMovieBW, __FILE__, __LINE__); // "..\\int\\MOVIE.C", 802 blitBufferToBuffer((unsigned char*)ddsd.lpSurface + ddsd.lPitch * _lastMovieSX + _lastMovieSY, _lastMovieBW, _lastMovieBH, ddsd.lPitch, _lastMovieBuffer, _lastMovieBW); IDirectDrawSurface_Unlock(gMovieDirectDrawSurface, ddsd.lpSurface); } else { @@ -543,7 +543,7 @@ void movieLoadSubtitles(char* filePath) break; } - MovieSubtitleListNode* subtitle = internal_malloc_safe(sizeof(*subtitle), __FILE__, __LINE__); // "..\\int\\MOVIE.C", 1050 + MovieSubtitleListNode* subtitle = (MovieSubtitleListNode*)internal_malloc_safe(sizeof(*subtitle), __FILE__, __LINE__); // "..\\int\\MOVIE.C", 1050 subtitle->next = NULL; subtitleCount++; diff --git a/src/movie.h b/src/movie.h index 39661ea..de0fa15 100644 --- a/src/movie.h +++ b/src/movie.h @@ -54,7 +54,7 @@ extern int _lastMovieW; extern int _lastMovieX; extern int _lastMovieY; extern MovieSubtitleListNode* gMovieSubtitleHead; -extern MovieExtendedFlags gMovieFlags; +extern unsigned int gMovieFlags; extern int _movieAlphaFlag; extern bool _movieSubRectFlag; extern int _movieH; diff --git a/src/movie_effect.c b/src/movie_effect.cc similarity index 97% rename from src/movie_effect.c rename to src/movie_effect.cc index 236dce7..b041bd7 100644 --- a/src/movie_effect.c +++ b/src/movie_effect.cc @@ -111,7 +111,7 @@ int movieEffectsLoad(const char* filePath) goto out; } - int* movieEffectFrameList = internal_malloc(sizeof(*movieEffectFrameList) * movieEffectsLength); + int* movieEffectFrameList = (int*)internal_malloc(sizeof(*movieEffectFrameList) * movieEffectsLength); if (movieEffectFrameList == NULL) { goto out; } @@ -155,7 +155,7 @@ int movieEffectsLoad(const char* filePath) continue; } - MovieEffect* movieEffect = internal_malloc(sizeof(*movieEffect)); + MovieEffect* movieEffect = (MovieEffect*)internal_malloc(sizeof(*movieEffect)); if (movieEffect == NULL) { continue; } diff --git a/src/movie_lib.c b/src/movie_lib.cc similarity index 99% rename from src/movie_lib.c rename to src/movie_lib.cc index 5d7d028..573cb99 100644 --- a/src/movie_lib.c +++ b/src/movie_lib.cc @@ -620,7 +620,7 @@ int _ioReset(int stream) _io_handle = stream; - mve = _ioRead(sizeof(Mve)); + mve = (Mve*)_ioRead(sizeof(Mve)); if (mve == NULL) { return 0; } diff --git a/src/nevs.c b/src/nevs.cc similarity index 97% rename from src/nevs.c rename to src/nevs.cc index 99716dc..99d7307 100644 --- a/src/nevs.c +++ b/src/nevs.cc @@ -64,7 +64,7 @@ void _nevs_initonce() // _interpretRegisterProgramDeleteCallback(_nevs_removeprogramreferences); if (_nevs == NULL) { - _nevs = internal_calloc_safe(sizeof(Nevs), NEVS_COUNT, __FILE__, __LINE__); // "..\\int\\NEVS.C", 131 + _nevs = (Nevs*)internal_calloc_safe(sizeof(Nevs), NEVS_COUNT, __FILE__, __LINE__); // "..\\int\\NEVS.C", 131 if (_nevs == NULL) { debugPrint("nevs_initonce(): out of memory"); exit(99); diff --git a/src/object.c b/src/object.cc similarity index 99% rename from src/object.c rename to src/object.cc index 1fce849..f0b5d5e 100644 --- a/src/object.c +++ b/src/object.cc @@ -463,7 +463,7 @@ int objectLoadAllInternal(File* stream) } if (objectCount != 0) { - gObjectFids = internal_malloc(sizeof(*gObjectFids) * objectCount); + gObjectFids = (int*)internal_malloc(sizeof(*gObjectFids) * objectCount); memset(gObjectFids, 0, sizeof(*gObjectFids) * objectCount); if (gObjectFids == NULL) { return -1; @@ -526,7 +526,7 @@ int objectLoadAllInternal(File* stream) Inventory* inventory = &(objectListNode->obj->data.inventory); if (inventory->length != 0) { - inventory->items = internal_malloc(sizeof(InventoryItem) * inventory->capacity); + inventory->items = (InventoryItem*)internal_malloc(sizeof(InventoryItem) * inventory->capacity); if (inventory->items == NULL) { return -1; } @@ -539,7 +539,7 @@ int objectLoadAllInternal(File* stream) } if (fixMapInventory) { - inventoryItem->item = internal_malloc(sizeof(Object)); + inventoryItem->item = (Object*)internal_malloc(sizeof(Object)); if (inventoryItem->item == NULL) { debugPrint("Error loading inventory\n"); return -1; @@ -2686,7 +2686,7 @@ int objectListCreate(int tile, int elevation, int objectType, Object*** objectLi return 0; } - Object** objects = *objectListPtr = internal_malloc(sizeof(*objects) * count); + Object** objects = *objectListPtr = (Object**)internal_malloc(sizeof(*objects) * count); if (objects == NULL) { return -1; } @@ -3018,7 +3018,7 @@ int _obj_create_intersect_list(int x, int y, int elevation, int objectType, Obje && object != gEgg) { int flags = _obj_intersects_with(object, x, y); if (flags != 0) { - ObjectWithFlags* entries = internal_realloc(*entriesPtr, sizeof(*entries) * (count + 1)); + ObjectWithFlags* entries = (ObjectWithFlags*)internal_realloc(*entriesPtr, sizeof(*entries) * (count + 1)); if (entries != NULL) { *entriesPtr = entries; entries[count].object = object; @@ -3235,12 +3235,12 @@ int _obj_offset_table_init() return -1; } - _offsetTable[0] = internal_malloc(sizeof(int) * _updateHexArea); + _offsetTable[0] = (int*)internal_malloc(sizeof(int) * _updateHexArea); if (_offsetTable[0] == NULL) { goto err; } - _offsetTable[1] = internal_malloc(sizeof(int) * _updateHexArea); + _offsetTable[1] = (int*)internal_malloc(sizeof(int) * _updateHexArea); if (_offsetTable[1] == NULL) { goto err; } @@ -3283,7 +3283,7 @@ int _obj_offset_table_init() } } - _offsetDivTable = internal_malloc(sizeof(int) * _updateHexArea); + _offsetDivTable = (int*)internal_malloc(sizeof(int) * _updateHexArea); if (_offsetDivTable == NULL) { goto err; } @@ -3292,7 +3292,7 @@ int _obj_offset_table_init() _offsetDivTable[i] = i / _updateHexWidth; } - _offsetModTable = internal_malloc(sizeof(int) * _updateHexArea); + _offsetModTable = (int*)internal_malloc(sizeof(int) * _updateHexArea); if (_offsetModTable == NULL) { goto err; } @@ -3340,12 +3340,12 @@ int _obj_order_table_init() return -1; } - _orderTable[0] = internal_malloc(sizeof(int) * _updateHexArea); + _orderTable[0] = (int*)internal_malloc(sizeof(int) * _updateHexArea); if (_orderTable[0] == NULL) { goto err; } - _orderTable[1] = internal_malloc(sizeof(int) * _updateHexArea); + _orderTable[1] = (int*)internal_malloc(sizeof(int) * _updateHexArea); if (_orderTable[1] == NULL) { goto err; } @@ -3407,7 +3407,7 @@ int _obj_render_table_init() return -1; } - _renderTable = internal_malloc(sizeof(*_renderTable) * _updateHexArea); + _renderTable = (ObjectListNode**)internal_malloc(sizeof(*_renderTable) * _updateHexArea); if (_renderTable == NULL) { return -1; } @@ -3582,7 +3582,7 @@ int _obj_load_obj(File* stream, Object** objectPtr, int elevation, Object* owner return 0; } - InventoryItem* inventoryItems = inventory->items = internal_malloc(sizeof(*inventoryItems) * inventory->capacity); + InventoryItem* inventoryItems = inventory->items = (InventoryItem*)internal_malloc(sizeof(*inventoryItems) * inventory->capacity); if (inventoryItems == NULL) { return -1; } @@ -3708,7 +3708,7 @@ int objectAllocate(Object** objectPtr) return -1; } - Object* object = *objectPtr = internal_malloc(sizeof(Object)); + Object* object = *objectPtr = (Object*)internal_malloc(sizeof(Object)); if (object == NULL) { return -1; } @@ -3754,7 +3754,7 @@ int objectListNodeCreate(ObjectListNode** nodePtr) return -1; } - ObjectListNode* node = *nodePtr = internal_malloc(sizeof(*node)); + ObjectListNode* node = *nodePtr = (ObjectListNode*)internal_malloc(sizeof(*node)); if (node == NULL) { return -1; } diff --git a/src/options.c b/src/options.cc similarity index 99% rename from src/options.c rename to src/options.cc index bf5a104..eb9f16d 100644 --- a/src/options.c +++ b/src/options.cc @@ -476,7 +476,7 @@ int optionsWindowInit() int cycle = 0; for (int index = 0; index < OPTIONS_WINDOW_BUTTONS_COUNT; index++) { - _opbtns[index] = internal_malloc(gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width * gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height + 1024); + _opbtns[index] = (unsigned char*)internal_malloc(gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width * gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height + 1024); if (_opbtns[index] == NULL) { while (--index >= 0) { internal_free(_opbtns[index]); diff --git a/src/palette.c b/src/palette.cc similarity index 100% rename from src/palette.c rename to src/palette.cc diff --git a/src/party_member.c b/src/party_member.cc similarity index 97% rename from src/party_member.c rename to src/party_member.cc index 3f68e77..532b414 100644 --- a/src/party_member.c +++ b/src/party_member.cc @@ -89,28 +89,28 @@ int partyMembersInit() sprintf(section, "Party Member %d", gPartyMemberDescriptionsLength); } - gPartyMemberPids = internal_malloc(sizeof(*gPartyMemberPids) * gPartyMemberDescriptionsLength); + gPartyMemberPids = (int*)internal_malloc(sizeof(*gPartyMemberPids) * gPartyMemberDescriptionsLength); if (gPartyMemberPids == NULL) { goto err; } memset(gPartyMemberPids, 0, sizeof(*gPartyMemberPids) * gPartyMemberDescriptionsLength); - gPartyMembers = internal_malloc(sizeof(*gPartyMembers) * (gPartyMemberDescriptionsLength + 20)); + gPartyMembers = (STRUCT_519DA8*)internal_malloc(sizeof(*gPartyMembers) * (gPartyMemberDescriptionsLength + 20)); if (gPartyMembers == NULL) { goto err; } memset(gPartyMembers, 0, sizeof(*gPartyMembers) * (gPartyMemberDescriptionsLength + 20)); - gPartyMemberDescriptions = internal_malloc(sizeof(*gPartyMemberDescriptions) * gPartyMemberDescriptionsLength); + gPartyMemberDescriptions = (PartyMemberDescription*)internal_malloc(sizeof(*gPartyMemberDescriptions) * gPartyMemberDescriptionsLength); if (gPartyMemberDescriptions == NULL) { goto err; } memset(gPartyMemberDescriptions, 0, sizeof(*gPartyMemberDescriptions) * gPartyMemberDescriptionsLength); - _partyMemberLevelUpInfoList = internal_malloc(sizeof(*_partyMemberLevelUpInfoList) * gPartyMemberDescriptionsLength); + _partyMemberLevelUpInfoList = (STRU_519DBC*)internal_malloc(sizeof(*_partyMemberLevelUpInfoList) * gPartyMemberDescriptionsLength); if (_partyMemberLevelUpInfoList == NULL) goto err; memset(_partyMemberLevelUpInfoList, 0, sizeof(*_partyMemberLevelUpInfoList) * gPartyMemberDescriptionsLength); @@ -530,7 +530,7 @@ int _partyMemberPrepLoadInstance(STRUCT_519DA8* a1) return 0; } - a1->script = internal_malloc(sizeof(*script)); + a1->script = (Script*)internal_malloc(sizeof(*script)); if (a1->script == NULL) { showMesageBox("\n Error!: partyMemberPrepLoad: Out of memory!"); exit(1); @@ -539,7 +539,7 @@ int _partyMemberPrepLoadInstance(STRUCT_519DA8* a1) memcpy(a1->script, script, sizeof(*script)); if (script->localVarsCount != 0 && script->localVarsOffset != -1) { - a1->vars = internal_malloc(sizeof(*a1->vars) * script->localVarsCount); + a1->vars = (int*)internal_malloc(sizeof(*a1->vars) * script->localVarsCount); if (a1->vars == NULL) { showMesageBox("\n Error!: partyMemberPrepLoad: Out of memory!"); exit(1); @@ -658,7 +658,7 @@ int _partyMemberRecoverLoadInstance(STRUCT_519DA8* a1) // 0x494BBC int partyMembersLoad(File* stream) { - int* partyMemberObjectIds = internal_malloc(sizeof(*partyMemberObjectIds) * (gPartyMemberDescriptionsLength + 20)); + int* partyMemberObjectIds = (int*)internal_malloc(sizeof(*partyMemberObjectIds) * (gPartyMemberDescriptionsLength + 20)); if (partyMemberObjectIds == NULL) { return -1; } @@ -971,7 +971,7 @@ int _partyMemberItemSave(Object* object) object->id = script->field_1C; } - STRUCT_519DA8* node = internal_malloc(sizeof(*node)); + STRUCT_519DA8* node = (STRUCT_519DA8*)internal_malloc(sizeof(*node)); if (node == NULL) { showMesageBox("\n Error!: partyMemberItemSave: Out of memory!"); exit(1); @@ -979,7 +979,7 @@ int _partyMemberItemSave(Object* object) node->object = object; - node->script = internal_malloc(sizeof(*script)); + node->script = (Script*)internal_malloc(sizeof(*script)); if (node->script == NULL) { showMesageBox("\n Error!: partyMemberItemSave: Out of memory!"); exit(1); @@ -988,7 +988,7 @@ int _partyMemberItemSave(Object* object) memcpy(node->script, script, sizeof(*script)); if (script->localVarsCount != 0 && script->localVarsOffset != -1) { - node->vars = internal_malloc(sizeof(*node->vars) * script->localVarsCount); + node->vars = (int*)internal_malloc(sizeof(*node->vars) * script->localVarsCount); if (node->vars == NULL) { showMesageBox("\n Error!: partyMemberItemSave: Out of memory!"); exit(1); diff --git a/src/perk.c b/src/perk.cc similarity index 99% rename from src/perk.c rename to src/perk.cc index aa722b2..c50aad4 100644 --- a/src/perk.c +++ b/src/perk.cc @@ -153,7 +153,7 @@ MessageList gPerksMessageList; // 0x4965A0 int perksInit() { - gPartyMemberPerkRanks = internal_malloc(sizeof(*gPartyMemberPerkRanks) * gPartyMemberDescriptionsLength); + gPartyMemberPerkRanks = (PerkRankData*)internal_malloc(sizeof(*gPartyMemberPerkRanks) * gPartyMemberDescriptionsLength); if (gPartyMemberPerkRanks == NULL) { return -1; } diff --git a/src/pipboy.c b/src/pipboy.cc similarity index 99% rename from src/pipboy.c rename to src/pipboy.cc index e7d3738..1dbb0a1 100644 --- a/src/pipboy.c +++ b/src/pipboy.cc @@ -2011,7 +2011,7 @@ int pipboyRenderScreensaver() _gmouse_disable(0); - unsigned char* buf = internal_malloc(412 * 374); + unsigned char* buf = (unsigned char*)internal_malloc(412 * 374); if (buf == NULL) { return -1; } @@ -2242,7 +2242,7 @@ int questInit() entry.completedThreshold = atoi(tok); - QuestDescription* entries = internal_realloc(gQuestDescriptions, sizeof(*gQuestDescriptions) * (gQuestsCount + 1)); + QuestDescription* entries = (QuestDescription*)internal_realloc(gQuestDescriptions, sizeof(*gQuestDescriptions) * (gQuestsCount + 1)); if (entries == NULL) { goto err; } @@ -2338,7 +2338,7 @@ int holodiskInit() entry.description = atoi(tok); - HolodiskDescription* entries = internal_realloc(gHolodiskDescriptions, sizeof(*gHolodiskDescriptions) * (gHolodisksCount + 1)); + HolodiskDescription* entries = (HolodiskDescription*)internal_realloc(gHolodiskDescriptions, sizeof(*gHolodiskDescriptions) * (gHolodisksCount + 1)); if (entries == NULL) { goto err; } diff --git a/src/proto.c b/src/proto.cc similarity index 99% rename from src/proto.c rename to src/proto.cc index e225855..972bf5a 100644 --- a/src/proto.c +++ b/src/proto.cc @@ -1695,7 +1695,7 @@ int _proto_find_free_subnode(int type, Proto** protoPtr) { size_t size = (type >= 0 && type < 11) ? _proto_sizes[type] : 0; - Proto* proto = internal_malloc(size); + Proto* proto = (Proto*)internal_malloc(size); *protoPtr = proto; if (proto == NULL) { return -1; @@ -1706,7 +1706,7 @@ int _proto_find_free_subnode(int type, Proto** protoPtr) if (protoList->head != NULL) { if (protoListExtent->length == PROTO_LIST_EXTENT_SIZE) { - ProtoListExtent* newExtent = protoListExtent->next = internal_malloc(sizeof(ProtoListExtent)); + ProtoListExtent* newExtent = protoListExtent->next = (ProtoListExtent*)internal_malloc(sizeof(ProtoListExtent)); if (protoListExtent == NULL) { internal_free(proto); *protoPtr = NULL; @@ -1722,7 +1722,7 @@ int _proto_find_free_subnode(int type, Proto** protoPtr) protoListExtent = newExtent; } } else { - protoListExtent = internal_malloc(sizeof(ProtoListExtent)); + protoListExtent = (ProtoListExtent*)internal_malloc(sizeof(ProtoListExtent)); if (protoListExtent == NULL) { internal_free(proto); *protoPtr = NULL; diff --git a/src/proto_instance.c b/src/proto_instance.cc similarity index 100% rename from src/proto_instance.c rename to src/proto_instance.cc diff --git a/src/queue.c b/src/queue.cc similarity index 98% rename from src/queue.c rename to src/queue.cc index e027163..0b20890 100644 --- a/src/queue.c +++ b/src/queue.cc @@ -70,7 +70,7 @@ int queueLoad(File* stream) int rc = 0; for (int index = 0; index < count; index += 1) { - QueueListNode* queueListNode = internal_malloc(sizeof(*queueListNode)); + QueueListNode* queueListNode = (QueueListNode*)internal_malloc(sizeof(*queueListNode)); if (queueListNode == NULL) { rc = -1; break; @@ -219,7 +219,7 @@ int queueSave(File* stream) // 0x4A258C int queueAddEvent(int delay, Object* obj, void* data, int eventType) { - QueueListNode* newQueueListNode = internal_malloc(sizeof(QueueListNode)); + QueueListNode* newQueueListNode = (QueueListNode*)internal_malloc(sizeof(QueueListNode)); if (newQueueListNode == NULL) { return -1; } diff --git a/src/random.c b/src/random.cc similarity index 100% rename from src/random.c rename to src/random.cc diff --git a/src/reaction.c b/src/reaction.cc similarity index 100% rename from src/reaction.c rename to src/reaction.cc diff --git a/src/region.c b/src/region.cc similarity index 87% rename from src/region.c rename to src/region.cc index e1e789c..9612f04 100644 --- a/src/region.c +++ b/src/region.cc @@ -48,11 +48,11 @@ void _regionSetBound(Region* region) // 0x4A2D78 Region* regionCreate(int initialCapacity) { - Region* region = internal_malloc_safe(sizeof(*region), __FILE__, __LINE__); // "..\int\REGION.C", 142 + Region* region = (Region*)internal_malloc_safe(sizeof(*region), __FILE__, __LINE__); // "..\int\REGION.C", 142 memset(region, 0, sizeof(*region)); if (initialCapacity != 0) { - region->points = internal_malloc_safe(sizeof(*region->points) * (initialCapacity + 1), __FILE__, __LINE__); // "..\int\REGION.C", 147 + region->points = (Point*)internal_malloc_safe(sizeof(*region->points) * (initialCapacity + 1), __FILE__, __LINE__); // "..\int\REGION.C", 147 region->pointsCapacity = initialCapacity + 1; } else { region->points = NULL; @@ -96,13 +96,13 @@ void regionAddPoint(Region* region, int x, int y) if (region->points != NULL) { if (region->pointsCapacity - 1 == region->pointsLength) { - region->points = internal_realloc_safe(region->points, sizeof(*region->points) * (region->pointsCapacity + 1), __FILE__, __LINE__); // "..\int\REGION.C", 190 + region->points = (Point*)internal_realloc_safe(region->points, sizeof(*region->points) * (region->pointsCapacity + 1), __FILE__, __LINE__); // "..\int\REGION.C", 190 region->pointsCapacity++; } } else { region->pointsCapacity = 2; region->pointsLength = 0; - region->points = internal_malloc_safe(sizeof(*region->points) * 2, __FILE__, __LINE__); // "..\int\REGION.C", 185 + region->points = (Point*)internal_malloc_safe(sizeof(*region->points) * 2, __FILE__, __LINE__); // "..\int\REGION.C", 185 } int pointIndex = region->pointsLength; diff --git a/src/scripts.c b/src/scripts.cc similarity index 98% rename from src/scripts.c rename to src/scripts.cc index 617a173..28bf86f 100644 --- a/src/scripts.c +++ b/src/scripts.cc @@ -151,7 +151,7 @@ char* _err_str = _Error_2; char* _blank_str = byte_50D6C0; // 0x664954 -ScriptRequests gScriptsRequests; +unsigned int gScriptsRequests; // 0x664958 STRUCT_664980 stru_664958; @@ -730,14 +730,14 @@ void _scrSetQueueTestVals(Object* a1, int a2) // 0x4A3E3C int _scrQueueRemoveFixed(Object* obj, void* data) { - ScriptEvent* scriptEvent = data; + ScriptEvent* scriptEvent = (ScriptEvent*)data; return obj == _scrQueueTestObj && scriptEvent->field_4 == _scrQueueTestValue; } // 0x4A3E60 int scriptAddTimerEvent(int sid, int delay, int param) { - ScriptEvent* scriptEvent = internal_malloc(sizeof(*scriptEvent)); + ScriptEvent* scriptEvent = (ScriptEvent*)internal_malloc(sizeof(*scriptEvent)); if (scriptEvent == NULL) { return -1; } @@ -762,7 +762,7 @@ int scriptAddTimerEvent(int sid, int delay, int param) // 0x4A3EDC int scriptEventWrite(File* stream, void* data) { - ScriptEvent* scriptEvent = data; + ScriptEvent* scriptEvent = (ScriptEvent*)data; if (fileWriteInt32(stream, scriptEvent->sid) == -1) return -1; if (fileWriteInt32(stream, scriptEvent->field_4) == -1) return -1; @@ -773,7 +773,7 @@ int scriptEventWrite(File* stream, void* data) // 0x4A3F04 int scriptEventRead(File* stream, void** dataPtr) { - ScriptEvent* scriptEvent = internal_malloc(sizeof(*scriptEvent)); + ScriptEvent* scriptEvent = (ScriptEvent*)internal_malloc(sizeof(*scriptEvent)); if (scriptEvent == NULL) { return -1; } @@ -796,7 +796,7 @@ err: // 0x4A3F4C int scriptEventProcess(Object* obj, void* data) { - ScriptEvent* scriptEvent = data; + ScriptEvent* scriptEvent = (ScriptEvent*)data; Script* script; if (scriptGetScript(scriptEvent->sid, &script) == -1) { @@ -1304,7 +1304,7 @@ int scriptsLoadScriptsList() while (fileReadString(string, 260, stream)) { gScriptsListEntriesLength++; - ScriptsListEntry* entries = internal_realloc(gScriptsListEntries, sizeof(*entries) * gScriptsListEntriesLength); + ScriptsListEntry* entries = (ScriptsListEntry*)internal_realloc(gScriptsListEntries, sizeof(*entries) * gScriptsListEntriesLength); if (entries == NULL) { return -1; } @@ -1647,7 +1647,7 @@ int scriptsLoadGameGlobalVars(File* stream) // 0x4A5448 int scriptsSkipGameGlobalVars(File* stream) { - int* vars = internal_malloc(sizeof(*vars) * gGameGlobalVarsLength); + int* vars = (int*)internal_malloc(sizeof(*vars) * gGameGlobalVarsLength); if (vars == NULL) { return -1; } @@ -1945,7 +1945,7 @@ int scriptLoadAll(File* stream) scriptList->length++; } - ScriptListExtent* extent = internal_malloc(sizeof(*extent)); + ScriptListExtent* extent = (ScriptListExtent*)internal_malloc(sizeof(*extent)); scriptList->head = extent; scriptList->tail = extent; if (extent == NULL) { @@ -1969,7 +1969,7 @@ int scriptLoadAll(File* stream) ScriptListExtent* prevExtent = extent; for (int extentIndex = 1; extentIndex < scriptList->length; extentIndex++) { - ScriptListExtent* extent = internal_malloc(sizeof(*extent)); + ScriptListExtent* extent = (ScriptListExtent*)internal_malloc(sizeof(*extent)); if (extent == NULL) { return -1; } @@ -2061,7 +2061,7 @@ int scriptAdd(int* sidPtr, int scriptType) if (scriptList->head != NULL) { // There is at least one extent available, which means tail is also set. if (scriptListExtent->length == SCRIPT_LIST_EXTENT_SIZE) { - ScriptListExtent* newExtent = scriptListExtent->next = internal_malloc(sizeof(*newExtent)); + ScriptListExtent* newExtent = scriptListExtent->next = (ScriptListExtent*)internal_malloc(sizeof(*newExtent)); if (newExtent == NULL) { return -1; } @@ -2076,7 +2076,7 @@ int scriptAdd(int* sidPtr, int scriptType) } } else { // Script head - scriptListExtent = internal_malloc(sizeof(ScriptListExtent)); + scriptListExtent = (ScriptListExtent*)internal_malloc(sizeof(ScriptListExtent)); if (scriptListExtent == NULL) { return -1; } @@ -2141,7 +2141,7 @@ int scriptsRemoveLocalVars(Script* script) gMapLocalVars + (script->localVarsOffset + script->localVarsCount), sizeof(*gMapLocalVars) * (oldMapLocalVarsCount - script->localVarsCount - script->localVarsOffset)); - gMapLocalVars = internal_realloc(gMapLocalVars, sizeof(*gMapLocalVars) * gMapLocalVarsLength); + gMapLocalVars = (int*)internal_realloc(gMapLocalVars, sizeof(*gMapLocalVars) * gMapLocalVarsLength); if (gMapLocalVars == NULL) { debugPrint("\nError in mem_realloc in scr_remove_local_vars!\n"); } @@ -2525,7 +2525,7 @@ void scriptsExecMapUpdateScripts(int proc) return; } - int* sidList = internal_malloc(sizeof(*sidList) * sidListCapacity); + int* sidList = (int*)internal_malloc(sizeof(*sidList) * sidListCapacity); if (sidList == NULL) { debugPrint("\nError: scr_exec_map_update_scripts: Out of memory for sidList!"); return; @@ -2772,7 +2772,7 @@ int _scr_explode_scenery(Object* a1, int tile, int radius, int elevation) return 0; } - int* scriptIds = internal_malloc(sizeof(*scriptIds) * scriptExtentsCount * SCRIPT_LIST_EXTENT_SIZE); + int* scriptIds = (int*)internal_malloc(sizeof(*scriptIds) * scriptExtentsCount * SCRIPT_LIST_EXTENT_SIZE); if (scriptIds == NULL) { return -1; } diff --git a/src/scripts.h b/src/scripts.h index 881636c..0901eb1 100644 --- a/src/scripts.h +++ b/src/scripts.h @@ -200,7 +200,7 @@ extern int _scrQueueTestValue; extern char* _err_str; extern char* _blank_str; -extern ScriptRequests gScriptsRequests; +extern unsigned int gScriptsRequests; extern STRUCT_664980 stru_664958; extern STRUCT_664980 stru_664980; extern int gScriptsRequestedElevatorType; diff --git a/src/select_file_list.c b/src/select_file_list.cc similarity index 100% rename from src/select_file_list.c rename to src/select_file_list.cc diff --git a/src/selfrun.c b/src/selfrun.cc similarity index 100% rename from src/selfrun.c rename to src/selfrun.cc diff --git a/src/skill.c b/src/skill.cc similarity index 100% rename from src/skill.c rename to src/skill.cc diff --git a/src/skilldex.c b/src/skilldex.cc similarity index 98% rename from src/skilldex.c rename to src/skilldex.cc index 6e6660a..711e00b 100644 --- a/src/skilldex.c +++ b/src/skilldex.cc @@ -150,7 +150,7 @@ int skilldexWindowInit() bool cycle = false; int buttonDataIndex; for (buttonDataIndex = 0; buttonDataIndex < SKILLDEX_SKILL_BUTTON_BUFFER_COUNT; buttonDataIndex++) { - gSkilldexButtonsData[buttonDataIndex] = internal_malloc(gSkilldexFrmSizes[SKILLDEX_FRM_BUTTON_ON].height * gSkilldexFrmSizes[SKILLDEX_FRM_BUTTON_ON].width + 512); + gSkilldexButtonsData[buttonDataIndex] = (unsigned char*)internal_malloc(gSkilldexFrmSizes[SKILLDEX_FRM_BUTTON_ON].height * gSkilldexFrmSizes[SKILLDEX_FRM_BUTTON_ON].width + 512); if (gSkilldexButtonsData[buttonDataIndex] == NULL) { break; } diff --git a/src/sound.c b/src/sound.cc similarity index 99% rename from src/sound.c rename to src/sound.cc index 1df2251..356d541 100644 --- a/src/sound.c +++ b/src/sound.cc @@ -517,12 +517,12 @@ Sound* soundAllocate(int a1, int a2) return NULL; } - Sound* sound = gSoundMallocProc(sizeof(*sound)); + Sound* sound = (Sound*)gSoundMallocProc(sizeof(*sound)); memset(sound, 0, sizeof(*sound)); memcpy(&(sound->io), &gSoundDefaultFileIO, sizeof(gSoundDefaultFileIO)); - WAVEFORMATEX* wfxFormat = gSoundMallocProc(sizeof(*wfxFormat)); + WAVEFORMATEX* wfxFormat = (WAVEFORMATEX*)gSoundMallocProc(sizeof(*wfxFormat)); memset(wfxFormat, 0, sizeof(*wfxFormat)); wfxFormat->wFormatTag = 1; diff --git a/src/sound.h b/src/sound.h index 5443636..3e5f781 100644 --- a/src/sound.h +++ b/src/sound.h @@ -52,7 +52,7 @@ typedef int SoundOpenProc(const char* filePath, int flags, ...); typedef int SoundCloseProc(int fileHandle); typedef int SoundReadProc(int fileHandle, void* buf, unsigned int size); typedef int SoundWriteProc(int fileHandle, const void* buf, unsigned int size); -typedef int SoundSeekProc(int fileHandle, long offset, int origin); +typedef long SoundSeekProc(int fileHandle, long offset, int origin); typedef long SoundTellProc(int fileHandle); typedef long SoundFileLengthProc(int fileHandle); diff --git a/src/sound_decoder.c b/src/sound_decoder.cc similarity index 98% rename from src/sound_decoder.c rename to src/sound_decoder.cc index 394c2fa..6bc85b0 100644 --- a/src/sound_decoder.c +++ b/src/sound_decoder.cc @@ -77,7 +77,7 @@ bool soundDecoderPrepare(SoundDecoder* soundDecoder, SoundDecoderReadProc* readP soundDecoder->readProc = readProc; soundDecoder->fd = fileHandle; - soundDecoder->bufferIn = malloc(SOUND_DECODER_IN_BUFFER_SIZE); + soundDecoder->bufferIn = (unsigned char*)malloc(SOUND_DECODER_IN_BUFFER_SIZE); if (soundDecoder->bufferIn == NULL) { return false; } @@ -1100,7 +1100,7 @@ SoundDecoder* soundDecoderInit(SoundDecoderReadProc* readProc, int fileHandle, i int v20; int v73; - SoundDecoder* soundDecoder = malloc(sizeof(*soundDecoder)); + SoundDecoder* soundDecoder = (SoundDecoder*)malloc(sizeof(*soundDecoder)); if (soundDecoder == NULL) { return NULL; } @@ -1172,7 +1172,7 @@ SoundDecoder* soundDecoderInit(SoundDecoderReadProc* readProc, int fileHandle, i soundDecoder->field_3C = soundDecoder->field_38 * soundDecoder->field_24; if (v73 != 0) { - soundDecoder->field_30 = malloc(sizeof(unsigned char*) * v73); + soundDecoder->field_30 = (unsigned char*)malloc(sizeof(unsigned char*) * v73); if (soundDecoder->field_30 == NULL) { goto L66; } @@ -1180,7 +1180,7 @@ SoundDecoder* soundDecoderInit(SoundDecoderReadProc* readProc, int fileHandle, i memset(soundDecoder->field_30, 0, sizeof(unsigned char*) * v73); } - soundDecoder->field_34 = malloc(sizeof(unsigned char*) * soundDecoder->field_2C); + soundDecoder->field_34 = (unsigned char*)malloc(sizeof(unsigned char*) * soundDecoder->field_2C); if (soundDecoder->field_34 == NULL) { goto L66; } @@ -1188,7 +1188,7 @@ SoundDecoder* soundDecoderInit(SoundDecoderReadProc* readProc, int fileHandle, i soundDecoder->field_50 = 0; if (gSoundDecodersCount == 1) { - _AudioDecoder_scale_tbl = malloc(0x20000); + _AudioDecoder_scale_tbl = (unsigned char*)malloc(0x20000); _AudioDecoder_scale0 = _AudioDecoder_scale_tbl + 0x10000; } diff --git a/src/sound_effects_cache.c b/src/sound_effects_cache.cc similarity index 97% rename from src/sound_effects_cache.c rename to src/sound_effects_cache.cc index 20b48d5..abd534d 100644 --- a/src/sound_effects_cache.c +++ b/src/sound_effects_cache.cc @@ -73,7 +73,7 @@ int soundEffectsCacheInit(int cacheSize, const char* effectsPath) return -1; } - gSoundEffectsCache = internal_malloc(sizeof(*gSoundEffectsCache)); + gSoundEffectsCache = (Cache*)internal_malloc(sizeof(*gSoundEffectsCache)); if (gSoundEffectsCache == NULL) { soundEffectsCacheFreeHandles(); soundEffectsListExit(); @@ -235,7 +235,7 @@ int soundEffectsCacheFileWrite(int handle, const void* buf, unsigned int size) } // 0x4A9358 -int soundEffectsCacheFileSeek(int handle, long offset, int origin) +long soundEffectsCacheFileSeek(int handle, long offset, int origin) { if (!soundEffectsIsValidHandle(handle)) { return -1; @@ -349,7 +349,7 @@ void soundEffectsCacheFreeImpl(void* ptr) // 0x4A94D4 int soundEffectsCacheCreateHandles() { - gSoundEffects = internal_malloc(sizeof(*gSoundEffects) * SOUND_EFFECTS_MAX_COUNT); + gSoundEffects = (SoundEffect*)internal_malloc(sizeof(*gSoundEffects) * SOUND_EFFECTS_MAX_COUNT); if (gSoundEffects == NULL) { return -1; } @@ -409,7 +409,7 @@ int soundEffectsCreate(int* handlePtr, int tag, void* data, CacheEntry* cacheHan soundEffect->position = 0; soundEffect->dataPosition = 0; - soundEffect->data = data; + soundEffect->data = (unsigned char*)data; *handlePtr = index; diff --git a/src/sound_effects_cache.h b/src/sound_effects_cache.h index 84d49cc..399624c 100644 --- a/src/sound_effects_cache.h +++ b/src/sound_effects_cache.h @@ -43,7 +43,7 @@ int soundEffectsCacheFileOpen(const char* fname, int mode, ...); int soundEffectsCacheFileClose(int handle); int soundEffectsCacheFileRead(int handle, void* buf, unsigned int size); int soundEffectsCacheFileWrite(int handle, const void* buf, unsigned int size); -int soundEffectsCacheFileSeek(int handle, long offset, int origin); +long soundEffectsCacheFileSeek(int handle, long offset, int origin); long soundEffectsCacheFileTell(int handle); long soundEffectsCacheFileLength(int handle); int soundEffectsCacheGetFileSizeImpl(int tag, int* sizePtr); diff --git a/src/sound_effects_list.c b/src/sound_effects_list.cc similarity index 93% rename from src/sound_effects_list.c rename to src/sound_effects_list.cc index 2cac757..e2962b0 100644 --- a/src/sound_effects_list.c +++ b/src/sound_effects_list.cc @@ -76,7 +76,7 @@ int soundEffectsListInit(const char* soundEffectsPath, int a2, int debugLevel) fileReadString(path, 255, stream); gSoundEffectsListEntriesLength = atoi(path); - gSoundEffectsListEntries = internal_malloc(sizeof(*gSoundEffectsListEntries) * gSoundEffectsListEntriesLength); + gSoundEffectsListEntries = (SoundEffectsListEntry*)internal_malloc(sizeof(*gSoundEffectsListEntries) * gSoundEffectsListEntriesLength); for (int index = 0; index < gSoundEffectsListEntriesLength; index++) { SoundEffectsListEntry* entry = &(gSoundEffectsListEntries[index]); @@ -171,7 +171,7 @@ int soundEffectsListGetTag(char* name, int* tagPtr) SoundEffectsListEntry dummy; dummy.name = name + gSoundEffectsListPathLength; - SoundEffectsListEntry* entry = bsearch(&dummy, gSoundEffectsListEntries, gSoundEffectsListEntriesLength, sizeof(*gSoundEffectsListEntries), soundEffectsListCompareByName); + SoundEffectsListEntry* entry = (SoundEffectsListEntry*)bsearch(&dummy, gSoundEffectsListEntries, gSoundEffectsListEntriesLength, sizeof(*gSoundEffectsListEntries), soundEffectsListCompareByName); if (entry == NULL) { return SFXL_ERR; } @@ -198,7 +198,7 @@ int soundEffectsListGetFilePath(int tag, char** pathPtr) char* name = gSoundEffectsListEntries[index].name; - char* path = internal_malloc(strlen(gSoundEffectsListPath) + strlen(name) + 1); + char* path = (char*)internal_malloc(strlen(gSoundEffectsListPath) + strlen(name) + 1); if (path == NULL) { return SFXL_ERR; } @@ -305,7 +305,7 @@ int soundEffectsListPopulateFileNames() return SFXL_ERR; } - char* pattern = internal_malloc(strlen(gSoundEffectsListPath) + strlen(extension) + 1); + char* pattern = (char*)internal_malloc(strlen(gSoundEffectsListPath) + strlen(extension) + 1); if (pattern == NULL) { return SFXL_ERR; } @@ -326,7 +326,7 @@ int soundEffectsListPopulateFileNames() return SFXL_ERR; } - gSoundEffectsListEntries = internal_malloc(sizeof(*gSoundEffectsListEntries) * gSoundEffectsListEntriesLength); + gSoundEffectsListEntries = (SoundEffectsListEntry*)internal_malloc(sizeof(*gSoundEffectsListEntries) * gSoundEffectsListEntriesLength); if (gSoundEffectsListEntries == NULL) { fileNameListFree(&fileNameList, 0); return SFXL_ERR; @@ -366,7 +366,7 @@ int soundEffectsListCopyFileNames(char** fileNameList) int soundEffectsListPopulateFileSizes() { - char* path = internal_malloc(gSoundEffectsListPathLength + 13); + char* path = (char*)internal_malloc(gSoundEffectsListPathLength + 13); if (path == NULL) { return SFXL_ERR; } diff --git a/src/stat.c b/src/stat.cc similarity index 100% rename from src/stat.c rename to src/stat.cc diff --git a/src/string_parsers.c b/src/string_parsers.cc similarity index 100% rename from src/string_parsers.c rename to src/string_parsers.cc diff --git a/src/text_font.c b/src/text_font.cc similarity index 98% rename from src/text_font.c rename to src/text_font.cc index 54caac2..ead4885 100644 --- a/src/text_font.c +++ b/src/text_font.cc @@ -131,7 +131,7 @@ int textFontLoad(int font) goto out; } - textFontDescriptor->glyphs = internal_malloc(textFontDescriptor->glyphCount * sizeof(TextFontGlyph)); + textFontDescriptor->glyphs = (TextFontGlyph*)internal_malloc(textFontDescriptor->glyphCount * sizeof(TextFontGlyph)); if (textFontDescriptor->glyphs == NULL) { goto out; } @@ -141,7 +141,7 @@ int textFontLoad(int font) } int dataSize = textFontDescriptor->lineHeight * ((textFontDescriptor->glyphs[textFontDescriptor->glyphCount - 1].width + 7) >> 3) + textFontDescriptor->glyphs[textFontDescriptor->glyphCount - 1].dataOffset; - textFontDescriptor->data = internal_malloc(dataSize); + textFontDescriptor->data = (unsigned char*)internal_malloc(dataSize); if (textFontDescriptor->data == NULL) { goto out; } diff --git a/src/text_object.c b/src/text_object.cc similarity index 98% rename from src/text_object.c rename to src/text_object.cc index a717e96..7b41c1a 100644 --- a/src/text_object.c +++ b/src/text_object.cc @@ -153,7 +153,7 @@ int textObjectAdd(Object* object, char* string, int font, int color, int a5, Rec return -1; } - TextObject* textObject = internal_malloc(sizeof(*textObject)); + TextObject* textObject = (TextObject*)internal_malloc(sizeof(*textObject)); if (textObject == NULL) { return -1; } @@ -204,7 +204,7 @@ int textObjectAdd(Object* object, char* string, int font, int color, int a5, Rec } int size = textObject->width * textObject->height; - textObject->data = internal_malloc(size); + textObject->data = (unsigned char*)internal_malloc(size); if (textObject->data == NULL) { fontSetCurrent(oldFont); return -1; diff --git a/src/tile.c b/src/tile.cc similarity index 100% rename from src/tile.c rename to src/tile.cc diff --git a/src/trait.c b/src/trait.cc similarity index 100% rename from src/trait.c rename to src/trait.cc diff --git a/src/trap.c b/src/trap.cc similarity index 100% rename from src/trap.c rename to src/trap.cc diff --git a/src/version.c b/src/version.cc similarity index 100% rename from src/version.c rename to src/version.cc diff --git a/src/widget.c b/src/widget.cc similarity index 100% rename from src/widget.c rename to src/widget.cc diff --git a/src/win32.c b/src/win32.cc similarity index 100% rename from src/win32.c rename to src/win32.cc diff --git a/src/window.c b/src/window.cc similarity index 95% rename from src/window.c rename to src/window.cc index 6d99a98..040755e 100644 --- a/src/window.c +++ b/src/window.cc @@ -248,7 +248,7 @@ void _windowPrintBuf(int win, char* string, int stringLength, int width, int max stringLength = 255; } - char* stringCopy = internal_malloc_safe(stringLength + 1, __FILE__, __LINE__); // "..\\int\\WINDOW.C", 1078 + char* stringCopy = (char*)internal_malloc_safe(stringLength + 1, __FILE__, __LINE__); // "..\\int\\WINDOW.C", 1078 strncpy(stringCopy, string, stringLength); stringCopy[stringLength] = '\0'; @@ -264,7 +264,7 @@ void _windowPrintBuf(int win, char* string, int stringLength, int width, int max stringHeight++; } - unsigned char* backgroundBuffer = internal_calloc_safe(stringWidth, stringHeight, __FILE__, __LINE__); // "..\\int\\WINDOW.C", 1093 + unsigned char* backgroundBuffer = (unsigned char*)internal_calloc_safe(stringWidth, stringHeight, __FILE__, __LINE__); // "..\\int\\WINDOW.C", 1093 unsigned char* backgroundBufferPtr = backgroundBuffer; fontDrawText(backgroundBuffer, stringCopy, stringWidth, stringWidth, flags); @@ -338,12 +338,12 @@ char** _windowWordWrap(char* string, int maxLength, int a3, int* substringListLe } if (substringList != NULL) { - substringList = internal_realloc_safe(substringList, sizeof(*substringList) * (substringListLength + 1), __FILE__, __LINE__); // "..\int\WINDOW.C", 1166 + substringList = (char**)internal_realloc_safe(substringList, sizeof(*substringList) * (substringListLength + 1), __FILE__, __LINE__); // "..\int\WINDOW.C", 1166 } else { - substringList = internal_malloc_safe(sizeof(*substringList), __FILE__, __LINE__); // "..\int\WINDOW.C", 1167 + substringList = (char**)internal_malloc_safe(sizeof(*substringList), __FILE__, __LINE__); // "..\int\WINDOW.C", 1167 } - char* substring = internal_malloc_safe(pch - start + 1, __FILE__, __LINE__); // "..\int\WINDOW.C", 1169 + char* substring = (char*)internal_malloc_safe(pch - start + 1, __FILE__, __LINE__); // "..\int\WINDOW.C", 1169 strncpy(substring, start, pch - start); substring[pch - start] = '\0'; @@ -361,12 +361,12 @@ char** _windowWordWrap(char* string, int maxLength, int a3, int* substringListLe if (start != pch) { if (substringList != NULL) { - substringList = internal_realloc_safe(substringList, sizeof(*substringList) * (substringListLength + 1), __FILE__, __LINE__); // "..\int\WINDOW.C", 1184 + substringList = (char**)internal_realloc_safe(substringList, sizeof(*substringList) * (substringListLength + 1), __FILE__, __LINE__); // "..\int\WINDOW.C", 1184 } else { - substringList = internal_malloc_safe(sizeof(*substringList), __FILE__, __LINE__); // "..\int\WINDOW.C", 1185 + substringList = (char**)internal_malloc_safe(sizeof(*substringList), __FILE__, __LINE__); // "..\int\WINDOW.C", 1185 } - char* substring = internal_malloc_safe(pch - start + 1, __FILE__, __LINE__); // "..\int\WINDOW.C", 1169 + char* substring = (char*)internal_malloc_safe(pch - start + 1, __FILE__, __LINE__); // "..\int\WINDOW.C", 1169 strncpy(substring, start, pch - start); substring[pch - start] = '\0'; @@ -833,7 +833,7 @@ bool _windowStartRegion(int initialCapacity) int newRegionIndex; ManagedWindow* managedWindow = &(gManagedWindows[gCurrentManagedWindowIndex]); if (managedWindow->regions == NULL) { - managedWindow->regions = internal_malloc_safe(sizeof(&(managedWindow->regions)), __FILE__, __LINE__); // "..\int\WINDOW.C", 2167 + managedWindow->regions = (Region**)internal_malloc_safe(sizeof(&(managedWindow->regions)), __FILE__, __LINE__); // "..\int\WINDOW.C", 2167 managedWindow->regionsLength = 1; newRegionIndex = 0; } else { @@ -846,7 +846,7 @@ bool _windowStartRegion(int initialCapacity) } if (newRegionIndex == managedWindow->regionsLength) { - managedWindow->regions = internal_realloc_safe(managedWindow->regions, sizeof(&(managedWindow->regions)) * (managedWindow->regionsLength + 1), __FILE__, __LINE__); // "..\int\WINDOW.C", 2178 + managedWindow->regions = (Region**)internal_realloc_safe(managedWindow->regions, sizeof(&(managedWindow->regions)) * (managedWindow->regionsLength + 1), __FILE__, __LINE__); // "..\int\WINDOW.C", 2178 managedWindow->regionsLength++; } } diff --git a/src/window_manager.c b/src/window_manager.cc similarity index 99% rename from src/window_manager.c rename to src/window_manager.cc index a0205c8..0bd4512 100644 --- a/src/window_manager.c +++ b/src/window_manager.cc @@ -129,7 +129,7 @@ int windowManagerInit(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitP } if (a3 & 1) { - _screen_buffer = internal_malloc((_scr_size.bottom - _scr_size.top + 1) * (_scr_size.right - _scr_size.left + 1)); + _screen_buffer = (unsigned char*)internal_malloc((_scr_size.bottom - _scr_size.top + 1) * (_scr_size.right - _scr_size.left + 1)); if (_screen_buffer == NULL) { if (gVideoSystemExitProc != NULL) { gVideoSystemExitProc(); @@ -148,7 +148,7 @@ int windowManagerInit(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitP colorPaletteSetMemoryProcs(internal_malloc, internal_realloc, internal_free); if (!_initColors()) { - unsigned char* palette = internal_malloc(768); + unsigned char* palette = (unsigned char*)internal_malloc(768); if (palette == NULL) { if (gVideoSystemExitProc != NULL) { gVideoSystemExitProc(); @@ -179,7 +179,7 @@ int windowManagerInit(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitP _GNW_intr_init(); - Window* window = gWindows[0] = internal_malloc(sizeof(*window)); + Window* window = gWindows[0] = (Window*)internal_malloc(sizeof(*window)); if (window == NULL) { if (gVideoSystemExitProc != NULL) { gVideoSystemExitProc(); @@ -290,12 +290,12 @@ int windowCreate(int x, int y, int width, int height, int a4, int flags) return -1; } - Window* window = gWindows[gWindowsLength] = internal_malloc(sizeof(*window)); + Window* window = gWindows[gWindowsLength] = (Window*)internal_malloc(sizeof(*window)); if (window == NULL) { return -1; } - window->buffer = internal_malloc(width * height); + window->buffer = (unsigned char*)internal_malloc(width * height); if (window->buffer == NULL) { internal_free(window); return -1; @@ -857,7 +857,7 @@ void _GNW_win_refresh(Window* window, Rect* rect, unsigned char* a3) while (v16 != NULL) { int width = v16->rect.right - v16->rect.left + 1; int height = v16->rect.bottom - v16->rect.top + 1; - unsigned char* buf = internal_malloc(width * height); + unsigned char* buf = (unsigned char*)internal_malloc(width * height); if (buf != NULL) { bufferFill(buf, width, height, width, _bk_color); if (dest_pitch != 0) { @@ -1490,7 +1490,7 @@ Button* buttonCreateInternal(int win, int x, int y, int width, int height, int m return NULL; } - Button* button = internal_malloc(sizeof(*button)); + Button* button = (Button*)internal_malloc(sizeof(*button)); if (button == NULL) { return NULL; } diff --git a/src/window_manager_private.c b/src/window_manager_private.cc similarity index 97% rename from src/window_manager_private.c rename to src/window_manager_private.cc index b7c04c5..3fd493b 100644 --- a/src/window_manager_private.c +++ b/src/window_manager_private.cc @@ -105,7 +105,7 @@ int _win_register_menu_bar(int win, int x, int y, int width, int height, int a6, return -1; } - struc_177* v14 = window->field_3C = internal_malloc(sizeof(struc_177)); + struc_177* v14 = window->field_3C = (struc_177*)internal_malloc(sizeof(struc_177)); if (v14 == NULL) { return -1; } @@ -197,7 +197,7 @@ int _GNW_process_menu(struc_177* ptr, int i) // 0x4DD03C int _calc_max_field_chars_wcursor(int a1, int a2) { - char* str = internal_malloc(17); + char* str = (char*)internal_malloc(17); if (str == NULL) { return -1; } diff --git a/src/word_wrap.c b/src/word_wrap.cc similarity index 100% rename from src/word_wrap.c rename to src/word_wrap.cc diff --git a/src/world_map.c b/src/world_map.cc similarity index 99% rename from src/world_map.c rename to src/world_map.cc index ace1d26..1d2cf5d 100644 --- a/src/world_map.c +++ b/src/world_map.cc @@ -1151,7 +1151,7 @@ int worldmapConfigInit() gWorldmapTilesLength++; - TileInfo* worldmapTiles = internal_realloc(gWorldmapTiles, sizeof(*gWorldmapTiles) * gWorldmapTilesLength); + TileInfo* worldmapTiles = (TileInfo*)internal_realloc(gWorldmapTiles, sizeof(*gWorldmapTiles) * gWorldmapTilesLength); if (worldmapTiles == NULL) { showMesageBox("\nwmConfigInit::Error loading tiles!"); exit(1); @@ -1206,7 +1206,7 @@ int worldmapConfigLoadEncounterTable(Config* config, char* lookupName, char* sec { gEncounterTablesLength++; - EncounterTable* encounterTables = internal_realloc(gEncounterTables, sizeof(EncounterTable) * gEncounterTablesLength); + EncounterTable* encounterTables = (EncounterTable*)internal_realloc(gEncounterTables, sizeof(EncounterTable) * gEncounterTablesLength); if (encounterTables == NULL) { showMesageBox("\nwmConfigInit::Error loading Encounter Table!"); exit(1); @@ -1461,7 +1461,7 @@ int _wmReadEncBaseType(char* name, int* valuePtr) _wmMaxEncBaseTypes++; - ENC_BASE_TYPE* arr = internal_realloc(_wmEncBaseTypeList, sizeof(*_wmEncBaseTypeList) * _wmMaxEncBaseTypes); + ENC_BASE_TYPE* arr = (ENC_BASE_TYPE*)internal_realloc(_wmEncBaseTypeList, sizeof(*_wmEncBaseTypeList) * _wmMaxEncBaseTypes); if (arr == NULL) { showMesageBox("\nwmConfigInit::Error Reading EncBaseType!"); exit(1); @@ -1692,7 +1692,7 @@ int _wmParseTerrainTypes(Config* config, char* string) gTerrainsLength = terrainCount; - gTerrains = internal_malloc(sizeof(*gTerrains) * terrainCount); + gTerrains = (Terrain*)internal_malloc(sizeof(*gTerrains) * terrainCount); if (gTerrains == NULL) { return -1; } @@ -2252,7 +2252,7 @@ int cityInit() gCitiesLength++; - cities = internal_realloc(gCities, sizeof(CityInfo) * gCitiesLength); + cities = (CityInfo*)internal_realloc(gCities, sizeof(CityInfo) * gCitiesLength); if (cities == NULL) { showMesageBox("\nwmConfigInit::Error loading areas!"); exit(1); @@ -2457,7 +2457,7 @@ int _wmMapInit() gMapsLength++; - maps = internal_realloc(gMaps, sizeof(*gMaps) * gMapsLength); + maps = (MapInfo*)internal_realloc(gMaps, sizeof(*gMaps) * gMapsLength); if (maps == NULL) { showMesageBox("\nwmConfigInit::Error loading maps!"); exit(1); @@ -4028,7 +4028,7 @@ int _wmGrabTileWalkMask(int tile) return 0; } - tileInfo->walkMaskData = internal_malloc(13200); + tileInfo->walkMaskData = (unsigned char*)internal_malloc(13200); if (tileInfo->walkMaskData == NULL) { return -1; } @@ -6288,7 +6288,7 @@ int _wmMakeTabsLabelList(int** quickDestinationsPtr, int* quickDestinationsLengt int capacity = 10; - quickDestinations = internal_malloc(sizeof(*quickDestinations) * capacity); + quickDestinations = (int*)internal_malloc(sizeof(*quickDestinations) * capacity); *quickDestinationsPtr = quickDestinations; if (quickDestinations == NULL) { @@ -6304,7 +6304,7 @@ int _wmMakeTabsLabelList(int** quickDestinationsPtr, int* quickDestinationsLengt if (capacity <= quickDestinationsLength) { capacity += 10; - quickDestinations = internal_realloc(quickDestinations, sizeof(*quickDestinations) * capacity); + quickDestinations = (int*)internal_realloc(quickDestinations, sizeof(*quickDestinations) * capacity); if (quickDestinations == NULL) { return -1; } diff --git a/src/xfile.c b/src/xfile.cc similarity index 99% rename from src/xfile.c rename to src/xfile.cc index 96070e7..ce3edeb 100644 --- a/src/xfile.c +++ b/src/xfile.cc @@ -47,7 +47,7 @@ XFile* xfileOpen(const char* filePath, const char* mode) assert(filePath); // "filename", "xfile.c", 162 assert(mode); // "mode", "xfile.c", 163 - XFile* stream = malloc(sizeof(*stream)); + XFile* stream = (XFile*)malloc(sizeof(*stream)); if (stream == NULL) { return NULL; } @@ -482,7 +482,7 @@ bool xbaseOpen(const char* path) return true; } - XBase* xbase = malloc(sizeof(*xbase)); + XBase* xbase = (XBase*)malloc(sizeof(*xbase)); if (xbase == NULL) { return false; }