From a9ca75a1a36072e927b468081474b5648897f3bc Mon Sep 17 00:00:00 2001 From: k3tamina Date: Sun, 19 Jun 2022 06:45:51 +0200 Subject: [PATCH] Cleanup world_map.h (#51) --- src/world_map.cc | 702 ++++++++++++++++++++++++++++++++++++----------- src/world_map.h | 550 ------------------------------------- 2 files changed, 543 insertions(+), 709 deletions(-) diff --git a/src/world_map.cc b/src/world_map.cc index e6ba0a8..143d94b 100644 --- a/src/world_map.cc +++ b/src/world_map.cc @@ -1,12 +1,12 @@ #include "world_map.h" -#include "animation.h" #include "color.h" #include "combat.h" #include "combat_ai.h" #include "core.h" #include "critter.h" #include "cycle.h" +#include "db.h" #include "dbox.h" #include "debug.h" #include "display_monitor.h" @@ -20,9 +20,7 @@ #include "item.h" #include "memory.h" #include "object.h" -#include "party_member.h" #include "perk.h" -#include "platform_compat.h" #include "proto_instance.h" #include "queue.h" #include "random.h" @@ -39,6 +37,45 @@ #include #include +#define CITY_NAME_SIZE (40) +#define TILE_WALK_MASK_NAME_SIZE (40) +#define ENTRANCE_LIST_CAPACITY (10) + +#define MAP_AMBIENT_SOUND_EFFECTS_CAPACITY (6) +#define MAP_STARTING_POINTS_CAPACITY (15) + +#define SUBTILE_GRID_WIDTH (7) +#define SUBTILE_GRID_HEIGHT (6) + +#define ENCOUNTER_ENTRY_SPECIAL (0x01) + +#define ENCOUNTER_SUBINFO_DEAD (0x01) + +#define WM_WINDOW_DIAL_X (532) +#define WM_WINDOW_DIAL_Y (48) + +#define WM_TOWN_LIST_SCROLL_UP_X (480) +#define WM_TOWN_LIST_SCROLL_UP_Y (137) + +#define WM_TOWN_LIST_SCROLL_DOWN_X (WM_TOWN_LIST_SCROLL_UP_X) +#define WM_TOWN_LIST_SCROLL_DOWN_Y (152) + +#define WM_WINDOW_GLOBE_OVERLAY_X (495) +#define WM_WINDOW_GLOBE_OVERLAY_Y (330) + +#define WM_WINDOW_CAR_X (514) +#define WM_WINDOW_CAR_Y (336) + +#define WM_WINDOW_CAR_OVERLAY_X (499) +#define WM_WINDOW_CAR_OVERLAY_Y (330) + +#define WM_WINDOW_CAR_FUEL_BAR_X (500) +#define WM_WINDOW_CAR_FUEL_BAR_Y (339) +#define WM_WINDOW_CAR_FUEL_BAR_HEIGHT (70) + +#define WM_TOWN_WORLD_SWITCH_X (519) +#define WM_TOWN_WORLD_SWITCH_Y (439) + #define WM_TILE_WIDTH (350) #define WM_TILE_HEIGHT (300) @@ -52,49 +89,303 @@ #define WM_VIEW_WIDTH (450) #define WM_VIEW_HEIGHT (443) +typedef enum EncounterFormationType { + ENCOUNTER_FORMATION_TYPE_SURROUNDING, + ENCOUNTER_FORMATION_TYPE_STRAIGHT_LINE, + ENCOUNTER_FORMATION_TYPE_DOUBLE_LINE, + ENCOUNTER_FORMATION_TYPE_WEDGE, + ENCOUNTER_FORMATION_TYPE_CONE, + ENCOUNTER_FORMATION_TYPE_HUDDLE, + ENCOUNTER_FORMATION_TYPE_COUNT, +} EncounterFormationType; + + +typedef enum EncounterFrequencyType { + ENCOUNTER_FREQUENCY_TYPE_NONE, + ENCOUNTER_FREQUENCY_TYPE_RARE, + ENCOUNTER_FREQUENCY_TYPE_UNCOMMON, + ENCOUNTER_FREQUENCY_TYPE_COMMON, + ENCOUNTER_FREQUENCY_TYPE_FREQUENT, + ENCOUNTER_FREQUENCY_TYPE_FORCED, + ENCOUNTER_FREQUENCY_TYPE_COUNT, +} EncounterFrequencyType; + +typedef enum EncounterSceneryType { + ENCOUNTER_SCENERY_TYPE_NONE, + ENCOUNTER_SCENERY_TYPE_LIGHT, + ENCOUNTER_SCENERY_TYPE_NORMAL, + ENCOUNTER_SCENERY_TYPE_HEAVY, + ENCOUNTER_SCENERY_TYPE_COUNT, +} EncounterSceneryType; + +typedef enum EncounterSituation { + ENCOUNTER_SITUATION_NOTHING, + ENCOUNTER_SITUATION_AMBUSH, + ENCOUNTER_SITUATION_FIGHTING, + ENCOUNTER_SITUATION_AND, + ENCOUNTER_SITUATION_COUNT, +} EncounterSituation; + +typedef enum EncounterLogicalOperator { + ENCOUNTER_LOGICAL_OPERATOR_NONE, + ENCOUNTER_LOGICAL_OPERATOR_AND, + ENCOUNTER_LOGICAL_OPERATOR_OR, +} EncounterLogicalOperator; + +typedef enum EncounterConditionType { + ENCOUNTER_CONDITION_TYPE_NONE = 0, + ENCOUNTER_CONDITION_TYPE_GLOBAL = 1, + ENCOUNTER_CONDITION_TYPE_NUMBER_OF_CRITTERS = 2, + ENCOUNTER_CONDITION_TYPE_RANDOM = 3, + ENCOUNTER_CONDITION_TYPE_PLAYER = 4, + ENCOUNTER_CONDITION_TYPE_DAYS_PLAYED = 5, + ENCOUNTER_CONDITION_TYPE_TIME_OF_DAY = 6, +} EncounterConditionType; + +typedef enum EncounterConditionalOperator { + ENCOUNTER_CONDITIONAL_OPERATOR_NONE, + ENCOUNTER_CONDITIONAL_OPERATOR_EQUAL, + ENCOUNTER_CONDITIONAL_OPERATOR_NOT_EQUAL, + ENCOUNTER_CONDITIONAL_OPERATOR_LESS_THAN, + ENCOUNTER_CONDITIONAL_OPERATOR_GREATER_THAN, + ENCOUNTER_CONDITIONAL_OPERATOR_COUNT, +} EncounterConditionalOperator; + +typedef enum Daytime { + DAY_PART_MORNING, + DAY_PART_AFTERNOON, + DAY_PART_NIGHT, + DAY_PART_COUNT, +} Daytime; + +typedef enum SubtileState { + SUBTILE_STATE_UNKNOWN, + SUBTILE_STATE_KNOWN, + SUBTILE_STATE_VISITED, +} SubtileState; + +typedef enum CitySize { + CITY_SIZE_SMALL, + CITY_SIZE_MEDIUM, + CITY_SIZE_LARGE, + CITY_SIZE_COUNT, +} CitySize; + +typedef enum WorldMapEncounterFrm { + WORLD_MAP_ENCOUNTER_FRM_RANDOM_BRIGHT, + WORLD_MAP_ENCOUNTER_FRM_RANDOM_DARK, + WORLD_MAP_ENCOUNTER_FRM_SPECIAL_BRIGHT, + WORLD_MAP_ENCOUNTER_FRM_SPECIAL_DARK, + WORLD_MAP_ENCOUNTER_FRM_COUNT, +} WorldMapEncounterFrm; + +typedef enum WorldmapArrowFrm { + WORLDMAP_ARROW_FRM_NORMAL, + WORLDMAP_ARROW_FRM_PRESSED, + WORLDMAP_ARROW_FRM_COUNT, +} WorldmapArrowFrm; + +typedef struct EntranceInfo { + int state; + int x; + int y; + int map; + int elevation; + int tile; + int rotation; +} EntranceInfo; + +typedef struct CityInfo { + char name[CITY_NAME_SIZE]; + int field_28; + int x; + int y; + int size; + int state; + // lock state + int field_3C; + int field_40; + int mapFid; + int labelFid; + int entrancesLength; + EntranceInfo entrances[ENTRANCE_LIST_CAPACITY]; +} CityInfo; + +typedef struct MapAmbientSoundEffectInfo { + char name[40]; + int chance; +} MapAmbientSoundEffectInfo; + +typedef struct MapStartPointInfo { + int elevation; + int tile; + int field_8; +} MapStartPointInfo; + +typedef struct MapInfo { + char lookupName[40]; + int field_28; + int field_2C; + char mapFileName[40]; + char music[40]; + int flags; + int ambientSoundEffectsLength; + MapAmbientSoundEffectInfo ambientSoundEffects[MAP_AMBIENT_SOUND_EFFECTS_CAPACITY]; + int startPointsLength; + MapStartPointInfo startPoints[MAP_STARTING_POINTS_CAPACITY]; +} MapInfo; + +typedef struct Terrain { + char field_0[40]; + int field_28; + int mapsLength; + int maps[20]; +} Terrain; + +typedef struct EncounterConditionEntry { + int type; + int conditionalOperator; + int param; + int value; +} EncounterConditionEntry; + +typedef struct EncounterCondition { + int entriesLength; + EncounterConditionEntry entries[3]; + int logicalOperators[2]; +} EncounterCondition; + +typedef struct ENCOUNTER_ENTRY_ENC { + int minQuantity; // min + int maxQuantity; // max + int field_8; + int situation; +} ENCOUNTER_ENTRY_ENC; + +typedef struct EncounterEntry { + int flags; + int map; + int scenery; + int chance; + int counter; + EncounterCondition condition; + int field_50; + ENCOUNTER_ENTRY_ENC field_54[6]; +} EncounterEntry; + +typedef struct EncounterTable { + char lookupName[40]; + int field_28; + int mapsLength; + int maps[6]; + int field_48; + int entriesLength; + EncounterEntry entries[41]; +} EncounterTable; + +typedef struct ENC_BASE_TYPE_38_48 { + int pid; + int minimumQuantity; + int maximumQuantity; + bool isEquipped; +} ENC_BASE_TYPE_38_48; + +typedef struct ENC_BASE_TYPE_38 { + char field_0[40]; + int field_28; + int field_2C; + int ratio; + int pid; + int flags; + int distance; + int tile; + int itemsLength; + ENC_BASE_TYPE_38_48 items[10]; + int team; + int script; + EncounterCondition condition; +} ENC_BASE_TYPE_38; + +typedef struct ENC_BASE_TYPE { + char name[40]; + int position; + int spacing; + int distance; + int field_34; + ENC_BASE_TYPE_38 field_38[10]; +} ENC_BASE_TYPE; + +typedef struct SubtileInfo { + int terrain; + int field_4; + int encounterChance[DAY_PART_COUNT]; + int encounterType; + int state; +} SubtileInfo; + +// A worldmap tile is 7x6 area, thus consisting of 42 individual subtiles. +typedef struct TileInfo { + int fid; + CacheEntry* handle; + unsigned char* data; + char walkMaskName[TILE_WALK_MASK_NAME_SIZE]; + unsigned char* walkMaskData; + int encounterDifficultyModifier; + SubtileInfo subtiles[SUBTILE_GRID_HEIGHT][SUBTILE_GRID_WIDTH]; +} TileInfo; + +// +typedef struct CitySizeDescription { + int fid; + int width; + int height; + CacheEntry* handle; + unsigned char* data; +} CitySizeDescription; + // 0x4BC860 -const int _can_rest_here[ELEVATION_COUNT] = { +static const int _can_rest_here[ELEVATION_COUNT] = { MAP_CAN_REST_ELEVATION_0, MAP_CAN_REST_ELEVATION_1, MAP_CAN_REST_ELEVATION_2, }; // 0x4BC86C -const int gDayPartEncounterFrequencyModifiers[DAY_PART_COUNT] = { +static const int gDayPartEncounterFrequencyModifiers[DAY_PART_COUNT] = { 40, 30, 0, }; // 0x4BC878 -const char* off_4BC878[2] = { +static const char* off_4BC878[2] = { "You detect something up ahead.", "Do you wish to encounter it?", }; // 0x4BC880 -MessageListItem stru_4BC880; +static MessageListItem stru_4BC880; // 0x50EE44 -char _aCricket[] = "cricket"; +static char _aCricket[] = "cricket"; // 0x50EE4C -char _aCricket1[] = "cricket1"; +static char _aCricket1[] = "cricket1"; // 0x51DD88 -const char* _wmStateStrs[2] = { +static const char* _wmStateStrs[2] = { "off", "on" }; // 0x51DD90 -const char* _wmYesNoStrs[2] = { +static const char* _wmYesNoStrs[2] = { "no", "yes", }; // 0x51DD98 -const char* gEncounterFrequencyTypeKeys[ENCOUNTER_FREQUENCY_TYPE_COUNT] = { +static const char* gEncounterFrequencyTypeKeys[ENCOUNTER_FREQUENCY_TYPE_COUNT] = { "none", "rare", "uncommon", @@ -104,7 +395,7 @@ const char* gEncounterFrequencyTypeKeys[ENCOUNTER_FREQUENCY_TYPE_COUNT] = { }; // 0x51DDB0 -const char* _wmFillStrs[9] = { +static const char* _wmFillStrs[9] = { "no_fill", "fill_n", "fill_s", @@ -117,7 +408,7 @@ const char* _wmFillStrs[9] = { }; // 0x51DDD4 -const char* _wmSceneryStrs[ENCOUNTER_SCENERY_TYPE_COUNT] = { +static const char* _wmSceneryStrs[ENCOUNTER_SCENERY_TYPE_COUNT] = { "none", "light", "normal", @@ -125,16 +416,16 @@ const char* _wmSceneryStrs[ENCOUNTER_SCENERY_TYPE_COUNT] = { }; // 0x51DDE4 -Terrain* gTerrains = NULL; +static Terrain* gTerrains = NULL; // 0x51DDE8 -int gTerrainsLength = 0; +static int gTerrainsLength = 0; // 0x51DDEC -TileInfo* gWorldmapTiles = NULL; +static TileInfo* gWorldmapTiles = NULL; // 0x51DDF0 -int gWorldmapTilesLength = 0; +static int gWorldmapTilesLength = 0; // The width of worldmap grid in tiles. // @@ -143,59 +434,59 @@ int gWorldmapTilesLength = 0; // // num_horizontal_tiles // 0x51DDF4 -int gWorldmapGridWidth = 0; +static int gWorldmapGridWidth = 0; // 0x51DDF8 -CityInfo* gCities = NULL; +static CityInfo* gCities = NULL; // 0x51DDFC -int gCitiesLength = 0; +static int gCitiesLength = 0; // 0x51DE00 -const char* gCitySizeKeys[CITY_SIZE_COUNT] = { +static const char* gCitySizeKeys[CITY_SIZE_COUNT] = { "small", "medium", "large", }; // 0x51DE0C -MapInfo* gMaps = NULL; +static MapInfo* gMaps = NULL; // 0x51DE10 -int gMapsLength = 0; +static int gMapsLength = 0; // 0x51DE14 -int gWorldmapWindow = -1; +static int gWorldmapWindow = -1; // 0x51DE18 -CacheEntry* gWorldmapBoxFrmHandle = INVALID_CACHE_ENTRY; +static CacheEntry* gWorldmapBoxFrmHandle = INVALID_CACHE_ENTRY; // 0x51DE1C -int gWorldmapBoxFrmWidth = 0; +static int gWorldmapBoxFrmWidth = 0; // 0x51DE20 -int gWorldmapBoxFrmHeight = 0; +static int gWorldmapBoxFrmHeight = 0; // 0x51DE24 -unsigned char* gWorldmapWindowBuffer = NULL; +static unsigned char* gWorldmapWindowBuffer = NULL; // 0x51DE28 -unsigned char* gWorldmapBoxFrmData = NULL; +static unsigned char* gWorldmapBoxFrmData = NULL; // 0x51DE2C -int gWorldmapOffsetX = 0; +static int gWorldmapOffsetX = 0; // 0x51DE30 -int gWorldmapOffsetY = 0; +static int gWorldmapOffsetY = 0; // -unsigned char* _circleBlendTable = NULL; +static unsigned char* _circleBlendTable = NULL; // -int _wmInterfaceWasInitialized = 0; +static int _wmInterfaceWasInitialized = 0; // encounter types -const char* _wmEncOpStrs[ENCOUNTER_SITUATION_COUNT] = { +static const char* _wmEncOpStrs[ENCOUNTER_SITUATION_COUNT] = { "nothing", "ambush", "fighting", @@ -203,7 +494,7 @@ const char* _wmEncOpStrs[ENCOUNTER_SITUATION_COUNT] = { }; // operators -const char* _wmConditionalOpStrs[ENCOUNTER_CONDITIONAL_OPERATOR_COUNT] = { +static const char* _wmConditionalOpStrs[ENCOUNTER_CONDITIONAL_OPERATOR_COUNT] = { "_", "==", "!=", @@ -212,7 +503,7 @@ const char* _wmConditionalOpStrs[ENCOUNTER_CONDITIONAL_OPERATOR_COUNT] = { }; // 0x51DE6C -const char* gEncounterFormationTypeKeys[ENCOUNTER_FORMATION_TYPE_COUNT] = { +static const char* gEncounterFormationTypeKeys[ENCOUNTER_FORMATION_TYPE_COUNT] = { "surrounding", "straight_line", "double_line", @@ -222,7 +513,7 @@ const char* gEncounterFormationTypeKeys[ENCOUNTER_FORMATION_TYPE_COUNT] = { }; // 0x51DE84 -int gWorldmapEncounterFrmIds[WORLD_MAP_ENCOUNTER_FRM_COUNT] = { +static int gWorldmapEncounterFrmIds[WORLD_MAP_ENCOUNTER_FRM_COUNT] = { 154, 155, 438, @@ -230,384 +521,477 @@ int gWorldmapEncounterFrmIds[WORLD_MAP_ENCOUNTER_FRM_COUNT] = { }; // 0x51DE94 -int* gQuickDestinations = NULL; +static int* gQuickDestinations = NULL; // 0x51DE98 -int gQuickDestinationsLength = 0; +static int gQuickDestinationsLength = 0; // 0x51DE9C -int _wmTownMapCurArea = -1; +static int _wmTownMapCurArea = -1; // 0x51DEA0 -unsigned int _wmLastRndTime = 0; +static unsigned int _wmLastRndTime = 0; // 0x51DEA4 -int _wmRndIndex = 0; +static int _wmRndIndex = 0; // 0x51DEA8 -int _wmRndCallCount = 0; +static int _wmRndCallCount = 0; // 0x51DEAC -int _terrainCounter = 1; +static int _terrainCounter = 1; // 0x51DEB0 -unsigned int _lastTime_2 = 0; +static unsigned int _lastTime_2 = 0; // 0x51DEB4 -bool _couldScroll = true; +static bool _couldScroll = true; // 0x51DEB8 -unsigned char* gWorldmapCityMapFrmData = NULL; +static unsigned char* gWorldmapCityMapFrmData = NULL; // 0x51DEBC -CacheEntry* gWorldmapCityMapFrmHandle = INVALID_CACHE_ENTRY; +static CacheEntry* gWorldmapCityMapFrmHandle = INVALID_CACHE_ENTRY; // 0x51DEC0 -int gWorldmapCityMapFrmWidth = 0; +static int gWorldmapCityMapFrmWidth = 0; // 0x51DEC4 -int gWorldmapCityMapFrmHeight = 0; +static int gWorldmapCityMapFrmHeight = 0; // 0x51DEC8 -char* _wmRemapSfxList[2] = { +static char* _wmRemapSfxList[2] = { _aCricket, _aCricket1, }; // 0x672DB8 -int _wmRndTileDirs[2]; +static int _wmRndTileDirs[2]; // 0x672DC0 -int _wmRndCenterTiles[2]; +static int _wmRndCenterTiles[2]; // 0x672DC8 -int _wmRndCenterRotations[2]; +static int _wmRndCenterRotations[2]; // 0x672DD0 -int _wmRndRotOffsets[2]; +static int _wmRndRotOffsets[2]; // Buttons for city entrances. // // 0x672DD8 -int _wmTownMapButtonId[ENTRANCE_LIST_CAPACITY]; +static int _wmTownMapButtonId[ENTRANCE_LIST_CAPACITY]; // 0x672E00 -int _wmGenData; +static int _wmGenData; // 0x672E04 -int _Meet_Frank_Horrigan; +static int _Meet_Frank_Horrigan; // Current_town. // // 0x672E08 -int _WorldMapCurrArea; +static int _WorldMapCurrArea; // Current town x. // // 0x672E0C -int _world_xpos; +static int _world_xpos; // Current town y. // // 0x672E10 -int _world_ypos; +static int _world_ypos; // 0x672E14 -SubtileInfo* _world_subtile; +static SubtileInfo* _world_subtile; // 0x672E18 -int dword_672E18; +static int dword_672E18; // 0x672E1C -bool gWorldmapIsTravelling; +static bool gWorldmapIsTravelling; // 0x672E20 -int gWorldmapTravelDestX; +static int gWorldmapTravelDestX; // 0x672E24 -int gWorldmapTravelDestY; +static int gWorldmapTravelDestY; // 0x672E28 -int dword_672E28; +static int dword_672E28; // 0x672E2C -int dword_672E2C; +static int dword_672E2C; // 0x672E30 -int dword_672E30; +static int dword_672E30; // 0x672E34 -int dword_672E34; +static int dword_672E34; // 0x672E38 -int _x_line_inc; +static int _x_line_inc; // 0x672E3C -int dword_672E3C; +static int dword_672E3C; // 0x672E40 -int _y_line_inc; +static int _y_line_inc; // 0x672E44 -int dword_672E44; +static int dword_672E44; // 0x672E48 -int _wmEncounterIconShow; +static int _wmEncounterIconShow; // 0x672E4C -int _EncounterMapID; +static int _EncounterMapID; // 0x672E50 -int dword_672E50; +static int dword_672E50; // 0x672E54 -int dword_672E54; +static int dword_672E54; // 0x672E58 -int _wmRndCursorFid; +static int _wmRndCursorFid; // 0x672E5C -int _old_world_xpos; +static int _old_world_xpos; // 0x672E60 -int _old_world_ypos; +static int _old_world_ypos; // 0x672E64 -bool gWorldmapIsInCar; +static bool gWorldmapIsInCar; // 0x672E68 -int _carCurrentArea; +static int _carCurrentArea; // 0x672E6C -int gWorldmapCarFuel; +static int gWorldmapCarFuel; // 0x672E70 -CacheEntry* gWorldmapCarFrmHandle; +static CacheEntry* gWorldmapCarFrmHandle; // 0x672E74 -Art* gWorldmapCarFrm; +static Art* gWorldmapCarFrm; // 0x672E78 -int gWorldmapCarFrmWidth; +static int gWorldmapCarFrmWidth; // 0x672E7C -int gWorldmapCarFrmHeight; +static int gWorldmapCarFrmHeight; // 0x672E80 -int gWorldmapCarFrmCurrentFrame; +static int gWorldmapCarFrmCurrentFrame; // 0x672E84 -CacheEntry* gWorldmapHotspotUpFrmHandle; +static CacheEntry* gWorldmapHotspotUpFrmHandle; // 0x672E88 -unsigned char* gWorldmapHotspotUpFrmData; +static unsigned char* gWorldmapHotspotUpFrmData; // 0x672E8C -CacheEntry* gWorldmapHotspotDownFrmHandle; +static CacheEntry* gWorldmapHotspotDownFrmHandle; // 0x672E90 -unsigned char* gWorldmapHotspotDownFrmData; +static unsigned char* gWorldmapHotspotDownFrmData; // 0x672E94 -int gWorldmapHotspotUpFrmWidth; +static int gWorldmapHotspotUpFrmWidth; // 0x672E98 -int gWorldmapHotspotUpFrmHeight; +static int gWorldmapHotspotUpFrmHeight; // 0x672E9C -CacheEntry* gWorldmapDestinationMarkerFrmHandle; +static CacheEntry* gWorldmapDestinationMarkerFrmHandle; // 0x672EA0 -unsigned char* gWorldmapDestinationMarkerFrmData; +static unsigned char* gWorldmapDestinationMarkerFrmData; // 0x672EA4 -int gWorldmapDestinationMarkerFrmWidth; +static int gWorldmapDestinationMarkerFrmWidth; // 0x672EA8 -int gWorldmapDestinationMarkerFrmHeight; +static int gWorldmapDestinationMarkerFrmHeight; // 0x672EAC -CacheEntry* gWorldmapLocationMarkerFrmHandle; +static CacheEntry* gWorldmapLocationMarkerFrmHandle; // 0x672EB0 -unsigned char* gWorldmapLocationMarkerFrmData; +static unsigned char* gWorldmapLocationMarkerFrmData; // 0x672EB4 -int gWorldmapLocationMarkerFrmWidth; +static int gWorldmapLocationMarkerFrmWidth; // 0x672EB8 -int gWorldmapLocationMarkerFrmHeight; +static int gWorldmapLocationMarkerFrmHeight; // 0x672EBC -CacheEntry* gWorldmapEncounterFrmHandles[WORLD_MAP_ENCOUNTER_FRM_COUNT]; +static CacheEntry* gWorldmapEncounterFrmHandles[WORLD_MAP_ENCOUNTER_FRM_COUNT]; // 0x672ECC -unsigned char* gWorldmapEncounterFrmData[WORLD_MAP_ENCOUNTER_FRM_COUNT]; +static unsigned char* gWorldmapEncounterFrmData[WORLD_MAP_ENCOUNTER_FRM_COUNT]; // 0x672EDC -int gWorldmapEncounterFrmWidths[WORLD_MAP_ENCOUNTER_FRM_COUNT]; +static int gWorldmapEncounterFrmWidths[WORLD_MAP_ENCOUNTER_FRM_COUNT]; // 0x672EEC -int gWorldmapEncounterFrmHeights[WORLD_MAP_ENCOUNTER_FRM_COUNT]; +static int gWorldmapEncounterFrmHeights[WORLD_MAP_ENCOUNTER_FRM_COUNT]; // 0x672EFC -int _wmViewportRightScrlLimit; +static int _wmViewportRightScrlLimit; // 0x672F00 -int _wmViewportBottomtScrlLimit; +static int _wmViewportBottomtScrlLimit; // 0x672F04 -CacheEntry* gWorldmapTownTabsUnderlayFrmHandle; +static CacheEntry* gWorldmapTownTabsUnderlayFrmHandle; // 0x672F08 -int gWorldmapTownTabsUnderlayFrmWidth; +static int gWorldmapTownTabsUnderlayFrmWidth; // 0x672F0C -int gWorldmapTownTabsUnderlayFrmHeight; +static int gWorldmapTownTabsUnderlayFrmHeight; // 0x672F10 -int _LastTabsYOffset; +static int _LastTabsYOffset; // 0x672F14 -unsigned char* gWorldmapTownTabsUnderlayFrmData; +static unsigned char* gWorldmapTownTabsUnderlayFrmData; // 0x672F18 -CacheEntry* gWorldmapTownTabsEdgeFrmHandle; +static CacheEntry* gWorldmapTownTabsEdgeFrmHandle; // 0x672F1C -unsigned char* gWorldmapTownTabsEdgeFrmData; +static unsigned char* gWorldmapTownTabsEdgeFrmData; // 0x672F20 -CacheEntry* gWorldmapDialFrmHandle; +static CacheEntry* gWorldmapDialFrmHandle; // 0x672F24 -int gWorldmapDialFrmWidth; +static int gWorldmapDialFrmWidth; // 0x672F28 -int gWorldmapDialFrmHeight; +static int gWorldmapDialFrmHeight; // 0x672F2C -int gWorldmapDialFrmCurrentFrame; +static int gWorldmapDialFrmCurrentFrame; // 0x672F30 -Art* gWorldmapDialFrm; +static Art* gWorldmapDialFrm; // 0x672F34 -CacheEntry* gWorldmapCarOverlayFrmHandle; +static CacheEntry* gWorldmapCarOverlayFrmHandle; // 0x672F38 -int gWorldmapCarOverlayFrmWidth; +static int gWorldmapCarOverlayFrmWidth; // 0x672F3C -int gWorldmapCarOverlayFrmHeight; +static int gWorldmapCarOverlayFrmHeight; // 0x672F40 -unsigned char* gWorldmapCarOverlayFrmData; +static unsigned char* gWorldmapCarOverlayFrmData; // 0x672F44 -CacheEntry* gWorldmapGlobeOverlayFrmHandle; +static CacheEntry* gWorldmapGlobeOverlayFrmHandle; // 0x672F48 -int gWorldmapGlobeOverlayFrmWidth; +static int gWorldmapGlobeOverlayFrmWidth; // 0x672F4C -int gWorldmapGloveOverlayFrmHeight; +static int gWorldmapGloveOverlayFrmHeight; // 0x672F50 -unsigned char* gWorldmapGlobeOverlayFrmData; +static unsigned char* gWorldmapGlobeOverlayFrmData; // 0x672F54 -int dword_672F54; +static int dword_672F54; // 0x672F58 -int _tabsOffset; +static int _tabsOffset; // 0x672F5C -CacheEntry* gWorldmapLittleRedButtonUpFrmHandle; +static CacheEntry* gWorldmapLittleRedButtonUpFrmHandle; // 0x672F60 -CacheEntry* gWorldmapLittleRedButtonDownFrmHandle; +static CacheEntry* gWorldmapLittleRedButtonDownFrmHandle; // 0x672F64 -unsigned char* gWorldmapLittleRedButtonUpFrmData; +static unsigned char* gWorldmapLittleRedButtonUpFrmData; // 0x672F68 -unsigned char* gWorldmapLittleRedButtonDownFrmData; +static unsigned char* gWorldmapLittleRedButtonDownFrmData; // 0x672F6C -CacheEntry* gWorldmapTownListScrollUpFrmHandle[WORLDMAP_ARROW_FRM_COUNT]; +static CacheEntry* gWorldmapTownListScrollUpFrmHandle[WORLDMAP_ARROW_FRM_COUNT]; // 0x672F74 -int gWorldmapTownListScrollUpFrmWidth; +static int gWorldmapTownListScrollUpFrmWidth; // 0x672F78 -int gWorldmapTownListScrollUpFrmHeight; +static int gWorldmapTownListScrollUpFrmHeight; // 0x672F7C -unsigned char* gWorldmapTownListScrollUpFrmData[WORLDMAP_ARROW_FRM_COUNT]; +static unsigned char* gWorldmapTownListScrollUpFrmData[WORLDMAP_ARROW_FRM_COUNT]; // 0x672F84 -CacheEntry* gWorldmapTownListScrollDownFrmHandle[WORLDMAP_ARROW_FRM_COUNT]; +static CacheEntry* gWorldmapTownListScrollDownFrmHandle[WORLDMAP_ARROW_FRM_COUNT]; // 0x672F8C -int gWorldmapTownListScrollDownFrmWidth; +static int gWorldmapTownListScrollDownFrmWidth; // 0x672F90 -int gWorldmapTownListScrollDownFrmHeight; +static int gWorldmapTownListScrollDownFrmHeight; // 0x672F94 -unsigned char* gWorldmapTownListScrollDownFrmData[WORLDMAP_ARROW_FRM_COUNT]; +static unsigned char* gWorldmapTownListScrollDownFrmData[WORLDMAP_ARROW_FRM_COUNT]; // 0x672F9C -CacheEntry* gWorldmapMonthsFrmHandle; +static CacheEntry* gWorldmapMonthsFrmHandle; // 0x672FA0 -Art* gWorldmapMonthsFrm; +static Art* gWorldmapMonthsFrm; // 0x672FA4 -CacheEntry* gWorldmapNumbersFrmHandle; +static CacheEntry* gWorldmapNumbersFrmHandle; // 0x672FA8 -Art* gWorldmapNumbersFrm; +static Art* gWorldmapNumbersFrm; // 0x672FAC -int _fontnum; +static int _fontnum; // worldmap.msg // // 0x672FB0 -MessageList gWorldmapMessageList; +static MessageList gWorldmapMessageList; // 0x672FB8 -int _wmFreqValues[6]; +static int _wmFreqValues[6]; // 0x672FD0 -int _wmRndOriginalCenterTile; +static int _wmRndOriginalCenterTile; // worldmap.txt // // 0x672FD4 -Config* gWorldmapConfig; +static Config* gWorldmapConfig; // 0x672FD8 -int _wmTownMapSubButtonIds[7]; +static int _wmTownMapSubButtonIds[7]; // 0x672FF4 -ENC_BASE_TYPE* _wmEncBaseTypeList; +static ENC_BASE_TYPE* _wmEncBaseTypeList; // 0x672FF8 -CitySizeDescription gCitySizeDescriptions[CITY_SIZE_COUNT]; +static CitySizeDescription gCitySizeDescriptions[CITY_SIZE_COUNT]; // 0x673034 -EncounterTable* gEncounterTables; +static EncounterTable* gEncounterTables; // Number of enc_base_types. // // 0x673038 -int _wmMaxEncBaseTypes; +static int _wmMaxEncBaseTypes; // 0x67303C -int gEncounterTablesLength; +static int gEncounterTablesLength; + +static int _wmGenDataInit(); +static int _wmGenDataReset(); +static int _wmWorldMapSaveTempData(); +static int _wmWorldMapLoadTempData(); +static int worldmapConfigInit(); +static int worldmapConfigLoadEncounterTable(Config* config, char* lookup_name, char* section); +static int worldmapConfigLoadEncounterEntry(EncounterEntry* entry, char* str); +static int _wmParseEncounterSubEncStr(EncounterEntry* entry, char** str_ptr); +static int _wmParseFindSubEncTypeMatch(char* str, int* out_value); +static int _wmFindEncBaseTypeMatch(char* str, int* out_value); +static int _wmReadEncBaseType(char* str, int* out_value); +static int _wmParseEncBaseSubTypeStr(ENC_BASE_TYPE_38* ptr, char** str_ptr); +static int _wmEncBaseTypeSlotInit(ENC_BASE_TYPE* entry); +static int _wmEncBaseSubTypeSlotInit(ENC_BASE_TYPE_38* entry); +static int _wmEncounterSubEncSlotInit(ENCOUNTER_ENTRY_ENC* entry); +static int worldmapEncounterTableEntryInit(EncounterEntry* entry); +static int worldmapEncounterTableInit(EncounterTable* encounterTable); +static int worldmapTileInfoInit(TileInfo* tile); +static int worldmapTerrainInfoInit(Terrain* terrain); +static int worldmapConfigInitEncounterCondition(EncounterCondition* condition); +static int _wmParseTerrainTypes(Config* config, char* str); +static int _wmParseTerrainRndMaps(Config* config, Terrain* terrain); +static int worldmapConfigLoadSubtile(TileInfo* tile, int x, int y, char* str); +static int worldmapFindEncounterTableByLookupName(char* str, int* out_value); +static int worldmapFindTerrainByLookupName(char* str, int* out_value); +static int _wmParseEncounterItemType(char** str_ptr, ENC_BASE_TYPE_38_48* a2, int* a3, const char* delim); +static int _wmParseItemType(char* str, ENC_BASE_TYPE_38_48* ptr); +static int worldmapConfigParseCondition(char** stringPtr, const char* a2, EncounterCondition* condition); +static int worldmapConfigParseConditionEntry(char** stringPtr, const char* a2, int* typePtr, int* operatorPtr, int* paramPtr, int* valuePtr); +static int worldmapConfigParseEncounterConditionalOperator(char** str_ptr, int* out_op); +static int worldmapCityInfoInit(CityInfo* area); +static int cityInit(); +static int worldmapFindMapByLookupName(char* str, int* out_value); +static int worldmapCityEntranceInfoInit(EntranceInfo* entrance); +static int worldmapMapInfoInit(MapInfo* map); +static int _wmMapInit(); +static int worldmapRandomStartingPointInit(MapStartPointInfo* rsp); +static int _wmMatchEntranceFromMap(int cityIndex, int mapIndex, int* entranceIndexPtr); +static int _wmMatchEntranceElevFromMap(int cityIndex, int map, int elevation, int* entranceIndexPtr); +static int _wmMatchAreaFromMap(int a1, int* out_a2); +static int _wmWorldMapFunc(int a1); +static int _wmInterfaceCenterOnParty(); +static int _wmRndEncounterOccurred(); +static int _wmPartyFindCurSubTile(); +static int _wmFindCurSubTileFromPos(int x, int y, SubtileInfo** subtile); +static int _wmFindCurTileFromPos(int x, int y, TileInfo** tile); +static int _wmRndEncounterPick(); +static int worldmapSetupCritters(int type_idx, Object** out_critter, int a3); +static int _wmSetupRndNextTileNumInit(ENC_BASE_TYPE* a1); +static int _wmSetupRndNextTileNum(ENC_BASE_TYPE* a1, ENC_BASE_TYPE_38* a2, int* out_tile_num); +static bool _wmEvalConditional(EncounterCondition* a1, int* a2); +static bool _wmEvalSubConditional(int a1, int a2, int a3); +static bool _wmGameTimeIncrement(int a1); +static int _wmGrabTileWalkMask(int tile_index); +static bool _wmWorldPosInvalid(int a1, int a2); +static void _wmPartyInitWalking(int x, int y); +static void worldmapPerformTravel(); +static void _wmInterfaceScrollTabsStart(int a1); +static void _wmInterfaceScrollTabsStop(); +static int worldmapWindowInit(); +static int worldmapWindowFree(); +static int worldmapWindowScroll(int a1, int a2, int a3, int a4, bool* a5, bool a6); +static void worldmapWindowHandleMouseScrolling(); +static int _wmMarkSubTileOffsetVisitedFunc(int a1, int a2, int a3, int a4, int a5, int a6); +static void _wmMarkSubTileRadiusVisited(int x, int y); +static int _wmTileGrabArt(int tile_index); +static int worldmapWindowRefresh(); +static void worldmapWindowRenderDate(bool shouldRefreshWindow); +static int _wmMatchWorldPosToArea(int a1, int a2, int* a3); +static int worldmapWindowRenderCity(CityInfo* cityInfo, CitySizeDescription* citySizeInfo, unsigned char* buffer, int x, int y); +static void worldmapWindowDimRect(unsigned char* dest, int width, int height, int pitch); +static int worldmapWindowDimSubtile(TileInfo* tileInfo, int a2, int a3, int a4, int a5, int a6); +static int _wmDrawCursorStopped(); +static bool _wmCursorIsVisible(); +static void _wmMarkAllSubTiles(int a1); +static int worldmapCityMapViewSelect(int* mapIndexPtr); +static int worldmapCityMapViewInit(); +static int worldmapCityMapViewRefresh(); +static int worldmapCityMapViewFree(); +static int carConsumeFuel(int a1); +static int worldmapWindowRenderChrome(bool shouldRefreshWindow); +static void worldmapWindowRenderCarFuelBar(); +static int worldmapRenderQuickDestinations(); +static int _wmMakeTabsLabelList(int** out_cities, int* out_len); +static int worldmapCompareCitiesByName(const void* a1, const void* a2); +static void worldmapWindowRenderDial(bool shouldRefreshWindow); +static int _wmAreaFindFirstValidMap(int* out_a1); + +static inline bool cityIsValid(int city) +{ + return city >= 0 && city < gCitiesLength; +} // wmWorldMap_init // 0x4BC89C diff --git a/src/world_map.h b/src/world_map.h index 794583c..4922aa7 100644 --- a/src/world_map.h +++ b/src/world_map.h @@ -1,54 +1,10 @@ #ifndef WORLD_MAP_H #define WORLD_MAP_H -#include "art.h" -#include "config.h" #include "db.h" -#include "map_defs.h" -#include "message.h" -#include "obj_types.h" - -#define CITY_NAME_SIZE (40) -#define TILE_WALK_MASK_NAME_SIZE (40) -#define ENTRANCE_LIST_CAPACITY (10) - -#define MAP_AMBIENT_SOUND_EFFECTS_CAPACITY (6) -#define MAP_STARTING_POINTS_CAPACITY (15) - -#define SUBTILE_GRID_WIDTH (7) -#define SUBTILE_GRID_HEIGHT (6) - -#define ENCOUNTER_ENTRY_SPECIAL (0x01) - -#define ENCOUNTER_SUBINFO_DEAD (0x01) #define CAR_FUEL_MAX (80000) -#define WM_WINDOW_DIAL_X (532) -#define WM_WINDOW_DIAL_Y (48) - -#define WM_TOWN_LIST_SCROLL_UP_X (480) -#define WM_TOWN_LIST_SCROLL_UP_Y (137) - -#define WM_TOWN_LIST_SCROLL_DOWN_X (WM_TOWN_LIST_SCROLL_UP_X) -#define WM_TOWN_LIST_SCROLL_DOWN_Y (152) - -#define WM_WINDOW_GLOBE_OVERLAY_X (495) -#define WM_WINDOW_GLOBE_OVERLAY_Y (330) - -#define WM_WINDOW_CAR_X (514) -#define WM_WINDOW_CAR_Y (336) - -#define WM_WINDOW_CAR_OVERLAY_X (499) -#define WM_WINDOW_CAR_OVERLAY_Y (330) - -#define WM_WINDOW_CAR_FUEL_BAR_X (500) -#define WM_WINDOW_CAR_FUEL_BAR_Y (339) -#define WM_WINDOW_CAR_FUEL_BAR_HEIGHT (70) - -#define WM_TOWN_WORLD_SWITCH_X (519) -#define WM_TOWN_WORLD_SWITCH_Y (439) - typedef enum MapFlags { MAP_SAVED = 0x01, MAP_DEAD_BODIES_AGE = 0x02, @@ -58,74 +14,6 @@ typedef enum MapFlags { MAP_CAN_REST_ELEVATION_2 = 0x20, } MapFlags; -typedef enum EncounterFormationType { - ENCOUNTER_FORMATION_TYPE_SURROUNDING, - ENCOUNTER_FORMATION_TYPE_STRAIGHT_LINE, - ENCOUNTER_FORMATION_TYPE_DOUBLE_LINE, - ENCOUNTER_FORMATION_TYPE_WEDGE, - ENCOUNTER_FORMATION_TYPE_CONE, - ENCOUNTER_FORMATION_TYPE_HUDDLE, - ENCOUNTER_FORMATION_TYPE_COUNT, -} EncounterFormationType; - -typedef enum EncounterFrequencyType { - ENCOUNTER_FREQUENCY_TYPE_NONE, - ENCOUNTER_FREQUENCY_TYPE_RARE, - ENCOUNTER_FREQUENCY_TYPE_UNCOMMON, - ENCOUNTER_FREQUENCY_TYPE_COMMON, - ENCOUNTER_FREQUENCY_TYPE_FREQUENT, - ENCOUNTER_FREQUENCY_TYPE_FORCED, - ENCOUNTER_FREQUENCY_TYPE_COUNT, -} EncounterFrequencyType; - -typedef enum EncounterSceneryType { - ENCOUNTER_SCENERY_TYPE_NONE, - ENCOUNTER_SCENERY_TYPE_LIGHT, - ENCOUNTER_SCENERY_TYPE_NORMAL, - ENCOUNTER_SCENERY_TYPE_HEAVY, - ENCOUNTER_SCENERY_TYPE_COUNT, -} EncounterSceneryType; - -typedef enum EncounterSituation { - ENCOUNTER_SITUATION_NOTHING, - ENCOUNTER_SITUATION_AMBUSH, - ENCOUNTER_SITUATION_FIGHTING, - ENCOUNTER_SITUATION_AND, - ENCOUNTER_SITUATION_COUNT, -} EncounterSituation; - -typedef enum EncounterLogicalOperator { - ENCOUNTER_LOGICAL_OPERATOR_NONE, - ENCOUNTER_LOGICAL_OPERATOR_AND, - ENCOUNTER_LOGICAL_OPERATOR_OR, -} EncounterLogicalOperator; - -typedef enum EncounterConditionType { - ENCOUNTER_CONDITION_TYPE_NONE = 0, - ENCOUNTER_CONDITION_TYPE_GLOBAL = 1, - ENCOUNTER_CONDITION_TYPE_NUMBER_OF_CRITTERS = 2, - ENCOUNTER_CONDITION_TYPE_RANDOM = 3, - ENCOUNTER_CONDITION_TYPE_PLAYER = 4, - ENCOUNTER_CONDITION_TYPE_DAYS_PLAYED = 5, - ENCOUNTER_CONDITION_TYPE_TIME_OF_DAY = 6, -} EncounterConditionType; - -typedef enum EncounterConditionalOperator { - ENCOUNTER_CONDITIONAL_OPERATOR_NONE, - ENCOUNTER_CONDITIONAL_OPERATOR_EQUAL, - ENCOUNTER_CONDITIONAL_OPERATOR_NOT_EQUAL, - ENCOUNTER_CONDITIONAL_OPERATOR_LESS_THAN, - ENCOUNTER_CONDITIONAL_OPERATOR_GREATER_THAN, - ENCOUNTER_CONDITIONAL_OPERATOR_COUNT, -} EncounterConditionalOperator; - -typedef enum Daytime { - DAY_PART_MORNING, - DAY_PART_AFTERNOON, - DAY_PART_NIGHT, - DAY_PART_COUNT, -} Daytime; - typedef enum CityState { CITY_STATE_UNKNOWN, CITY_STATE_KNOWN, @@ -133,12 +21,6 @@ typedef enum CityState { CITY_STATE_INVISIBLE = -66, } CityState; -typedef enum SubtileState { - SUBTILE_STATE_UNKNOWN, - SUBTILE_STATE_KNOWN, - SUBTILE_STATE_VISITED, -} SubtileState; - typedef enum City { CITY_ARROYO, CITY_DEN, @@ -345,387 +227,11 @@ typedef enum Map { MAP_IN_GAME_MOVIE1 = 149, } Map; -typedef enum CitySize { - CITY_SIZE_SMALL, - CITY_SIZE_MEDIUM, - CITY_SIZE_LARGE, - CITY_SIZE_COUNT, -} CitySize; - -typedef struct EntranceInfo { - int state; - int x; - int y; - int map; - int elevation; - int tile; - int rotation; -} EntranceInfo; - -typedef struct CityInfo { - char name[CITY_NAME_SIZE]; - int field_28; - int x; - int y; - int size; - int state; - // lock state - int field_3C; - int field_40; - int mapFid; - int labelFid; - int entrancesLength; - EntranceInfo entrances[ENTRANCE_LIST_CAPACITY]; -} CityInfo; - -typedef struct MapAmbientSoundEffectInfo { - char name[40]; - int chance; -} MapAmbientSoundEffectInfo; - -typedef struct MapStartPointInfo { - int elevation; - int tile; - int field_8; -} MapStartPointInfo; - -typedef struct MapInfo { - char lookupName[40]; - int field_28; - int field_2C; - char mapFileName[40]; - char music[40]; - int flags; - int ambientSoundEffectsLength; - MapAmbientSoundEffectInfo ambientSoundEffects[MAP_AMBIENT_SOUND_EFFECTS_CAPACITY]; - int startPointsLength; - MapStartPointInfo startPoints[MAP_STARTING_POINTS_CAPACITY]; -} MapInfo; - -typedef struct Terrain { - char field_0[40]; - int field_28; - int mapsLength; - int maps[20]; -} Terrain; - -typedef struct EncounterConditionEntry { - int type; - int conditionalOperator; - int param; - int value; -} EncounterConditionEntry; - -typedef struct EncounterCondition { - int entriesLength; - EncounterConditionEntry entries[3]; - int logicalOperators[2]; -} EncounterCondition; - -typedef struct ENCOUNTER_ENTRY_ENC { - int minQuantity; // min - int maxQuantity; // max - int field_8; - int situation; -} ENCOUNTER_ENTRY_ENC; - -typedef struct EncounterEntry { - int flags; - int map; - int scenery; - int chance; - int counter; - EncounterCondition condition; - int field_50; - ENCOUNTER_ENTRY_ENC field_54[6]; -} EncounterEntry; - -typedef struct EncounterTable { - char lookupName[40]; - int field_28; - int mapsLength; - int maps[6]; - int field_48; - int entriesLength; - EncounterEntry entries[41]; -} EncounterTable; - -typedef struct ENC_BASE_TYPE_38_48 { - int pid; - int minimumQuantity; - int maximumQuantity; - bool isEquipped; -} ENC_BASE_TYPE_38_48; - -typedef struct ENC_BASE_TYPE_38 { - char field_0[40]; - int field_28; - int field_2C; - int ratio; - int pid; - int flags; - int distance; - int tile; - int itemsLength; - ENC_BASE_TYPE_38_48 items[10]; - int team; - int script; - EncounterCondition condition; -} ENC_BASE_TYPE_38; - -typedef struct ENC_BASE_TYPE { - char name[40]; - int position; - int spacing; - int distance; - int field_34; - ENC_BASE_TYPE_38 field_38[10]; -} ENC_BASE_TYPE; - -typedef struct SubtileInfo { - int terrain; - int field_4; - int encounterChance[DAY_PART_COUNT]; - int encounterType; - int state; -} SubtileInfo; - -// A worldmap tile is 7x6 area, thus consisting of 42 individual subtiles. -typedef struct TileInfo { - int fid; - CacheEntry* handle; - unsigned char* data; - char walkMaskName[TILE_WALK_MASK_NAME_SIZE]; - unsigned char* walkMaskData; - int encounterDifficultyModifier; - SubtileInfo subtiles[SUBTILE_GRID_HEIGHT][SUBTILE_GRID_WIDTH]; -} TileInfo; - -// -typedef struct CitySizeDescription { - int fid; - int width; - int height; - CacheEntry* handle; - unsigned char* data; -} CitySizeDescription; - -typedef enum WorldMapEncounterFrm { - WORLD_MAP_ENCOUNTER_FRM_RANDOM_BRIGHT, - WORLD_MAP_ENCOUNTER_FRM_RANDOM_DARK, - WORLD_MAP_ENCOUNTER_FRM_SPECIAL_BRIGHT, - WORLD_MAP_ENCOUNTER_FRM_SPECIAL_DARK, - WORLD_MAP_ENCOUNTER_FRM_COUNT, -} WorldMapEncounterFrm; - -typedef enum WorldmapArrowFrm { - WORLDMAP_ARROW_FRM_NORMAL, - WORLDMAP_ARROW_FRM_PRESSED, - WORLDMAP_ARROW_FRM_COUNT, -} WorldmapArrowFrm; - -extern const int _can_rest_here[ELEVATION_COUNT]; -extern const int gDayPartEncounterFrequencyModifiers[DAY_PART_COUNT]; -extern const char* off_4BC878[2]; -extern MessageListItem stru_4BC880; - -extern char _aCricket[]; -extern char _aCricket1[]; - -extern const char* _wmStateStrs[2]; -extern const char* _wmYesNoStrs[2]; -extern const char* gEncounterFrequencyTypeKeys[ENCOUNTER_FREQUENCY_TYPE_COUNT]; -extern const char* _wmFillStrs[9]; -extern const char* _wmSceneryStrs[ENCOUNTER_SCENERY_TYPE_COUNT]; -extern Terrain* gTerrains; -extern int gTerrainsLength; -extern TileInfo* gWorldmapTiles; -extern int gWorldmapTilesLength; -extern int gWorldmapGridWidth; -extern CityInfo* gCities; -extern int gCitiesLength; -extern const char* gCitySizeKeys[CITY_SIZE_COUNT]; -extern MapInfo* gMaps; -extern int gMapsLength; -extern int gWorldmapWindow; -extern CacheEntry* gWorldmapBoxFrmHandle; -extern int gWorldmapBoxFrmWidth; -extern int gWorldmapBoxFrmHeight; -extern unsigned char* gWorldmapWindowBuffer; -extern unsigned char* gWorldmapBoxFrmData; -extern int gWorldmapOffsetX; -extern int gWorldmapOffsetY; -extern unsigned char* _circleBlendTable; -extern int _wmInterfaceWasInitialized; -extern const char* _wmEncOpStrs[ENCOUNTER_SITUATION_COUNT]; -extern const char* _wmConditionalOpStrs[ENCOUNTER_CONDITIONAL_OPERATOR_COUNT]; -extern const char* gEncounterFormationTypeKeys[ENCOUNTER_FORMATION_TYPE_COUNT]; -extern int gWorldmapEncounterFrmIds[WORLD_MAP_ENCOUNTER_FRM_COUNT]; -extern int* gQuickDestinations; -extern int gQuickDestinationsLength; -extern int _wmTownMapCurArea; -extern unsigned int _wmLastRndTime; -extern int _wmRndIndex; -extern int _wmRndCallCount; -extern int _terrainCounter; -extern unsigned int _lastTime_2; -extern bool _couldScroll; -extern unsigned char* gWorldmapCurrentCityMapFrmData; -extern CacheEntry* gWorldmapCityMapFrmHandle; -extern int gWorldmapCityMapFrmWidth; -extern int gWorldmapCityMapFrmHeight; -extern char* _wmRemapSfxList[2]; - -extern int _wmRndTileDirs[2]; -extern int _wmRndCenterTiles[2]; -extern int _wmRndCenterRotations[2]; -extern int _wmRndRotOffsets[2]; -extern int _wmTownMapButtonId[ENTRANCE_LIST_CAPACITY]; -extern int _wmGenData; -extern int _Meet_Frank_Horrigan; -extern int _WorldMapCurrArea; -extern int _world_xpos; -extern int _world_ypos; -extern SubtileInfo* _world_subtile; -extern int dword_672E18; -extern bool gWorldmapIsTravelling; -extern int gWorldmapTravelDestX; -extern int gWorldmapTravelDestY; -extern int dword_672E28; -extern int dword_672E2C; -extern int dword_672E30; -extern int dword_672E34; -extern int _x_line_inc; -extern int dword_672E3C; -extern int _y_line_inc; -extern int dword_672E44; -extern int _wmEncounterIconShow; -extern int _EncounterMapID; -extern int dword_672E50; -extern int dword_672E54; -extern int _wmRndCursorFid; -extern int _old_world_xpos; -extern int _old_world_ypos; -extern bool gWorldmapIsInCar; -extern int _carCurrentArea; -extern int gWorldmapCarFuel; -extern CacheEntry* gWorldmapCarFrmHandle; -extern Art* gWorldmapCarFrm; -extern int gWorldmapCarFrmWidth; -extern int gWorldmapCarFrmHeight; -extern int gWorldmapCarFrmCurrentFrame; -extern CacheEntry* gWorldmapHotspotUpFrmHandle; -extern unsigned char* gWorldmapHotspotUpFrmData; -extern CacheEntry* gWorldmapHotspotDownFrmHandle; -extern unsigned char* gWorldmapHotspotDownFrmData; -extern int gWorldmapHotspotUpFrmWidth; -extern int gWorldmapHotspotUpFrmHeight; -extern CacheEntry* gWorldmapDestinationMarkerFrmHandle; -extern unsigned char* gWorldmapDestinationMarkerFrmData; -extern int gWorldmapDestinationMarkerFrmWidth; -extern int gWorldmapDestinationMarkerFrmHeight; -extern CacheEntry* gWorldmapLocationMarkerFrmHandle; -extern unsigned char* gWorldmapLocationMarkerFrmData; -extern int gWorldmapLocationMarkerFrmWidth; -extern int gWorldmapLocationMarkerFrmHeight; -extern CacheEntry* gWorldmapEncounterFrmHandles[WORLD_MAP_ENCOUNTER_FRM_COUNT]; -extern unsigned char* gWorldmapEncounterFrmData[WORLD_MAP_ENCOUNTER_FRM_COUNT]; -extern int gWorldmapEncounterFrmWidths[WORLD_MAP_ENCOUNTER_FRM_COUNT]; -extern int gWorldmapEncounterFrmHeights[WORLD_MAP_ENCOUNTER_FRM_COUNT]; -extern int _wmViewportRightScrlLimit; -extern int _wmViewportBottomtScrlLimit; -extern CacheEntry* gWorldmapTownTabsUnderlayFrmHandle; -extern int gWorldmapTownTabsUnderlayFrmWidth; -extern int gWorldmapTownTabsUnderlayFrmHeight; -extern int _LastTabsYOffset; -extern unsigned char* gWorldmapTownTabsUnderlayFrmData; -extern CacheEntry* gWorldmapTownTabsEdgeFrmHandle; -extern unsigned char* gWorldmapTownTabsEdgeFrmData; -extern CacheEntry* gWorldmapDialFrmHandle; -extern int gWorldmapDialWidth; -extern int gWorldmapDialHeight; -extern int gWorldmapDialFrmCurrentFrame; -extern Art* gWorldmapDialFrm; -extern CacheEntry* gWorldmapCarOverlayFrmHandle; -extern int gWorldmapCarOverlayFrmWidth; -extern int gWorldmapCarOverlayFrmHeight; -extern unsigned char* gWorldmapOverlayFrmData; -extern CacheEntry* gWorldmapGlobeOverlayFrmHandle; -extern int gWorldmapGlobeOverlayFrmWidth; -extern int gWorldmapGloveOverlayFrmHeight; -extern unsigned char* gWorldmapGlobeOverlayFrmData; -extern int dword_672F54; -extern int _tabsOffset; -extern CacheEntry* gWorldmapLittleRedButtonUpFrmHandle; -extern CacheEntry* gWorldmapLittleRedButtonDownFrmHandle; -extern unsigned char* gWorldmapLittleRedButtonUpFrmData; -extern unsigned char* gWorldmapLittleRedButtonDownFrmData; -extern CacheEntry* gWorldmapTownListScrollUpFrmHandle[2]; -extern int gWorldmapTownListScrollUpFrmWidth; -extern int gWorldmapTownListScrollUpFrmHeight; -extern unsigned char* gWorldmapTownListScrollUpFrmData[2]; -extern CacheEntry* gWorldmapTownListScrollDownFrmHandle[2]; -extern int gWorldmapTownListScrollDownFrmWidth; -extern int gWorldmapTownListScrollDownFrmHeight; -extern unsigned char* gWorldmapTownListScrollDownFrmData[2]; -extern CacheEntry* gWorldmapMonthsFrmHandle; -extern Art* gWorldmapMonthsFrm; -extern CacheEntry* gWorldmapNumbersFrmHandle; -extern Art* gWorldmapNumbersFrm; -extern int _fontnum; -extern MessageList gWorldmapMessageList; -extern int _wmFreqValues[6]; -extern int _wmRndOriginalCenterTile; -extern Config* gWorldmapConfig; -extern int _wmTownMapSubButtonIds[7]; -extern ENC_BASE_TYPE* _wmEncBaseTypeList; -extern CitySizeDescription gCitySizeDescriptions[CITY_SIZE_COUNT]; -extern EncounterTable* gEncounterTables; -extern int _wmMaxEncBaseTypes; -extern int gEncounterTablesLength; - int worldmapInit(); -int _wmGenDataInit(); -int _wmGenDataReset(); void worldmapExit(); int worldmapReset(); int worldmapSave(File* stream); int worldmapLoad(File* stream); -int _wmWorldMapSaveTempData(); -int _wmWorldMapLoadTempData(); -int worldmapConfigInit(); -int worldmapConfigLoadEncounterTable(Config* config, char* lookup_name, char* section); -int worldmapConfigLoadEncounterEntry(EncounterEntry* entry, char* str); -int _wmParseEncounterSubEncStr(EncounterEntry* entry, char** str_ptr); -int _wmParseFindSubEncTypeMatch(char* str, int* out_value); -int _wmFindEncBaseTypeMatch(char* str, int* out_value); -int _wmReadEncBaseType(char* str, int* out_value); -int _wmParseEncBaseSubTypeStr(ENC_BASE_TYPE_38* ptr, char** str_ptr); -int _wmEncBaseTypeSlotInit(ENC_BASE_TYPE* entry); -int _wmEncBaseSubTypeSlotInit(ENC_BASE_TYPE_38* entry); -int _wmEncounterSubEncSlotInit(ENCOUNTER_ENTRY_ENC* entry); -int worldmapEncounterTableEntryInit(EncounterEntry* entry); -int worldmapEncounterTableInit(EncounterTable* encounterTable); -int worldmapTileInfoInit(TileInfo* tile); -int worldmapTerrainInfoInit(Terrain* terrain); -int worldmapConfigInitEncounterCondition(EncounterCondition* condition); -int _wmParseTerrainTypes(Config* config, char* str); -int _wmParseTerrainRndMaps(Config* config, Terrain* terrain); -int worldmapConfigLoadSubtile(TileInfo* tile, int x, int y, char* str); -int worldmapFindEncounterTableByLookupName(char* str, int* out_value); -int worldmapFindTerrainByLookupName(char* str, int* out_value); -int _wmParseEncounterItemType(char** str_ptr, ENC_BASE_TYPE_38_48* a2, int* a3, const char* delim); -int _wmParseItemType(char* str, ENC_BASE_TYPE_38_48* ptr); -int worldmapConfigParseCondition(char** stringPtr, const char* a2, EncounterCondition* condition); -int worldmapConfigParseConditionEntry(char** stringPtr, const char* a2, int* typePtr, int* operatorPtr, int* paramPtr, int* valuePtr); -int worldmapConfigParseEncounterConditionalOperator(char** str_ptr, int* out_op); -int worldmapCityInfoInit(CityInfo* area); -int cityInit(); -int worldmapFindMapByLookupName(char* str, int* out_value); -int worldmapCityEntranceInfoInit(EntranceInfo* entrance); -int worldmapMapInfoInit(MapInfo* map); -int _wmMapInit(); -int worldmapRandomStartingPointInit(MapStartPointInfo* rsp); int mapGetCount(); int mapGetFileName(int map_index, char* dest); int mapGetIndexByFileName(char* name); @@ -735,51 +241,13 @@ bool _wmMapDeadBodiesAge(); bool _wmMapCanRestHere(int elevation); bool _wmMapPipboyActive(); int _wmMapMarkVisited(int map_index); -int _wmMatchEntranceFromMap(int cityIndex, int mapIndex, int* entranceIndexPtr); -int _wmMatchEntranceElevFromMap(int cityIndex, int map, int elevation, int* entranceIndexPtr); -int _wmMatchAreaFromMap(int a1, int* out_a2); int _wmMapMarkMapEntranceState(int a1, int a2, int a3); void _wmWorldMap(); -int _wmWorldMapFunc(int a1); int _wmCheckGameAreaEvents(); -int _wmInterfaceCenterOnParty(); -int _wmRndEncounterOccurred(); -int _wmPartyFindCurSubTile(); -int _wmFindCurSubTileFromPos(int x, int y, SubtileInfo** subtile); -int _wmFindCurTileFromPos(int x, int y, TileInfo** tile); -int _wmRndEncounterPick(); int worldmapSetupRandomEncounter(); -int worldmapSetupRandomEncounter(); -int worldmapSetupCritters(int type_idx, Object** out_critter, int a3); -int _wmSetupRndNextTileNumInit(ENC_BASE_TYPE* a1); -int _wmSetupRndNextTileNum(ENC_BASE_TYPE* a1, ENC_BASE_TYPE_38* a2, int* out_tile_num); bool _wmEvalTileNumForPlacement(int tile); -bool _wmEvalConditional(EncounterCondition* a1, int* a2); -bool _wmEvalSubConditional(int a1, int a2, int a3); -bool _wmGameTimeIncrement(int a1); -int _wmGrabTileWalkMask(int tile_index); -bool _wmWorldPosInvalid(int a1, int a2); -void _wmPartyInitWalking(int x, int y); -void worldmapPerformTravel(); -void _wmInterfaceScrollTabsStart(int a1); -void _wmInterfaceScrollTabsStop(); -int worldmapWindowInit(); -int worldmapWindowFree(); -int worldmapWindowScroll(int a1, int a2, int a3, int a4, bool* a5, bool a6); -void worldmapWindowHandleMouseScrolling(); -int _wmMarkSubTileOffsetVisitedFunc(int a1, int a2, int a3, int a4, int a5, int a6); -void _wmMarkSubTileRadiusVisited(int x, int y); int _wmSubTileMarkRadiusVisited(int x, int y, int radius); int _wmSubTileGetVisitedState(int a1, int a2, int* a3); -int _wmTileGrabArt(int tile_index); -int worldmapWindowRefresh(); -void worldmapWindowRenderDate(bool shouldRefreshWindow); -int _wmMatchWorldPosToArea(int a1, int a2, int* a3); -int worldmapWindowRenderCity(CityInfo* cityInfo, CitySizeDescription* citySizeInfo, unsigned char* buffer, int x, int y); -void worldmapWindowDimRect(unsigned char* dest, int width, int height, int pitch); -int worldmapWindowDimSubtile(TileInfo* tileInfo, int a2, int a3, int a4, int a5, int a6); -int _wmDrawCursorStopped(); -bool _wmCursorIsVisible(); int _wmGetAreaIdxName(int index, char* name); bool _wmAreaIsKnown(int city_index); int _wmAreaVisitedState(int a1); @@ -789,13 +257,7 @@ bool _wmAreaSetVisibleState(int a1, int a2, int a3); int worldmapCitySetPos(int index, int x, int y); int _wmGetPartyWorldPos(int* out_x, int* out_y); int _wmGetPartyCurArea(int* a1); -void _wmMarkAllSubTiles(int a1); void _wmTownMap(); -int worldmapCityMapViewSelect(int* mapIndexPtr); -int worldmapCityMapViewInit(); -int worldmapCityMapViewRefresh(); -int worldmapCityMapViewFree(); -int carConsumeFuel(int a1); int carAddFuel(int a1); int carGetFuel(); bool carIsEmpty(); @@ -804,21 +266,9 @@ int _wmCarGiveToParty(); int ambientSoundEffectGetLength(); int ambientSoundEffectGetRandom(); int ambientSoundEffectGetName(int ambientSoundEffectIndex, char** namePtr); -int worldmapWindowRenderChrome(bool shouldRefreshWindow); -void worldmapWindowRenderCarFuelBar(); -int worldmapRenderQuickDestinations(); -int _wmMakeTabsLabelList(int** out_cities, int* out_len); -int worldmapCompareCitiesByName(const void* a1, const void* a2); -void worldmapWindowRenderDial(bool shouldRefreshWindow); -int _wmAreaFindFirstValidMap(int* out_a1); int worldmapStartMapMusic(); int worldmapSetMapMusic(int a1, const char* name); int _wmMatchAreaContainingMapIdx(int map_index, int* out_city_index); int _wmTeleportToArea(int a1); -static inline bool cityIsValid(int city) -{ - return city >= 0 && city < gCitiesLength; -} - #endif /* WORLD_MAP_H */