first commit

This commit is contained in:
murdle
2026-03-01 02:38:58 +02:00
commit 19250b9db4
19111 changed files with 4358159 additions and 0 deletions

View File

@@ -0,0 +1,130 @@
#pragma once
// 4J Stu - For non-splitscreen menus, default to this screen
#define DEFAULT_XUI_MENU_USER 0
#define MULTITHREAD_ENABLE
#define MAX_CAPENAME_SIZE 32
#define MAX_BANNERNAME_SIZE 32
#define MAX_TMSFILENAME_SIZE 40
#define MAX_TYPE_SIZE 32
#define MAX_EXTENSION_TYPES 3
#ifdef __PSVITA__
#define MAX_LOCAL_PLAYERS 1
#else
#define MAX_LOCAL_PLAYERS 4
#endif
// 4J Stu - Required for sentient reporting of whether the volume level has been changed or not
#define DEFAULT_VOLUME_LEVEL 100
#define GAME_HOST_OPTION_BITMASK_DIFFICULTY 0x00000003 // 0 - 3
#define GAME_HOST_OPTION_BITMASK_FRIENDSOFFRIENDS 0x00000004
#define GAME_HOST_OPTION_BITMASK_GAMERTAGS 0x00000008
#define GAME_HOST_OPTION_BITMASK_GAMETYPE 0x00000030
#define GAME_HOST_OPTION_BITMASK_LEVELTYPE 0x00000040
#define GAME_HOST_OPTION_BITMASK_STRUCTURES 0x00000080
#define GAME_HOST_OPTION_BITMASK_BONUSCHEST 0x00000100
#define GAME_HOST_OPTION_BITMASK_BEENINCREATIVE 0x00000200
#define GAME_HOST_OPTION_BITMASK_PVP 0x00000400
#define GAME_HOST_OPTION_BITMASK_TRUSTPLAYERS 0x00000800
#define GAME_HOST_OPTION_BITMASK_TNT 0x00001000
#define GAME_HOST_OPTION_BITMASK_FIRESPREADS 0x00002000
#define GAME_HOST_OPTION_BITMASK_HOSTFLY 0x00004000
#define GAME_HOST_OPTION_BITMASK_HOSTHUNGER 0x00008000
#define GAME_HOST_OPTION_BITMASK_HOSTINVISIBLE 0x00010000
#define GAME_HOST_OPTION_BITMASK_BEDROCKFOG 0x00020000
#define GAME_HOST_OPTION_BITMASK_DISABLESAVE 0x00040000
#define GAME_HOST_OPTION_BITMASK_ALL 0xFFFFFFFF
#ifdef _XBOX
#define PROFILE_VERSION_1 1
#define PROFILE_VERSION_2 2
#define PROFILE_VERSION_3 3
#define PROFILE_VERSION_4 4
#define PROFILE_VERSION_5 6
#define PROFILE_VERSION_6 7
#define PROFILE_VERSION_7 8
#endif
#define PROFILE_VERSION_8 10
#define PROFILE_VERSION_9 11
#define PROFILE_VERSION_10 12
// 4J-JEV: New Statistics and Achievements for 'NexGen' platforms.
#define PROFILE_VERSION_BUILD_JUNE14 13
#define MAX_FAVORITE_SKINS 10 // these are stored in the profile data so keep it small
// defines for game settings - uiBitmaskValues
#define GAMESETTING_CLOUDS 0x00000001
#define GAMESETTING_ONLINE 0x00000002
#define GAMESETTING_INVITEONLY 0x00000004
#define GAMESETTING_FRIENDSOFFRIENDS 0x00000008
#define GAMESETTING_DISPLAYUPDATEMSG 0x00000030
#define GAMESETTING_BEDROCKFOG 0x00000040
#define GAMESETTING_DISPLAYHUD 0x00000080
#define GAMESETTING_DISPLAYHAND 0x00000100
#define GAMESETTING_CUSTOMSKINANIM 0x00000200
#define GAMESETTING_DEATHMESSAGES 0x00000400
#define GAMESETTING_UISIZE 0x00001800
#define GAMESETTING_UISIZE_SPLITSCREEN 0x00006000
#define GAMESETTING_ANIMATEDCHARACTER 0x00008000
#define GAMESETTING_PS3EULAREAD 0x00010000
#define GAMESETTING_PSVITANETWORKMODEADHOC 0x00020000
// defines for languages
#define MINECRAFT_LANGUAGE_DEFAULT 0x00
#define MINECRAFT_LANGUAGE_ENGLISH 0x01
#define MINECRAFT_LANGUAGE_JAPANESE 0x02
#define MINECRAFT_LANGUAGE_GERMAN 0x03
#define MINECRAFT_LANGUAGE_FRENCH 0x04
#define MINECRAFT_LANGUAGE_SPANISH 0x05
#define MINECRAFT_LANGUAGE_ITALIAN 0x06
#define MINECRAFT_LANGUAGE_KOREAN 0x07
#define MINECRAFT_LANGUAGE_TCHINESE 0x08
#define MINECRAFT_LANGUAGE_PORTUGUESE 0x09
#define MINECRAFT_LANGUAGE_BRAZILIAN 0x0A
#define MINECRAFT_LANGUAGE_RUSSIAN 0x0B
#define MINECRAFT_LANGUAGE_DUTCH 0x0C
#define MINECRAFT_LANGUAGE_FINISH 0x0D
#define MINECRAFT_LANGUAGE_SWEDISH 0x0E
#define MINECRAFT_LANGUAGE_DANISH 0x0F
#define MINECRAFT_LANGUAGE_NORWEGIAN 0x10
#define MINECRAFT_LANGUAGE_POLISH 0x11
#define MINECRAFT_LANGUAGE_TURKISH 0x12
#define MINECRAFT_LANGUAGE_LATINAMERICANSPANISH 0x13
#define MINECRAFT_LANGUAGE_GREEK 0x14
/* Match these
const int XC_LANGUAGE_ENGLISH =1;
const int XC_LANGUAGE_JAPANESE =2;
const int XC_LANGUAGE_GERMAN =3;
const int XC_LANGUAGE_FRENCH =4;
const int XC_LANGUAGE_SPANISH =5;
const int XC_LANGUAGE_ITALIAN =6;
const int XC_LANGUAGE_KOREAN =7;
const int XC_LANGUAGE_TCHINESE =8;
const int XC_LANGUAGE_PORTUGUESE =9;
const int XC_LANGUAGE_BRAZILIAN =10;
const int XC_LANGUAGE_RUSSIAN =11;
const int XC_LANGUAGE_DUTCH =12;
const int XC_LANGUAGE_FINISH =13;
const int XC_LANGUAGE_SWEDISH =14;
const int XC_LANGUAGE_DANISH =15;
const int XC_LANGUAGE_NORWEGIAN =16;
const int XC_LANGUAGE_POLISH =17;
const int XC_LANGUAGE_TURKISH =18;
const int XC_LANGUAGE_LATINAMERICANSPANISH =19;
const int XC_LANGUAGE_GREEK =20;
*/

View File

@@ -0,0 +1,913 @@
#pragma once
enum eFileExtensionType
{
eFileExtensionType_PNG=0,
eFileExtensionType_INF,
eFileExtensionType_DAT,
};
enum eTMSFileType
{
eTMSFileType_MinecraftStore=0,
eTMSFileType_TexturePack,
eTMSFileType_All
};
enum eTPDFileType
{
eTPDFileType_Loc=0,
eTPDFileType_Icon,
// eTPDFileType_Banner,
eTPDFileType_Comparison,
};
enum eFont
{
eFont_European=0,
eFont_Korean,
eFont_Japanese,
eFont_Chinese,
eFont_None, // to fallback to nothing
};
enum eXuiAction
{
eAppAction_Idle=0,
eAppAction_SaveGame,
eAppAction_SaveGameCapturedThumbnail,
eAppAction_ExitWorld,
eAppAction_ExitWorldCapturedThumbnail,
eAppAction_ExitWorldTrial,
//eAppAction_ExitGameFatalLoadError,
eAppAction_Respawn,
eAppAction_WaitForRespawnComplete,
eAppAction_PrimaryPlayerSignedOut,
eAppAction_PrimaryPlayerSignedOutReturned,
eAppAction_PrimaryPlayerSignedOutReturned_Menus,
eAppAction_ExitPlayer, // secondary player
eAppAction_ExitPlayerPreLogin,
eAppAction_TrialOver,
eAppAction_ExitTrial,
eAppAction_WaitForDimensionChangeComplete,
eAppAction_SocialPost,
eAppAction_SocialPostScreenshot,
eAppAction_EthernetDisconnected,
eAppAction_EthernetDisconnectedReturned,
eAppAction_EthernetDisconnectedReturned_Menus,
eAppAction_ExitAndJoinFromInvite,
eAppAction_DashboardTrialJoinFromInvite,
eAppAction_ExitAndJoinFromInviteConfirmed,
eAppAction_JoinFromInvite,
eAppAction_ChangeSessionType,
eAppAction_SetDefaultOptions,
eAppAction_LocalPlayerJoined,
eAppAction_RemoteServerSave,
eAppAction_WaitRemoteServerSaveComplete,
eAppAction_FailedToJoinNoPrivileges,
eAppAction_AutosaveSaveGame,
eAppAction_AutosaveSaveGameCapturedThumbnail,
eAppAction_ProfileReadError,
eAppAction_DisplayLavaMessage,
eAppAction_BanLevel,
eAppAction_LevelInBanLevelList,
eAppAction_ReloadTexturePack,
eAppAction_TexturePackRequired, // when the user has joined from invite, but doesn't have the texture pack
#ifdef __ORBIS__
eAppAction_OptionsSaveNoSpace,
#endif
eAppAction_DebugText,
};
enum eTMSAction
{
eTMSAction_Idle=0,
eTMSAction_TMS_RetrieveFiles_Complete,
eTMSAction_TMSPP_RetrieveFiles_CreateLoad_SignInReturned,
eTMSAction_TMSPP_RetrieveFiles_RunPlayGame,
eTMSAction_TMSPP_RetrieveFiles_HelpAndOptions,
eTMSAction_TMSPP_RetrieveFiles_DLCMain,
eTMSAction_TMSPP_GlobalFileList,
eTMSAction_TMSPP_GlobalFileList_Waiting,
// eTMSAction_TMSPP_ConfigFile,
// eTMSAction_TMSPP_ConfigFile_Waiting,
eTMSAction_TMSPP_UserFileList,
eTMSAction_TMSPP_UserFileList_Waiting,
eTMSAction_TMSPP_XUIDSFile,
eTMSAction_TMSPP_XUIDSFile_Waiting,
eTMSAction_TMSPP_DLCFile,
eTMSAction_TMSPP_DLCFile_Waiting,
eTMSAction_TMSPP_BannedListFile,
eTMSAction_TMSPP_BannedListFile_Waiting,
eTMSAction_TMSPP_RetrieveFiles_Complete,
eTMSAction_TMSPP_DLCFileOnly,
eTMSAction_TMSPP_RetrieveUserFilelist_DLCFileOnly,
};
// The server runs on its own thread, so we need to call its actions there rather than where all other Xui actions are performed
// In general these are debugging options
enum eXuiServerAction
{
eXuiServerAction_Idle=0,
eXuiServerAction_DropItem, // Debug
eXuiServerAction_SaveGame,
eXuiServerAction_AutoSaveGame,
eXuiServerAction_SpawnMob, // Debug
eXuiServerAction_PauseServer,
eXuiServerAction_ToggleRain, // Debug
eXuiServerAction_ToggleThunder, // Debug
eXuiServerAction_ServerSettingChanged_Gamertags,
eXuiServerAction_ServerSettingChanged_Difficulty,
eXuiServerAction_ExportSchematic, //Debug
eXuiServerAction_ServerSettingChanged_BedrockFog,
eXuiServerAction_SetCameraLocation, //Debug
};
enum eGameSetting
{
eGameSetting_MusicVolume=0,
eGameSetting_SoundFXVolume,
eGameSetting_Gamma,
eGameSetting_Difficulty,
eGameSetting_Sensitivity_InGame,
eGameSetting_Sensitivity_InMenu,
eGameSetting_ViewBob,
eGameSetting_ControlScheme,
eGameSetting_ControlInvertLook,
eGameSetting_ControlSouthPaw,
eGameSetting_SplitScreenVertical,
eGameSetting_GamertagsVisible,
// Interim TU 1.6.6
eGameSetting_Autosave,
eGameSetting_DisplaySplitscreenGamertags,
eGameSetting_Hints,
eGameSetting_InterfaceOpacity,
eGameSetting_Tooltips,
// TU5
eGameSetting_Clouds,
eGameSetting_Online,
eGameSetting_InviteOnly,
eGameSetting_FriendsOfFriends,
eGameSetting_DisplayUpdateMessage,
// TU6
eGameSetting_BedrockFog,
eGameSetting_DisplayHUD,
eGameSetting_DisplayHand,
// TU7
eGameSetting_CustomSkinAnim,
// TU9
eGameSetting_DeathMessages,
eGameSetting_UISize,
eGameSetting_UISizeSplitscreen,
eGameSetting_AnimatedCharacter,
// PS3
eGameSetting_PS3_EULA_Read,
// PSVita
eGameSetting_PSVita_NetworkModeAdhoc,
};
enum eGameMode
{
eMode_Singleplayer,
eMode_Multiplayer
};
enum eMinecraftColour
{
eMinecraftColour_NOT_SET,
eMinecraftColour_Foliage_Evergreen,
eMinecraftColour_Foliage_Birch,
eMinecraftColour_Foliage_Default,
eMinecraftColour_Foliage_Common,
eMinecraftColour_Foliage_Ocean,
eMinecraftColour_Foliage_Plains,
eMinecraftColour_Foliage_Desert,
eMinecraftColour_Foliage_ExtremeHills,
eMinecraftColour_Foliage_Forest,
eMinecraftColour_Foliage_Taiga,
eMinecraftColour_Foliage_Swampland,
eMinecraftColour_Foliage_River,
eMinecraftColour_Foliage_Hell,
eMinecraftColour_Foliage_Sky,
eMinecraftColour_Foliage_FrozenOcean,
eMinecraftColour_Foliage_FrozenRiver,
eMinecraftColour_Foliage_IcePlains,
eMinecraftColour_Foliage_IceMountains,
eMinecraftColour_Foliage_MushroomIsland,
eMinecraftColour_Foliage_MushroomIslandShore,
eMinecraftColour_Foliage_Beach,
eMinecraftColour_Foliage_DesertHills,
eMinecraftColour_Foliage_ForestHills,
eMinecraftColour_Foliage_TaigaHills,
eMinecraftColour_Foliage_ExtremeHillsEdge,
eMinecraftColour_Foliage_Jungle,
eMinecraftColour_Foliage_JungleHills,
eMinecraftColour_Grass_Common,
eMinecraftColour_Grass_Ocean,
eMinecraftColour_Grass_Plains,
eMinecraftColour_Grass_Desert,
eMinecraftColour_Grass_ExtremeHills,
eMinecraftColour_Grass_Forest,
eMinecraftColour_Grass_Taiga,
eMinecraftColour_Grass_Swampland,
eMinecraftColour_Grass_River,
eMinecraftColour_Grass_Hell,
eMinecraftColour_Grass_Sky,
eMinecraftColour_Grass_FrozenOcean,
eMinecraftColour_Grass_FrozenRiver,
eMinecraftColour_Grass_IcePlains,
eMinecraftColour_Grass_IceMountains,
eMinecraftColour_Grass_MushroomIsland,
eMinecraftColour_Grass_MushroomIslandShore,
eMinecraftColour_Grass_Beach,
eMinecraftColour_Grass_DesertHills,
eMinecraftColour_Grass_ForestHills,
eMinecraftColour_Grass_TaigaHills,
eMinecraftColour_Grass_ExtremeHillsEdge,
eMinecraftColour_Grass_Jungle,
eMinecraftColour_Grass_JungleHills,
eMinecraftColour_Water_Ocean,
eMinecraftColour_Water_Plains,
eMinecraftColour_Water_Desert,
eMinecraftColour_Water_ExtremeHills,
eMinecraftColour_Water_Forest,
eMinecraftColour_Water_Taiga,
eMinecraftColour_Water_Swampland,
eMinecraftColour_Water_River,
eMinecraftColour_Water_Hell,
eMinecraftColour_Water_Sky,
eMinecraftColour_Water_FrozenOcean,
eMinecraftColour_Water_FrozenRiver,
eMinecraftColour_Water_IcePlains,
eMinecraftColour_Water_IceMountains,
eMinecraftColour_Water_MushroomIsland,
eMinecraftColour_Water_MushroomIslandShore,
eMinecraftColour_Water_Beach,
eMinecraftColour_Water_DesertHills,
eMinecraftColour_Water_ForestHills,
eMinecraftColour_Water_TaigaHills,
eMinecraftColour_Water_ExtremeHillsEdge,
eMinecraftColour_Water_Jungle,
eMinecraftColour_Water_JungleHills,
eMinecraftColour_Sky_Ocean,
eMinecraftColour_Sky_Plains,
eMinecraftColour_Sky_Desert,
eMinecraftColour_Sky_ExtremeHills,
eMinecraftColour_Sky_Forest,
eMinecraftColour_Sky_Taiga,
eMinecraftColour_Sky_Swampland,
eMinecraftColour_Sky_River,
eMinecraftColour_Sky_Hell,
eMinecraftColour_Sky_Sky,
eMinecraftColour_Sky_FrozenOcean,
eMinecraftColour_Sky_FrozenRiver,
eMinecraftColour_Sky_IcePlains,
eMinecraftColour_Sky_IceMountains,
eMinecraftColour_Sky_MushroomIsland,
eMinecraftColour_Sky_MushroomIslandShore,
eMinecraftColour_Sky_Beach,
eMinecraftColour_Sky_DesertHills,
eMinecraftColour_Sky_ForestHills,
eMinecraftColour_Sky_TaigaHills,
eMinecraftColour_Sky_ExtremeHillsEdge,
eMinecraftColour_Sky_Jungle,
eMinecraftColour_Sky_JungleHills,
eMinecraftColour_Tile_RedstoneDust,
eMinecraftColour_Tile_RedstoneDustUnlit,
eMinecraftColour_Tile_RedstoneDustLitMin,
eMinecraftColour_Tile_RedstoneDustLitMax,
eMinecraftColour_Tile_StemMin,
eMinecraftColour_Tile_StemMax,
eMinecraftColour_Tile_WaterLily,
eMinecraftColour_Sky_Dawn_Dark,
eMinecraftColour_Sky_Dawn_Bright,
eMinecraftColour_Material_None,
eMinecraftColour_Material_Grass,
eMinecraftColour_Material_Sand,
eMinecraftColour_Material_Cloth,
eMinecraftColour_Material_Fire,
eMinecraftColour_Material_Ice,
eMinecraftColour_Material_Metal,
eMinecraftColour_Material_Plant,
eMinecraftColour_Material_Snow,
eMinecraftColour_Material_Clay,
eMinecraftColour_Material_Dirt,
eMinecraftColour_Material_Stone,
eMinecraftColour_Material_Water,
eMinecraftColour_Material_Wood,
eMinecraftColour_Material_Emerald,
eMinecraftColour_Particle_Note_00,
eMinecraftColour_Particle_Note_01,
eMinecraftColour_Particle_Note_02,
eMinecraftColour_Particle_Note_03,
eMinecraftColour_Particle_Note_04,
eMinecraftColour_Particle_Note_05,
eMinecraftColour_Particle_Note_06,
eMinecraftColour_Particle_Note_07,
eMinecraftColour_Particle_Note_08,
eMinecraftColour_Particle_Note_09,
eMinecraftColour_Particle_Note_10,
eMinecraftColour_Particle_Note_11,
eMinecraftColour_Particle_Note_12,
eMinecraftColour_Particle_Note_13,
eMinecraftColour_Particle_Note_14,
eMinecraftColour_Particle_Note_15,
eMinecraftColour_Particle_Note_16,
eMinecraftColour_Particle_Note_17,
eMinecraftColour_Particle_Note_18,
eMinecraftColour_Particle_Note_19,
eMinecraftColour_Particle_Note_20,
eMinecraftColour_Particle_Note_21,
eMinecraftColour_Particle_Note_22,
eMinecraftColour_Particle_Note_23,
eMinecraftColour_Particle_Note_24,
eMinecraftColour_Particle_NetherPortal,
eMinecraftColour_Particle_EnderPortal,
eMinecraftColour_Particle_Smoke,
eMinecraftColour_Particle_Ender,
eMinecraftColour_Particle_Explode,
eMinecraftColour_Particle_HugeExplosion,
eMinecraftColour_Particle_DripWater,
eMinecraftColour_Particle_DripLavaStart,
eMinecraftColour_Particle_DripLavaEnd,
eMinecraftColour_Particle_EnchantmentTable,
eMinecraftColour_Particle_DragonBreathMin,
eMinecraftColour_Particle_DragonBreathMax,
eMinecraftColour_Particle_Suspend,
eMinecraftColour_Particle_CritStart,
eMinecraftColour_Particle_CritEnd,
eMinecraftColour_Effect_MovementSpeed,
eMinecraftColour_Effect_MovementSlowDown,
eMinecraftColour_Effect_DigSpeed,
eMinecraftColour_Effect_DigSlowdown,
eMinecraftColour_Effect_DamageBoost,
eMinecraftColour_Effect_Heal,
eMinecraftColour_Effect_Harm,
eMinecraftColour_Effect_Jump,
eMinecraftColour_Effect_Confusion,
eMinecraftColour_Effect_Regeneration,
eMinecraftColour_Effect_DamageResistance,
eMinecraftColour_Effect_FireResistance,
eMinecraftColour_Effect_WaterBreathing,
eMinecraftColour_Effect_Invisiblity,
eMinecraftColour_Effect_Blindness,
eMinecraftColour_Effect_NightVision,
eMinecraftColour_Effect_Hunger,
eMinecraftColour_Effect_Weakness,
eMinecraftColour_Effect_Poison,
eMinecraftColour_Potion_BaseColour,
eMinecraftColour_Mob_Creeper_Colour1,
eMinecraftColour_Mob_Creeper_Colour2,
eMinecraftColour_Mob_Skeleton_Colour1,
eMinecraftColour_Mob_Skeleton_Colour2,
eMinecraftColour_Mob_Spider_Colour1,
eMinecraftColour_Mob_Spider_Colour2,
eMinecraftColour_Mob_Zombie_Colour1,
eMinecraftColour_Mob_Zombie_Colour2,
eMinecraftColour_Mob_Slime_Colour1,
eMinecraftColour_Mob_Slime_Colour2,
eMinecraftColour_Mob_Ghast_Colour1,
eMinecraftColour_Mob_Ghast_Colour2,
eMinecraftColour_Mob_PigZombie_Colour1,
eMinecraftColour_Mob_PigZombie_Colour2,
eMinecraftColour_Mob_Enderman_Colour1,
eMinecraftColour_Mob_Enderman_Colour2,
eMinecraftColour_Mob_CaveSpider_Colour1,
eMinecraftColour_Mob_CaveSpider_Colour2,
eMinecraftColour_Mob_Silverfish_Colour1,
eMinecraftColour_Mob_Silverfish_Colour2,
eMinecraftColour_Mob_Blaze_Colour1,
eMinecraftColour_Mob_Blaze_Colour2,
eMinecraftColour_Mob_LavaSlime_Colour1,
eMinecraftColour_Mob_LavaSlime_Colour2,
eMinecraftColour_Mob_Pig_Colour1,
eMinecraftColour_Mob_Pig_Colour2,
eMinecraftColour_Mob_Sheep_Colour1,
eMinecraftColour_Mob_Sheep_Colour2,
eMinecraftColour_Mob_Cow_Colour1,
eMinecraftColour_Mob_Cow_Colour2,
eMinecraftColour_Mob_Chicken_Colour1,
eMinecraftColour_Mob_Chicken_Colour2,
eMinecraftColour_Mob_Squid_Colour1,
eMinecraftColour_Mob_Squid_Colour2,
eMinecraftColour_Mob_Wolf_Colour1,
eMinecraftColour_Mob_Wolf_Colour2,
eMinecraftColour_Mob_MushroomCow_Colour1,
eMinecraftColour_Mob_MushroomCow_Colour2,
eMinecraftColour_Mob_Ocelot_Colour1,
eMinecraftColour_Mob_Ocelot_Colour2,
eMinecraftColour_Mob_Villager_Colour1,
eMinecraftColour_Mob_Villager_Colour2,
eMinecraftColour_Armour_Default_Leather_Colour,
eMinecraftColour_Under_Water_Clear_Colour,
eMinecraftColour_Under_Lava_Clear_Colour,
eMinecraftColour_In_Cloud_Base_Colour,
eMinecraftColour_Under_Water_Fog_Colour,
eMinecraftColour_Under_Lava_Fog_Colour,
eMinecraftColour_In_Cloud_Fog_Colour,
eMinecraftColour_Default_Fog_Colour,
eMinecraftColour_Nether_Fog_Colour,
eMinecraftColour_End_Fog_Colour,
eMinecraftColour_Sign_Text,
eMinecraftColour_Map_Text,
eHTMLColor_0,
eHTMLColor_1,
eHTMLColor_2,
eHTMLColor_3,
eHTMLColor_4,
eHTMLColor_5,
eHTMLColor_6,
eHTMLColor_7,
eHTMLColor_8,
eHTMLColor_9,
eHTMLColor_a,
eHTMLColor_b,
eHTMLColor_c,
eHTMLColor_d,
eHTMLColor_e,
eHTMLColor_f,
eHTMLColor_0_dark,
eHTMLColor_1_dark,
eHTMLColor_2_dark,
eHTMLColor_3_dark,
eHTMLColor_4_dark,
eHTMLColor_5_dark,
eHTMLColor_6_dark,
eHTMLColor_7_dark,
eHTMLColor_8_dark,
eHTMLColor_9_dark,
eHTMLColor_a_dark,
eHTMLColor_b_dark,
eHTMLColor_c_dark,
eHTMLColor_d_dark,
eHTMLColor_e_dark,
eHTMLColor_f_dark,
eHTMLColor_T1,
eHTMLColor_T2,
eHTMLColor_T3,
eHTMLColor_Black,
eHTMLColor_White,
eTextColor_Enchant,
eTextColor_EnchantFocus,
eTextColor_EnchantDisabled,
eTextColor_RenamedItemTitle,
//eHTMLColor_0 = 0x000000, //r:0 , g: 0, b: 0, i: 0
//eHTMLColor_1 = 0x0000aa, //r:0 , g: 0, b: aa, i: 1
//eHTMLColor_2 = 0x109e10, // Changed by request of Dave //0x00aa00, //r:0 , g: aa, b: 0, i: 2
//eHTMLColor_3 = 0x109e9e, // Changed by request of Dave //0x00aaaa, //r:0 , g: aa, b: aa, i: 3
//eHTMLColor_4 = 0xaa0000, //r:aa , g: 0, b: 0, i: 4
//eHTMLColor_5 = 0xaa00aa, //r:aa , g: 0, b: aa, i: 5
//eHTMLColor_6 = 0xffaa00, //r:ff , g: aa, b: 0, i: 6
//eHTMLColor_7 = 0xaaaaaa, //r:aa , g: aa, b: aa, i: 7
//eHTMLColor_8 = 0x555555, //r:55 , g: 55, b: 55, i: 8
//eHTMLColor_9 = 0x5555ff, //r:55 , g: 55, b: ff, i: 9
//eHTMLColor_a = 0x55ff55, //r:55 , g: ff, b: 55, i: a
//eHTMLColor_b = 0x55ffff, //r:55 , g: ff, b: ff, i: b
//eHTMLColor_c = 0xff5555, //r:ff , g: 55, b: 55, i: c
//eHTMLColor_d = 0xff55ff, //r:ff , g: 55, b: ff, i: d
//eHTMLColor_e = 0xffff55, //r:ff , g: ff, b: 55, i: e
//eHTMLColor_f = 0xffffff, //r:ff , g: ff, b: ff, i: f
//eHTMLColor_0_dark = 0x000000, //r:0 , g: 0, b: 0, i: 10
//eHTMLColor_1_dark = 0x00002a, //r:0 , g: 0, b: 2a, i: 11
//eHTMLColor_2_dark = 0x002a00, //r:0 , g: 2a, b: 0, i: 12
//eHTMLColor_3_dark = 0x002a2a, //r:0 , g: 2a, b: 2a, i: 13
//eHTMLColor_4_dark = 0x2a0000, //r:2a , g: 0, b: 0, i: 14
//eHTMLColor_5_dark = 0x2a002a, //r:2a , g: 0, b: 2a, i: 15
//eHTMLColor_6_dark = 0x2a2a00, //r:2a , g: 2a, b: 0, i: 16
//eHTMLColor_7_dark = 0x2a2a2a, //r:2a , g: 2a, b: 2a, i: 17
//eHTMLColor_8_dark = 0x151515, //r:15 , g: 15, b: 15, i: 18
//eHTMLColor_9_dark = 0x15153f, //r:15 , g: 15, b: 3f, i: 19
//eHTMLColor_a_dark = 0x153f15, //r:15 , g: 3f, b: 15, i: 1a
//eHTMLColor_b_dark = 0x153f3f, //r:15 , g: 3f, b: 3f, i: 1b
//eHTMLColor_c_dark = 0x3f1515, //r:3f , g: 15, b: 15, i: 1c
//eHTMLColor_d_dark = 0x3f153f, //r:3f , g: 15, b: 3f, i: 1d
//eHTMLColor_e_dark = 0x3f3f15, //r:3f , g: 3f, b: 15, i: 1e
//eHTMLColor_f_dark = 0x3f3f3f, //r:3f , g: 3f, b: 3f, i: 1f
eMinecraftColour_COUNT,
};
enum eDLCContentType
{
e_DLC_SkinPack=0,
e_DLC_TexturePacks,
e_DLC_MashupPacks,
e_DLC_Themes,
e_DLC_AvatarItems,
e_DLC_Gamerpics,
e_DLC_MAX_MinecraftStore,
e_DLC_TexturePackData, // for the icon, banner and text
e_DLC_MAX,
e_DLC_NotDefined,
};
enum eDLCMarketplaceType
{
e_Marketplace_Content=0, // skins, texture packs and mashup packs
e_Marketplace_Themes,
e_Marketplace_AvatarItems,
e_Marketplace_Gamerpics,
e_Marketplace_MAX,
e_Marketplace_NotDefined,
};
enum eDLCContentState
{
e_DLC_ContentState_Idle = 0,
e_DLC_ContentState_Retrieving,
e_DLC_ContentState_Retrieved
};
enum eTMSContentState
{
e_TMS_ContentState_Idle = 0,
e_TMS_ContentState_Queued,
e_TMS_ContentState_Retrieving,
e_TMS_ContentState_Retrieved
};
enum eXUID
{
eXUID_Undefined=0,
eXUID_NoName, // name not needed
eXUID_Notch,
eXUID_Carl,
eXUID_Daniel,
eXUID_Deadmau5,
eXUID_DannyBStyle,
eXUID_JulianClark,
eXUID_Millionth,
eXUID_4JPaddy,
eXUID_4JStuart,
eXUID_4JDavid,
eXUID_4JRichard,
eXUID_4JSteven,
};
enum _eTerrainFeatureType
{
eTerrainFeature_None=0,
eTerrainFeature_Stronghold,
eTerrainFeature_Mineshaft,
eTerrainFeature_Village,
eTerrainFeature_Ravine,
eTerrainFeature_NetherFortress,
eTerrainFeature_StrongholdEndPortal,
eTerrainFeature_Count
};
// 4J Stu - Whend adding new options you should consider whether having them on should disable achievements, and if so add them to the CanRecordStatsAndAchievements function
// 4J Stu - These options are now saved in save data, so new options can ONLY be added to the end
enum eGameHostOption
{
eGameHostOption_Difficulty=0,
eGameHostOption_OnlineGame, // Unused
eGameHostOption_InviteOnly, // Unused
eGameHostOption_FriendsOfFriends,
eGameHostOption_Gamertags,
eGameHostOption_Tutorial, // special case
eGameHostOption_GameType,
eGameHostOption_LevelType, // flat or default
eGameHostOption_Structures,
eGameHostOption_BonusChest,
eGameHostOption_HasBeenInCreative,
eGameHostOption_PvP,
eGameHostOption_TrustPlayers,
eGameHostOption_TNT,
eGameHostOption_FireSpreads,
eGameHostOption_CheatsEnabled, // special case
eGameHostOption_HostCanFly,
eGameHostOption_HostCanChangeHunger,
eGameHostOption_HostCanBeInvisible,
eGameHostOption_BedrockFog,
eGameHostOption_NoHUD,
eGameHostOption_All,
eGameHostOption_DisableSaving,
};
// 4J-PB - If any new DLC items are added to the TMSFiles, this array needs updated
#ifdef _XBOX
enum _TMSFILES
{
TMS_SP1=0,
TMS_SP2,
TMS_SP3,
TMS_SP4,
TMS_SP5,
TMS_SP6,
TMS_SPF,
TMS_SPB,
TMS_SPC,
TMS_SPZ,
TMS_SPM,
TMS_SPI,
TMS_SPG,
TMS_THST,
TMS_THIR,
TMS_THGO,
TMS_THDI,
TMS_THAW,
TMS_GPAN,
TMS_GPCO,
TMS_GPEN,
TMS_GPFO,
TMS_GPTO,
TMS_GPBA,
TMS_GPFA,
TMS_GPME,
TMS_GPMF,
TMS_GPMM,
TMS_GPSE,
TMS_GPOr,
TMS_GPMi,
TMS_GPMB,
TMS_GPBr,
TMS_GPM1,
TMS_GPM2,
TMS_GPM3,
TMS_AH_0001,
TMS_AH_0002,
TMS_AH_0003,
TMS_AH_0004,
TMS_AH_0005,
TMS_AH_0006,
TMS_AH_0007,
TMS_AH_0008,
TMS_AH_0009,
TMS_AH_0010,
TMS_AH_0011,
TMS_AH_0012,
TMS_AH_0013,
TMS_AT_0001,
TMS_AT_0002,
TMS_AT_0003,
TMS_AT_0004,
TMS_AT_0005,
TMS_AT_0006,
TMS_AT_0007,
TMS_AT_0008,
TMS_AT_0009,
TMS_AT_0010,
TMS_AT_0011,
TMS_AT_0012,
TMS_AT_0013,
TMS_AT_0014,
TMS_AT_0015,
TMS_AT_0016,
TMS_AT_0017,
TMS_AT_0018,
TMS_AT_0019,
TMS_AT_0020,
TMS_AT_0021,
TMS_AT_0022,
TMS_AT_0023,
TMS_AT_0024,
TMS_AT_0025,
TMS_AT_0026,
TMS_AP_0001,
TMS_AP_0002,
TMS_AP_0003,
TMS_AP_0004,
TMS_AP_0005,
TMS_AP_0006,
TMS_AP_0007,
TMS_AP_0009,
TMS_AP_0010,
TMS_AP_0011,
TMS_AP_0012,
TMS_AP_0013,
TMS_AP_0014,
TMS_AP_0015,
TMS_AP_0016,
TMS_AP_0017,
TMS_AP_0018,
TMS_AP_0019,
TMS_AP_0020,
TMS_AP_0021,
TMS_AP_0022,
TMS_AP_0023,
TMS_AP_0024,
TMS_AP_0025,
TMS_AP_0026,
TMS_AP_0027,
TMS_AP_0028,
TMS_AP_0029,
TMS_AP_0030,
TMS_AP_0031,
TMS_AP_0032,
TMS_AP_0033,
TMS_AA_0001,
TMS_MPMA,
TMS_MPMA_DAT,
TMS_MPSR,
TMS_MPSR_DAT,
TMS_MPHA,
TMS_MPHA_DAT,
TMS_TP01,
TMS_TP01_DAT,
TMS_TP02,
TMS_TP02_DAT,
TMS_TP04,
TMS_TP04_DAT,
TMS_TP05,
TMS_TP05_DAT,
TMS_TP06,
TMS_TP06_DAT,
TMS_TP07,
TMS_TP07_DAT,
TMS_COUNT
};
#endif
enum EHTMLFontSize
{
eHTMLSize_Normal,
eHTMLSize_Splitscreen,
eHTMLSize_Tutorial,
eHTMLSize_EndPoem,
eHTMLSize_COUNT,
};
enum EControllerActions
{
ACTION_MENU_A,
ACTION_MENU_B,
ACTION_MENU_X,
ACTION_MENU_Y,
ACTION_MENU_UP,
ACTION_MENU_DOWN,
ACTION_MENU_RIGHT,
ACTION_MENU_LEFT,
ACTION_MENU_PAGEUP,
ACTION_MENU_PAGEDOWN,
ACTION_MENU_RIGHT_SCROLL,
ACTION_MENU_LEFT_SCROLL,
ACTION_MENU_STICK_PRESS,
ACTION_MENU_OTHER_STICK_PRESS,
ACTION_MENU_OTHER_STICK_UP,
ACTION_MENU_OTHER_STICK_DOWN,
ACTION_MENU_OTHER_STICK_LEFT,
ACTION_MENU_OTHER_STICK_RIGHT,
ACTION_MENU_PAUSEMENU,
#ifdef _DURANGO
ACTION_MENU_GTC_PAUSE,
ACTION_MENU_GTC_RESUME,
#endif
#ifdef __ORBIS__
ACTION_MENU_TOUCHPAD_PRESS,
#endif
ACTION_MENU_OK,
ACTION_MENU_CANCEL,
ACTION_MAX_MENU = ACTION_MENU_CANCEL,
MINECRAFT_ACTION_JUMP,
MINECRAFT_ACTION_FORWARD,
MINECRAFT_ACTION_BACKWARD,
MINECRAFT_ACTION_LEFT,
MINECRAFT_ACTION_RIGHT,
MINECRAFT_ACTION_LOOK_LEFT,
MINECRAFT_ACTION_LOOK_RIGHT,
MINECRAFT_ACTION_LOOK_UP,
MINECRAFT_ACTION_LOOK_DOWN,
MINECRAFT_ACTION_USE,
MINECRAFT_ACTION_ACTION,
MINECRAFT_ACTION_LEFT_SCROLL,
MINECRAFT_ACTION_RIGHT_SCROLL,
MINECRAFT_ACTION_INVENTORY,
MINECRAFT_ACTION_PAUSEMENU,
MINECRAFT_ACTION_DROP,
MINECRAFT_ACTION_SNEAK_TOGGLE,
MINECRAFT_ACTION_CRAFTING,
MINECRAFT_ACTION_RENDER_THIRD_PERSON,
MINECRAFT_ACTION_GAME_INFO,
MINECRAFT_ACTION_DPAD_LEFT,
MINECRAFT_ACTION_DPAD_RIGHT,
MINECRAFT_ACTION_DPAD_UP,
MINECRAFT_ACTION_DPAD_DOWN,
MINECRAFT_ACTION_MAX,
// These 4 aren't mapped to the input manager directly but are created from the dpad controls if required in Minecraft::run_middle
// Don't use them with the input manager directly, just through LocalPlayer::ullButtonsPressed
MINECRAFT_ACTION_SPAWN_CREEPER,
MINECRAFT_ACTION_CHANGE_SKIN,
MINECRAFT_ACTION_FLY_TOGGLE,
MINECRAFT_ACTION_RENDER_DEBUG
};
enum eMCLang
{
eMCLang_null=0,
eMCLang_enUS,
eMCLang_enGB,
eMCLang_enIE,
eMCLang_enAU,
eMCLang_enNZ,
eMCLang_enCA,
eMCLang_jaJP,
eMCLang_deDE,
eMCLang_deAT,
eMCLang_frFR,
eMCLang_frCA,
eMCLang_esES,
eMCLang_esMX,
eMCLang_itIT,
eMCLang_koKR,
eMCLang_ptPT,
eMCLang_ptBR,
eMCLang_ruRU,
eMCLang_nlNL,
eMCLang_fiFI,
eMCLang_svSV,
eMCLang_daDA,
eMCLang_noNO,
eMCLang_plPL,
eMCLang_trTR,
eMCLang_elEL,
eMCLang_zhCHS,
eMCLang_zhCHT,
eMCLang_laLAS,
eMCLang_zhSG,
eMCLang_zhCN,
eMCLang_zhHK,
eMCLang_zhTW,
eMCLang_nlBE,
eMCLang_daDK,
eMCLang_frBE,
eMCLang_frCH,
eMCLang_deCH,
eMCLang_nbNO,
eMCLang_enGR,
eMCLang_enHK,
eMCLang_enSA,
eMCLang_enHU,
eMCLang_enIN,
eMCLang_enIL,
eMCLang_enSG,
eMCLang_enSK,
eMCLang_enZA,
eMCLang_enCZ,
eMCLang_enAE,
eMCLang_esAR,
eMCLang_esCL,
eMCLang_esCO,
eMCLang_esUS,
eMCLang_svSE,
eMCLang_csCZ,
eMCLang_elGR,
eMCLang_nnNO,
eMCLang_skSK,
};

View File

@@ -0,0 +1,227 @@
#pragma once
typedef struct
{
wchar_t *wchFilename;
eFileExtensionType eEXT;
eTMSFileType eTMSType;
PBYTE pbData;
UINT uiSize;
int iConfig; // used for texture pack data files
}
TMS_FILE;
typedef struct
{
PBYTE pbData;
DWORD dwBytes;
BYTE ucRefCount;
}
MEMDATA,*PMEMDATA;
typedef struct
{
DWORD dwNotification;
UINT uiParam;
}
NOTIFICATION,*PNOTIFICATION;
typedef struct
{
bool bSettingsChanged;
unsigned char ucMusicVolume;
unsigned char ucSoundFXVolume;
unsigned char ucSensitivity;
unsigned char ucGamma;
unsigned char ucPad01; // 1 byte of padding inserted here
unsigned short usBitmaskValues; // bit 0,1 - difficulty
// bit 2 - view bob
// bit 3 - player visible in a map
// bit 4,5 - control scheme
// bit 6 - invert look
// bit 7 - southpaw
// bit 8 - splitscreen vertical
// 4J-PB - Adding new values for interim TU for 1.6.6
// bit 9 - Display gamertags in splitscreen
// bit 10 - Disable/Enable hints
// bit 11,12,13,14 - Autosave frequency - 0 = Off, 8 = (8*15 minutes) = 2 hours
// bit 15 Tooltips
// debug values
unsigned int uiDebugBitmask;
// block off space to use for whatever we want (e.g bitflags for storing things the player has done in the game, so we can flag the first time they do things, such as sleep)
union
{
struct
{
unsigned char ucTutorialCompletion[TUTORIAL_PROFILE_STORAGE_BYTES];
// adding new flags for interim TU to 1.6.6
// A value that encodes the skin that the player has set as their default
DWORD dwSelectedSkin;
// In-Menu sensitivity
unsigned char ucMenuSensitivity;
unsigned char ucInterfaceOpacity;
unsigned char ucPad02;//2 bytes of padding added here
unsigned char usPad03;
// Adding another bitmask flag for more settings for 1.8.2
unsigned int uiBitmaskValues; // 0x00000001 - eGameSetting_Clouds - on
// 0x00000002 - eGameSetting_GameSetting_Online - on
// 0x00000004 - eGameSetting_GameSetting_Invite - off
// 0x00000008 - eGameSetting_GameSetting_FriendsOfFriends - on
// 0x00000010 - eGameSetting_PSVita_NetworkModeAdhoc - on
// TU 5
// 0x00000030 - eGameSetting_DisplayUpdateMessage - 3 - counts down to zero
// TU 6
// 0x00000040 - eGameSetting_BedrockFog - off
// 0x00000080 - eGameSetting_DisplayHUD - on
// 0x00000100 - eGameSetting_DisplayHand - on
// TU 7
// 0x00000200 - eGameSetting_CustomSkinAnim - on
// TU9 // 0x00000400 - eGameSetting_DeathMessages - on
// Adding another bitmask to store "special" completion tasks for the tutorial
unsigned int uiSpecialTutorialBitmask;
// A value that encodes the cape that the player has set
DWORD dwSelectedCape;
unsigned int uiFavoriteSkinA[MAX_FAVORITE_SKINS];
unsigned char ucCurrentFavoriteSkinPos;
// TU13
unsigned int uiMashUpPackWorldsDisplay; // bitmask to enable/disable the display of the individual mash-up pack worlds
// PS3 1.05 - Adding Greek, so need a language
unsigned char ucLanguage;
// 4J Stu - See comment for GAME_SETTINGS_PROFILE_DATA_BYTES below
// was 192
//unsigned char ucUnused[192-TUTORIAL_PROFILE_STORAGE_BYTES-sizeof(DWORD)-sizeof(char)-sizeof(char)-sizeof(char)-sizeof(char)-sizeof(LONG)-sizeof(LONG)-sizeof(DWORD)];
// 4J-PB - don't need to define the padded space, the union with ucReservedSpace will make the sizeof GAME_SETTINGS correct
};
unsigned char ucReservedSpace[192];
};
}
GAME_SETTINGS;
#ifdef _XBOX_ONE
typedef struct
{
WCHAR wchPlayerUID[64];
char pszLevelName[14];
}
BANNEDLISTDATA,*PBANNEDLISTDATA;
#else
typedef struct
{
PlayerUID xuid;
char pszLevelName[14];
}
BANNEDLISTDATA,*PBANNEDLISTDATA;
#endif
typedef std::vector <PBANNEDLISTDATA> VBANNEDLIST;
typedef struct
{
int iPad;
eXuiAction action;
}
XuiActionParam;
// tips
typedef struct
{
int iSortValue;
UINT uiStringID;
}
TIPSTRUCT;
typedef struct
{
eXUID eXuid;
WCHAR wchCape[MAX_CAPENAME_SIZE];
WCHAR wchSkin[MAX_CAPENAME_SIZE];
}
MOJANG_DATA;
typedef struct
{
eDLCContentType eDLCType;
#if defined( __PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
char chImageURL[256];//SCE_NP_COMMERCE2_URL_LEN
#else
#ifdef _XBOX_ONE
wstring wsProductId;
wstring wsDisplayName;
// add a store for the local DLC image
PBYTE pbImageData;
DWORD dwImageBytes;
#else
ULONGLONG ullOfferID_Full;
ULONGLONG ullOfferID_Trial;
#endif
WCHAR wchBanner[MAX_BANNERNAME_SIZE];
WCHAR wchDataFile[MAX_BANNERNAME_SIZE];
int iGender;
#endif
int iConfig;
unsigned int uiSortIndex;
}
DLC_INFO;
typedef struct
{
int x,z;
_eTerrainFeatureType eTerrainFeature;
}
FEATURE_DATA;
// banned list
typedef struct
{
BYTE *pBannedList;
DWORD dwBytes;
}
BANNEDLIST;
typedef struct _DLCRequest
{
DWORD dwType;
eDLCContentState eState;
}
DLCRequest;
typedef struct _TMSPPRequest
{
eTMSContentState eState;
eDLCContentType eType;
C4JStorage::eGlobalStorage eStorageFacility;
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal;
//char szFilename[MAX_TMSFILENAME_SIZE];
#ifdef _XBOX_ONE
int( *CallbackFunc)(LPVOID,int,int,LPVOID, WCHAR *);
#else
int( *CallbackFunc)(LPVOID,int,int,C4JStorage::PTMSPP_FILEDATA, LPCSTR szFilename);
#endif
WCHAR wchFilename[MAX_TMSFILENAME_SIZE];
LPVOID lpCallbackParam;
}
TMSPPRequest;
typedef pair<EUIScene, HXUIOBJ> SceneStackPair;

View File

@@ -0,0 +1,38 @@
#include "stdafx.h"
#include "Consoles_SoundEngine.h"
bool ConsoleSoundEngine::GetIsPlayingStreamingCDMusic()
{
return m_bIsPlayingStreamingCDMusic;
}
bool ConsoleSoundEngine::GetIsPlayingStreamingGameMusic()
{
return m_bIsPlayingStreamingGameMusic;
}
void ConsoleSoundEngine::SetIsPlayingStreamingCDMusic(bool bVal)
{
m_bIsPlayingStreamingCDMusic=bVal;
}
void ConsoleSoundEngine::SetIsPlayingStreamingGameMusic(bool bVal)
{
m_bIsPlayingStreamingGameMusic=bVal;
}
bool ConsoleSoundEngine::GetIsPlayingEndMusic()
{
return m_bIsPlayingEndMusic;
}
bool ConsoleSoundEngine::GetIsPlayingNetherMusic()
{
return m_bIsPlayingNetherMusic;
}
void ConsoleSoundEngine::SetIsPlayingEndMusic(bool bVal)
{
m_bIsPlayingEndMusic=bVal;
}
void ConsoleSoundEngine::SetIsPlayingNetherMusic(bool bVal)
{
m_bIsPlayingNetherMusic=bVal;
}

View File

@@ -0,0 +1,81 @@
#pragma once
#include "..\..\..\Minecraft.World\SoundTypes.h"
#ifdef _XBOX
#elif defined (__PS3__)
#undef __in
#undef __out
#include "..\..\PS3\Miles\include\mss.h"
#elif defined (__PSVITA__)
#include "..\..\PSVITA\Miles\include\mss.h"
#elif defined _DURANGO
// 4J Stu - Temp define to get Miles to link, can likely be removed when we get a new version of Miles
#define _SEKRIT
#include "..\..\Durango\Miles\include\mss.h"
#elif defined _WINDOWS64
#include "..\..\windows64\Miles\include\mss.h"
#else // PS4
// 4J Stu - Temp define to get Miles to link, can likely be removed when we get a new version of Miles
#define _SEKRIT2
#include "..\..\Orbis\Miles\include\mss.h"
#endif
typedef struct
{
float x,y,z;
}
AUDIO_VECTOR;
typedef struct
{
bool bValid;
AUDIO_VECTOR vPosition;
AUDIO_VECTOR vOrientFront;
}
AUDIO_LISTENER;
class Options;
class ConsoleSoundEngine
{
public:
ConsoleSoundEngine() : m_bIsPlayingStreamingCDMusic(false),m_bIsPlayingStreamingGameMusic(false), m_bIsPlayingEndMusic(false),m_bIsPlayingNetherMusic(false){};
virtual void tick(shared_ptr<Mob> *players, float a) =0;
virtual void destroy()=0;
virtual void play(int iSound, float x, float y, float z, float volume, float pitch) =0;
virtual void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true) =0;
virtual void playUI(int iSound, float volume, float pitch) =0;
virtual void updateMusicVolume(float fVal) =0;
virtual void updateSystemMusicPlaying(bool isPlaying) = 0;
virtual void updateSoundEffectVolume(float fVal) =0;
virtual void init(Options *) =0 ;
virtual void add(const wstring& name, File *file) =0;
virtual void addMusic(const wstring& name, File *file) =0;
virtual void addStreaming(const wstring& name, File *file) =0;
virtual char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces) =0;
virtual void playMusicTick() =0;
virtual bool GetIsPlayingStreamingCDMusic() ;
virtual bool GetIsPlayingStreamingGameMusic() ;
virtual void SetIsPlayingStreamingCDMusic(bool bVal) ;
virtual void SetIsPlayingStreamingGameMusic(bool bVal) ;
virtual bool GetIsPlayingEndMusic() ;
virtual bool GetIsPlayingNetherMusic() ;
virtual void SetIsPlayingEndMusic(bool bVal) ;
virtual void SetIsPlayingNetherMusic(bool bVal) ;
static const WCHAR *wchSoundNames[eSoundType_MAX];
static const WCHAR *wchUISoundNames[eSFX_MAX];
private:
// platform specific functions
virtual int initAudioHardware(int iMinSpeakers)=0;
bool m_bIsPlayingStreamingCDMusic;
bool m_bIsPlayingStreamingGameMusic;
bool m_bIsPlayingEndMusic;
bool m_bIsPlayingNetherMusic;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,168 @@
#pragma once
class Mob;
class Options;
using namespace std;
#include "..\..\Minecraft.World\SoundTypes.h"
enum eMUSICFILES
{
eStream_Overworld_Calm1 = 0,
eStream_Overworld_Calm2,
eStream_Overworld_Calm3,
eStream_Overworld_hal1,
eStream_Overworld_hal2,
eStream_Overworld_hal3,
eStream_Overworld_hal4,
eStream_Overworld_nuance1,
eStream_Overworld_nuance2,
#ifndef _XBOX
// Add the new music tracks
eStream_Overworld_Creative1,
eStream_Overworld_Creative2,
eStream_Overworld_Creative3,
eStream_Overworld_Creative4,
eStream_Overworld_Creative5,
eStream_Overworld_Creative6,
eStream_Overworld_Menu1,
eStream_Overworld_Menu2,
eStream_Overworld_Menu3,
eStream_Overworld_Menu4,
#endif
eStream_Overworld_piano1,
eStream_Overworld_piano2,
eStream_Overworld_piano3, // <-- make piano3 the last overworld one
// Nether
eStream_Nether1,
eStream_Nether2,
eStream_Nether3,
eStream_Nether4,
// The End
eStream_end_dragon,
eStream_end_end,
eStream_CD_1,
eStream_CD_2,
eStream_CD_3,
eStream_CD_4,
eStream_CD_5,
eStream_CD_6,
eStream_CD_7,
eStream_CD_8,
eStream_CD_9,
eStream_CD_10,
eStream_CD_11,
eStream_CD_12,
eStream_Max,
};
enum eMUSICTYPE
{
eMusicType_None,
eMusicType_Game,
eMusicType_CD,
};
enum MUSIC_STREAMSTATE
{
eMusicStreamState_Idle=0,
eMusicStreamState_Stop,
eMusicStreamState_Stopping,
eMusicStreamState_Opening,
eMusicStreamState_OpeningCancel,
eMusicStreamState_Play,
eMusicStreamState_Playing,
eMusicStreamState_Completed
};
typedef struct
{
F32 x,y,z,volume,pitch;
int iSound;
bool bIs3D;
bool bUseSoundsPitchVal;
#ifdef _DEBUG
char chName[64];
#endif
}
AUDIO_INFO;
class SoundEngine : public ConsoleSoundEngine
{
static const int MAX_SAME_SOUNDS_PLAYING = 8; // 4J added
public:
SoundEngine();
virtual void destroy();
#ifdef _DEBUG
void GetSoundName(char *szSoundName,int iSound);
#endif
virtual void play(int iSound, float x, float y, float z, float volume, float pitch);
virtual void playStreaming(const wstring& name, float x, float y , float z, float volume, float pitch, bool bMusicDelay=true);
virtual void playUI(int iSound, float volume, float pitch);
virtual void playMusicTick();
virtual void updateMusicVolume(float fVal);
virtual void updateSystemMusicPlaying(bool isPlaying);
virtual void updateSoundEffectVolume(float fVal);
virtual void init(Options *);
virtual void tick(shared_ptr<Mob> *players, float a); // 4J - updated to take array of local players rather than single one
virtual void add(const wstring& name, File *file);
virtual void addMusic(const wstring& name, File *file);
virtual void addStreaming(const wstring& name, File *file);
virtual char *ConvertSoundPathToName(const wstring& name, bool bConvertSpaces=false);
bool isStreamingWavebankReady(); // 4J Added
int getMusicID(int iDomain);
int getMusicID(const wstring& name);
void SetStreamingSounds(int iOverworldMin, int iOverWorldMax, int iNetherMin, int iNetherMax, int iEndMin, int iEndMax, int iCD1);
void updateMiles(); // AP added so Vita can update all the Miles functions during the mixer callback
void playMusicUpdate();
private:
float getMasterMusicVolume();
// platform specific functions
#ifdef __PS3__
int initAudioHardware(int iMinSpeakers);
#else
int initAudioHardware(int iMinSpeakers) { return iMinSpeakers;}
#endif
int GetRandomishTrack(int iStart,int iEnd);
HMSOUNDBANK m_hBank;
HDIGDRIVER m_hDriver;
HSTREAM m_hStream;
static char m_szSoundPath[];
static char m_szMusicPath[];
static char m_szRedistName[];
static char *m_szStreamFileA[eStream_Max];
AUDIO_LISTENER m_ListenerA[MAX_LOCAL_PLAYERS];
int m_validListenerCount;
Random *random;
int m_musicID;
int m_iMusicDelay;
int m_StreamState;
int m_MusicType;
AUDIO_INFO m_StreamingAudioInfo;
wstring m_CDMusic;
BOOL m_bSystemMusicPlaying;
float m_MasterMusicVolume;
float m_MasterEffectsVolume;
C4JThread *m_openStreamThread;
static int OpenStreamThreadProc( void* lpParameter );
char m_szStreamName[255];
int CurrentSoundsPlaying[eSoundType_MAX+eSFX_MAX];
// streaming music files - will be different for mash-up packs
int m_iStream_Overworld_Min,m_iStream_Overworld_Max;
int m_iStream_Nether_Min,m_iStream_Nether_Max;
int m_iStream_End_Min,m_iStream_End_Max;
int m_iStream_CD_1;
bool *m_bHeardTrackA;
#ifdef __ORBIS__
int32_t m_hBGMAudio;
#endif
};

View File

@@ -0,0 +1,165 @@
#include "stdafx.h"
#include "Consoles_SoundEngine.h"
const WCHAR *ConsoleSoundEngine::wchSoundNames[eSoundType_MAX]=
{
L"mob.chicken", // eSoundType_MOB_CHICKEN_AMBIENT
L"mob.chickenhurt", // eSoundType_MOB_CHICKEN_HURT
L"mob.chickenplop", // eSoundType_MOB_CHICKENPLOP
L"mob.cow", // eSoundType_MOB_COW_AMBIENT
L"mob.cowhurt", // eSoundType_MOB_COW_HURT
L"mob.pig", // eSoundType_MOB_PIG_AMBIENT
L"mob.pigdeath", // eSoundType_MOB_PIG_DEATH
L"mob.sheep", // eSoundType_MOB_SHEEP_AMBIENT
L"mob.wolf.growl", // eSoundType_MOB_WOLF_GROWL
L"mob.wolf.whine", // eSoundType_MOB_WOLF_WHINE
L"mob.wolf.panting", // eSoundType_MOB_WOLF_PANTING
L"mob.wolf.bark", // eSoundType_MOB_WOLF_BARK
L"mob.wolf.hurt", // eSoundType_MOB_WOLF_HURT
L"mob.wolf.death", // eSoundType_MOB_WOLF_DEATH
L"mob.wolf.shake", // eSoundType_MOB_WOLF_SHAKE
L"mob.blaze.breathe", // eSoundType_MOB_BLAZE_BREATHE
L"mob.blaze.hit", // eSoundType_MOB_BLAZE_HURT
L"mob.blaze.death", // eSoundType_MOB_BLAZE_DEATH
L"mob.ghast.moan", // eSoundType_MOB_GHAST_MOAN
L"mob.ghast.scream", // eSoundType_MOB_GHAST_SCREAM
L"mob.ghast.death", // eSoundType_MOB_GHAST_DEATH
L"mob.ghast.fireball", // eSoundType_MOB_GHAST_FIREBALL
L"mob.ghast.charge", // eSoundType_MOB_GHAST_CHARGE
L"mob.endermen.idle", // eSoundType_MOB_ENDERMEN_IDLE
L"mob.endermen.hit", // eSoundType_MOB_ENDERMEN_HIT
L"mob.endermen.death", // eSoundType_MOB_ENDERMEN_DEATH
L"mob.endermen.portal", // eSoundType_MOB_ENDERMEN_PORTAL
L"mob.zombiepig.zpig", // eSoundType_MOB_ZOMBIEPIG_AMBIENT
L"mob.zombiepig.zpighurt", // eSoundType_MOB_ZOMBIEPIG_HURT
L"mob.zombiepig.zpigdeath", // eSoundType_MOB_ZOMBIEPIG_DEATH
L"mob.zombiepig.zpigangry", // eSoundType_MOB_ZOMBIEPIG_ZPIGANGRY
L"mob.silverfish.say", // eSoundType_MOB_SILVERFISH_AMBIENT,
L"mob.silverfish.hit", // eSoundType_MOB_SILVERFISH_HURT
L"mob.silverfish.kill", // eSoundType_MOB_SILVERFISH_DEATH,
L"mob.silverfish.step", // eSoundType_MOB_SILVERFISH_STEP,
L"mob.skeleton", // eSoundType_MOB_SKELETON_AMBIENT,
L"mob.skeletonhurt", // eSoundType_MOB_SKELETON_HURT,
L"mob.spider", // eSoundType_MOB_SPIDER_AMBIENT,
L"mob.spiderdeath", // eSoundType_MOB_SPIDER_DEATH,
L"mob.slime", // eSoundType_MOB_SLIME,
L"mob.slimeattack", // eSoundType_MOB_SLIME_ATTACK,
L"mob.creeper", // eSoundType_MOB_CREEPER_HURT,
L"mob.creeperdeath", // eSoundType_MOB_CREEPER_DEATH,
L"mob.zombie", // eSoundType_MOB_ZOMBIE_AMBIENT,
L"mob.zombiehurt", // eSoundType_MOB_ZOMBIE_HURT,
L"mob.zombiedeath", // eSoundType_MOB_ZOMBIE_DEATH,
L"mob.zombie.wood", // eSoundType_MOB_ZOMBIE_WOOD,
L"mob.zombie.woodbreak", // eSoundType_MOB_ZOMBIE_WOOD_BREAK,
L"mob.zombie.metal", // eSoundType_MOB_ZOMBIE_METAL,
L"mob.magmacube.big", // eSoundType_MOB_MAGMACUBE_BIG,
L"mob.magmacube.small", // eSoundType_MOB_MAGMACUBE_SMALL,
L"mob.cat.purr", // eSoundType_MOB_CAT_PURR
L"mob.cat.purreow", // eSoundType_MOB_CAT_PURREOW
L"mob.cat.meow", // eSoundType_MOB_CAT_MEOW
// 4J-PB - correct the name of the event for hitting ocelots
L"mob.cat.hit", // eSoundType_MOB_CAT_HITT
// L"mob.irongolem.throw", // eSoundType_MOB_IRONGOLEM_THROW
// L"mob.irongolem.hit", // eSoundType_MOB_IRONGOLEM_HIT
// L"mob.irongolem.death", // eSoundType_MOB_IRONGOLEM_DEATH
// L"mob.irongolem.walk", // eSoundType_MOB_IRONGOLEM_WALK
L"random.bow", // eSoundType_RANDOM_BOW,
L"random.bowhit", // eSoundType_RANDOM_BOW_HIT,
L"random.explode", // eSoundType_RANDOM_EXPLODE,
L"random.fizz", // eSoundType_RANDOM_FIZZ,
L"random.pop", // eSoundType_RANDOM_POP,
L"random.fuse", // eSoundType_RANDOM_FUSE,
L"random.drink", // eSoundType_RANDOM_DRINK,
L"random.eat", // eSoundType_RANDOM_EAT,
L"random.burp", // eSoundType_RANDOM_BURP,
L"random.splash", // eSoundType_RANDOM_SPLASH,
L"random.click", // eSoundType_RANDOM_CLICK,
L"random.glass", // eSoundType_RANDOM_GLASS,
L"random.orb", // eSoundType_RANDOM_ORB,
L"random.break", // eSoundType_RANDOM_BREAK,
L"random.chestopen", // eSoundType_RANDOM_CHEST_OPEN,
L"random.chestclosed", // eSoundType_RANDOM_CHEST_CLOSE,
L"random.door_open", // eSoundType_RANDOM_DOOR_OPEN,
L"random.door_close", // eSoundType_RANDOM_DOOR_CLOSE,
L"ambient.weather.rain", // eSoundType_AMBIENT_WEATHER_RAIN,
L"ambient.weather.thunder", // eSoundType_AMBIENT_WEATHER_THUNDER,
L"ambient.cave.cave", // eSoundType_CAVE_CAVE, DON'T USE FOR XBOX 360!!!
#ifdef _XBOX
L"ambient.cave.cave2", // eSoundType_CAVE_CAVE2 - removed the two sounds that were at 192k in the first ambient cave event
#endif
L"portal.portal", // eSoundType_PORTAL_PORTAL,
// 4J-PB - added a couple that were still using wstring
L"portal.trigger", // eSoundType_PORTAL_TRIGGER
L"portal.travel", // eSoundType_PORTAL_TRAVEL
L"fire.ignite", // eSoundType_FIRE_IGNITE,
L"fire.fire", // eSoundType_FIRE_FIRE,
L"damage.hurtflesh", // eSoundType_DAMAGE_HURT,
L"damage.fallsmall", // eSoundType_DAMAGE_FALL_SMALL,
L"damage.fallbig", // eSoundType_DAMAGE_FALL_BIG,
L"note.harp", // eSoundType_NOTE_HARP,
L"note.bd", // eSoundType_NOTE_BD,
L"note.snare", // eSoundType_NOTE_SNARE,
L"note.hat", // eSoundType_NOTE_HAT,
L"note.bassattack", // eSoundType_NOTE_BASSATTACK,
L"tile.piston.in", // eSoundType_TILE_PISTON_IN,
L"tile.piston.out", // eSoundType_TILE_PISTON_OUT,
L"liquid.water", // eSoundType_LIQUID_WATER,
L"liquid.lavapop", // eSoundType_LIQUID_LAVA_POP,
L"liquid.lava", // eSoundType_LIQUID_LAVA,
L"step.stone", // eSoundType_STEP_STONE,
L"step.wood", // eSoundType_STEP_WOOD,
L"step.gravel", // eSoundType_STEP_GRAVEL,
L"step.grass", // eSoundType_STEP_GRASS,
L"step.metal", // eSoundType_STEP_METAL,
L"step.cloth", // eSoundType_STEP_CLOTH,
L"step.sand", // eSoundType_STEP_SAND,
// below this are the additional sounds from the second soundbank
L"mob.enderdragon.end", // eSoundType_MOB_ENDERDRAGON_END
L"mob.enderdragon.growl", // eSoundType_MOB_ENDERDRAGON_GROWL
L"mob.enderdragon.hit", // eSoundType_MOB_ENDERDRAGON_HIT
L"mob.enderdragon.wings", // eSoundType_MOB_ENDERDRAGON_MOVE
L"mob.irongolem.throw", // eSoundType_MOB_IRONGOLEM_THROW
L"mob.irongolem.hit", // eSoundType_MOB_IRONGOLEM_HIT
L"mob.irongolem.death", // eSoundType_MOB_IRONGOLEM_DEATH
L"mob.irongolem.walk", // eSoundType_MOB_IRONGOLEM_WALK
// TU14
L"damage.thorns", // eSoundType_DAMAGE_THORNS
L"random.anvil_break", // eSoundType_RANDOM_ANVIL_BREAK
L"random.anvil_land", // eSoundType_RANDOM_ANVIL_LAND
L"random.anvil_use", // eSoundType_RANDOM_ANVIL_USE
L"mob.villager.haggle", // eSoundType_MOB_VILLAGER_HAGGLE
L"mob.villager.idle", // eSoundType_MOB_VILLAGER_IDLE
L"mob.villager.hit", // eSoundType_MOB_VILLAGER_HIT
L"mob.villager.death", // eSoundType_MOB_VILLAGER_DEATH
L"mob.villager.yes", // eSoundType_MOB_VILLAGER_YES
L"mob.villager.no", // eSoundType_MOB_VILLAGER_NO
L"mob.zombie.infect", // eSoundType_MOB_ZOMBIE_INFECT
L"mob.zombie.unfect", // eSoundType_MOB_ZOMBIE_UNFECT
L"mob.zombie.remedy", // eSoundType_MOB_ZOMBIE_REMEDY
L"step.snow", // eSoundType_STEP_SNOW
L"step.ladder", // eSoundType_STEP_LADDER
L"dig.cloth", // eSoundType_DIG_CLOTH
L"dig.grass", // eSoundType_DIG_GRASS
L"dig.gravel", // eSoundType_DIG_GRAVEL
L"dig.sand", // eSoundType_DIG_SAND
L"dig.snow", // eSoundType_DIG_SNOW
L"dig.stone", // eSoundType_DIG_STONE
L"dig.wood", // eSoundType_DIG_WOOD
};
const WCHAR *ConsoleSoundEngine::wchUISoundNames[eSFX_MAX]=
{
L"back",
L"craft",
L"craftfail",
L"focus",
L"press",
L"scroll",
};

View File

@@ -0,0 +1,57 @@
#pragma once
#define VER_PRODUCTMAJORVERSION 0
#define VER_PRODUCTMINORVERSION 0
// This goes up with each build
// 4J-JEV: This value is extracted with a regex so it can be placed as the version in the AppX manifest on Durango.
#define VER_PRODUCTBUILD 495
// This goes up if there is any change to network traffic or code in a build
#define VER_NETWORK 495
#define VER_PRODUCTBUILD_QFE 0
#define VER_FILEVERSION_STRING "1.3"
#define VER_PRODUCTVERSION_STRING VER_FILEVERSION_STRING
#define VER_FILEVERSION_STRING_W L"1.3"
#define VER_PRODUCTVERSION_STRING_W VER_FILEVERSION_STRING_W
#define VER_FILEBETA_STR ""
#undef VER_FILEVERSION
#define VER_FILEVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE
#define VER_PRODUCTVERSION VER_PRODUCTMAJORVERSION, VER_PRODUCTMINORVERSION, VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE
#if (VER_PRODUCTBUILD < 10)
#define VER_FILEBPAD "000"
#define VER_FILEBPAD_W L"000"
#elif (VER_PRODUCTBUILD < 100)
#define VER_FILEBPAD "00"
#define VER_FILEBPAD_W L"00"
#elif (VER_PRODUCTBUILD < 1000)
#define VER_FILEBPAD "0"
#define VER_FILEBPAD_W L"0"
#else
#define VER_FILEBPAD
#define VER_FILEBPAD_W
#endif
#define VER_WIDE_PREFIX(x) L##x
#define VER_FILEVERSION_STR2(x,y) VER_FILEVERSION_STRING "." VER_FILEBPAD #x "." #y
#define VER_FILEVERSION_STR2_W(x,y) VER_FILEVERSION_STRING_W L"." VER_FILEBPAD_W VER_WIDE_PREFIX(#x) L"." VER_WIDE_PREFIX(#y)
#define VER_FILEVERSION_STR1(x,y) VER_FILEVERSION_STR2(x, y)
#define VER_FILEVERSION_STR1_W(x,y) VER_FILEVERSION_STR2_W(x, y)
#undef VER_FILEVERSION_STR
#define VER_FILEVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR1(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#define VER_FILEVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#define VER_PRODUCTVERSION_STR_W VER_FILEVERSION_STR1_W(VER_PRODUCTBUILD, VER_PRODUCTBUILD_QFE)
#if (VER_PRODUCTBUILD_QFE >= 256)
#error "QFE number cannot exceed 255"
#endif

View File

@@ -0,0 +1,176 @@
#pragma once
#include <stdlib.h>
class C4JMemoryPool
{
public:
unsigned int Align(unsigned int val, unsigned int align) { return int((val+(align-1))/align) * align; }
virtual void* Alloc(size_t size) = 0;
virtual void Free(void* ptr) = 0;
};
// Fast Efficient Fixed-Size Memory Pool : No Loops and No Overhead
// http://www.alogicalmind.com/memory_pools/index.htm
class C4JMemoryPoolFixed : public C4JMemoryPool
{
// Basic type define
typedef unsigned int uint;
typedef unsigned char uchar;
uint m_numOfBlocks; // Num of blocks
uint m_sizeOfEachBlock; // Size of each block
uint m_numFreeBlocks; // Num of remaining blocks
uint m_numInitialized; // Num of initialized blocks
uchar* m_memStart; // Beginning of memory pool
uchar* m_memEnd; // End of memory pool
uchar* m_next; // Num of next free block
// CRITICAL_SECTION m_CS;
public:
C4JMemoryPoolFixed()
{
m_numOfBlocks = 0;
m_sizeOfEachBlock = 0;
m_numFreeBlocks = 0;
m_numInitialized = 0;
m_memStart = NULL;
m_memEnd = NULL;
m_next = 0;
}
C4JMemoryPoolFixed(uint sizeOfEachBlock, uint numOfBlocks)
{
CreatePool(sizeOfEachBlock, numOfBlocks);
}
~C4JMemoryPoolFixed() { DestroyPool(); }
void CreatePool(uint sizeOfEachBlock, uint numOfBlocks)
{
assert(sizeOfEachBlock >= 4); // has to be at least the size of an int, for book keeping
m_numOfBlocks = numOfBlocks;
m_sizeOfEachBlock = sizeOfEachBlock;
m_numFreeBlocks = numOfBlocks;
m_numInitialized = 0;
m_memStart = new uchar[ m_sizeOfEachBlock *
m_numOfBlocks ];
m_memEnd = m_memStart + (m_sizeOfEachBlock * m_numOfBlocks);
m_next = m_memStart;
// InitializeCriticalSection(&m_CS);
}
void DestroyPool()
{
delete[] m_memStart;
m_memStart = NULL;
}
uchar* AddrFromIndex(uint i) const
{
return m_memStart + ( i * m_sizeOfEachBlock );
}
uint IndexFromAddr(const uchar* p) const
{
return (((uint)(p - m_memStart)) / m_sizeOfEachBlock);
}
virtual void* Alloc(size_t size)
{
if(size > m_sizeOfEachBlock)
return ::malloc(size);
// EnterCriticalSection(&m_CS);
if (m_numInitialized < m_numOfBlocks )
{
uint* p = (uint*)AddrFromIndex( m_numInitialized );
*p = m_numInitialized + 1;
m_numInitialized++;
}
void* ret = NULL;
if ( m_numFreeBlocks > 0 )
{
ret = (void*)m_next;
--m_numFreeBlocks;
if (m_numFreeBlocks!=0)
{
m_next = AddrFromIndex( *((uint*)m_next) );
}
else
{
m_next = NULL;
}
}
// LeaveCriticalSection(&m_CS);
return ret;
}
virtual void Free(void* ptr)
{
if(ptr < m_memStart || ptr > m_memEnd)
{
::free(ptr);
return;
}
// EnterCriticalSection(&m_CS);
if (m_next != NULL)
{
(*(uint*)ptr) = IndexFromAddr( m_next );
m_next = (uchar*)ptr;
}
else
{
*((uint*)ptr) = m_numOfBlocks;
m_next = (uchar*)ptr;
}
++m_numFreeBlocks;
// LeaveCriticalSection(&m_CS);
}
}; // End pool class
// this pool will constantly grow until it is reset (automatically when all allocs have been "freed")
class C4JMemoryPoolGrow : public C4JMemoryPool
{
uint32_t m_totalSize;
uint32_t m_memUsed;
uint32_t m_numAllocations;
uint8_t* m_pMemory;
uint32_t m_currentOffset;
public:
C4JMemoryPoolGrow(uint32_t size = 64*1024)
{
size = Align(size, 4);
m_totalSize = size;
m_pMemory = new uint8_t[size];
m_currentOffset = 0;
m_memUsed = 0;
m_numAllocations = 0;
}
virtual void* Alloc(size_t size)
{
size = Align(size, 4); // 4 byte align the memory
assert((m_currentOffset + size) < m_totalSize); // make sure we haven't ran out of space
void* returnMem = &m_pMemory[m_currentOffset]; // grab the return memory
m_currentOffset += size;
m_numAllocations++;
return returnMem;
}
virtual void Free(void* ptr)
{
m_numAllocations--;
if(m_numAllocations == 0)
m_currentOffset = 0; // reset the pool when we reach zero allocations
}
};

View File

@@ -0,0 +1,113 @@
#pragma once
#include "..\Minecraft.Client\Common\C4JMemoryPool.h"
// Custom allocator, takes a C4JMemoryPool class, which can be one of a number of pool implementations.
template <class T>
class C4JPoolAllocator
{
public:
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
//! A struct to construct an allocator for a different type.
template<typename U>
struct rebind { typedef C4JPoolAllocator<U> other; };
C4JMemoryPool* m_pPool;
bool m_selfAllocated;
C4JPoolAllocator( C4JMemoryPool* pool = new C4JMemoryPoolFixed(32, 4096 )) : m_pPool( pool ), m_selfAllocated(true)
{
printf("allocated mempool\n");
}
template<typename U>
C4JPoolAllocator(C4JPoolAllocator<U> const& obj) : m_pPool( obj.m_pPool ), m_selfAllocated(false) // copy constructor
{
printf("C4JPoolAllocator constructed from 0x%08x\n", &obj);
assert(obj.m_pPool);
}
private:
public:
~C4JPoolAllocator()
{
if(m_selfAllocated)
delete m_pPool;
}
pointer address( reference r ) const { return &r; }
const_pointer address( const_reference r ) const { return &r; }
pointer allocate( size_type n, const void* /*hint*/=0 )
{
assert(m_pPool);
return (pointer)m_pPool->Alloc(n * sizeof(T));
}
void deallocate( pointer p, size_type /*n*/ )
{
assert(m_pPool);
m_pPool->Free(p);
}
void construct( pointer p, const T& val )
{
new (p) T(val);
}
void destroy( pointer p )
{
p->~T();
}
size_type max_size() const
{
return ULONG_MAX / sizeof(T);
}
};
template <class T>
bool
operator==( const C4JPoolAllocator<T>& left, const C4JPoolAllocator<T>& right )
{
if (left.m_pPool == right.m_pPool)
{
return true;
}
return false;
}
template <class T>
bool
operator!=( const C4JPoolAllocator<T>& left, const C4JPoolAllocator<T>& right)
{
if (left.m_pPool != right.m_pPool)
{
return true;
}
return false;
}

View File

@@ -0,0 +1,366 @@
#include "stdafx.h"
#include "ColourTable.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
unordered_map<wstring,eMinecraftColour> ColourTable::s_colourNamesMap;
wchar_t *ColourTable::ColourTableElements[eMinecraftColour_COUNT] =
{
L"NOTSET",
L"Foliage_Evergreen",
L"Foliage_Birch",
L"Foliage_Default",
L"Foliage_Common",
L"Foliage_Ocean",
L"Foliage_Plains",
L"Foliage_Desert",
L"Foliage_ExtremeHills",
L"Foliage_Forest",
L"Foliage_Taiga",
L"Foliage_Swampland",
L"Foliage_River",
L"Foliage_Hell",
L"Foliage_Sky",
L"Foliage_FrozenOcean",
L"Foliage_FrozenRiver",
L"Foliage_IcePlains",
L"Foliage_IceMountains",
L"Foliage_MushroomIsland",
L"Foliage_MushroomIslandShore",
L"Foliage_Beach",
L"Foliage_DesertHills",
L"Foliage_ForestHills",
L"Foliage_TaigaHills",
L"Foliage_ExtremeHillsEdge",
L"Foliage_Jungle",
L"Foliage_JungleHills",
L"Grass_Common",
L"Grass_Ocean",
L"Grass_Plains",
L"Grass_Desert",
L"Grass_ExtremeHills",
L"Grass_Forest",
L"Grass_Taiga",
L"Grass_Swampland",
L"Grass_River",
L"Grass_Hell",
L"Grass_Sky",
L"Grass_FrozenOcean",
L"Grass_FrozenRiver",
L"Grass_IcePlains",
L"Grass_IceMountains",
L"Grass_MushroomIsland",
L"Grass_MushroomIslandShore",
L"Grass_Beach",
L"Grass_DesertHills",
L"Grass_ForestHills",
L"Grass_TaigaHills",
L"Grass_ExtremeHillsEdge",
L"Grass_Jungle",
L"Grass_JungleHills",
L"Water_Ocean",
L"Water_Plains",
L"Water_Desert",
L"Water_ExtremeHills",
L"Water_Forest",
L"Water_Taiga",
L"Water_Swampland",
L"Water_River",
L"Water_Hell",
L"Water_Sky",
L"Water_FrozenOcean",
L"Water_FrozenRiver",
L"Water_IcePlains",
L"Water_IceMountains",
L"Water_MushroomIsland",
L"Water_MushroomIslandShore",
L"Water_Beach",
L"Water_DesertHills",
L"Water_ForestHills",
L"Water_TaigaHills",
L"Water_ExtremeHillsEdge",
L"Water_Jungle",
L"Water_JungleHills",
L"Sky_Ocean",
L"Sky_Plains",
L"Sky_Desert",
L"Sky_ExtremeHills",
L"Sky_Forest",
L"Sky_Taiga",
L"Sky_Swampland",
L"Sky_River",
L"Sky_Hell",
L"Sky_Sky",
L"Sky_FrozenOcean",
L"Sky_FrozenRiver",
L"Sky_IcePlains",
L"Sky_IceMountains",
L"Sky_MushroomIsland",
L"Sky_MushroomIslandShore",
L"Sky_Beach",
L"Sky_DesertHills",
L"Sky_ForestHills",
L"Sky_TaigaHills",
L"Sky_ExtremeHillsEdge",
L"Sky_Jungle",
L"Sky_JungleHills",
L"Tile_RedstoneDust",
L"Tile_RedstoneDustUnlit",
L"Tile_RedstoneDustLitMin",
L"Tile_RedstoneDustLitMax",
L"Tile_StemMin",
L"Tile_StemMax",
L"Tile_WaterLily",
L"Sky_Dawn_Dark",
L"Sky_Dawn_Bright",
L"Material_None",
L"Material_Grass",
L"Material_Sand",
L"Material_Cloth",
L"Material_Fire",
L"Material_Ice",
L"Material_Metal",
L"Material_Plant",
L"Material_Snow",
L"Material_Clay",
L"Material_Dirt",
L"Material_Stone",
L"Material_Water",
L"Material_Wood",
L"Material_Emerald",
L"Particle_Note_00",
L"Particle_Note_01",
L"Particle_Note_02",
L"Particle_Note_03",
L"Particle_Note_04",
L"Particle_Note_05",
L"Particle_Note_06",
L"Particle_Note_07",
L"Particle_Note_08",
L"Particle_Note_09",
L"Particle_Note_10",
L"Particle_Note_11",
L"Particle_Note_12",
L"Particle_Note_13",
L"Particle_Note_14",
L"Particle_Note_15",
L"Particle_Note_16",
L"Particle_Note_17",
L"Particle_Note_18",
L"Particle_Note_19",
L"Particle_Note_20",
L"Particle_Note_21",
L"Particle_Note_22",
L"Particle_Note_23",
L"Particle_Note_24",
L"Particle_NetherPortal",
L"Particle_EnderPortal",
L"Particle_Smoke",
L"Particle_Ender",
L"Particle_Explode",
L"Particle_HugeExplosion",
L"Particle_DripWater",
L"Particle_DripLavaStart",
L"Particle_DripLavaEnd",
L"Particle_EnchantmentTable",
L"Particle_DragonBreathMin",
L"Particle_DragonBreathMax",
L"Particle_Suspend",
L"Particle_CritStart", // arrow in air
L"Particle_CritEnd", // arrow in air
L"Effect_MovementSpeed",
L"Effect_MovementSlowDown",
L"Effect_DigSpeed",
L"Effect_DigSlowdown",
L"Effect_DamageBoost",
L"Effect_Heal",
L"Effect_Harm",
L"Effect_Jump",
L"Effect_Confusion",
L"Effect_Regeneration",
L"Effect_DamageResistance",
L"Effect_FireResistance",
L"Effect_WaterBreathing",
L"Effect_Invisiblity",
L"Effect_Blindness",
L"Effect_NightVision",
L"Effect_Hunger",
L"Effect_Weakness",
L"Effect_Poison",
L"Potion_BaseColour",
L"Mob_Creeper_Colour1",
L"Mob_Creeper_Colour2",
L"Mob_Skeleton_Colour1",
L"Mob_Skeleton_Colour2",
L"Mob_Spider_Colour1",
L"Mob_Spider_Colour2",
L"Mob_Zombie_Colour1",
L"Mob_Zombie_Colour2",
L"Mob_Slime_Colour1",
L"Mob_Slime_Colour2",
L"Mob_Ghast_Colour1",
L"Mob_Ghast_Colour2",
L"Mob_PigZombie_Colour1",
L"Mob_PigZombie_Colour2",
L"Mob_Enderman_Colour1",
L"Mob_Enderman_Colour2",
L"Mob_CaveSpider_Colour1",
L"Mob_CaveSpider_Colour2",
L"Mob_Silverfish_Colour1",
L"Mob_Silverfish_Colour2",
L"Mob_Blaze_Colour1",
L"Mob_Blaze_Colour2",
L"Mob_LavaSlime_Colour1",
L"Mob_LavaSlime_Colour2",
L"Mob_Pig_Colour1",
L"Mob_Pig_Colour2",
L"Mob_Sheep_Colour1",
L"Mob_Sheep_Colour2",
L"Mob_Cow_Colour1",
L"Mob_Cow_Colour2",
L"Mob_Chicken_Colour1",
L"Mob_Chicken_Colour2",
L"Mob_Squid_Colour1",
L"Mob_Squid_Colour2",
L"Mob_Wolf_Colour1",
L"Mob_Wolf_Colour2",
L"Mob_MushroomCow_Colour1",
L"Mob_MushroomCow_Colour2",
L"Mob_Ocelot_Colour1",
L"Mob_Ocelot_Colour2",
L"Mob_Villager_Colour1",
L"Mob_Villager_Colour2",
L"Armour_Default_Leather_Colour",
L"Under_Water_Clear_Colour",
L"Under_Lava_Clear_Colour",
L"In_Cloud_Base_Colour",
L"Under_Water_Fog_Colour",
L"Under_Lava_Fog_Colour",
L"In_Cloud_Fog_Colour",
L"Default_Fog_Colour",
L"Nether_Fog_Colour",
L"End_Fog_Colour",
L"Sign_Text",
L"Map_Text",
L"HTMLColor_0",
L"HTMLColor_1",
L"HTMLColor_2",
L"HTMLColor_3",
L"HTMLColor_4",
L"HTMLColor_5",
L"HTMLColor_6",
L"HTMLColor_7",
L"HTMLColor_8",
L"HTMLColor_9",
L"HTMLColor_a",
L"HTMLColor_b",
L"HTMLColor_c",
L"HTMLColor_d",
L"HTMLColor_e",
L"HTMLColor_f",
L"HTMLColor_dark_0",
L"HTMLColor_dark_1",
L"HTMLColor_dark_2",
L"HTMLColor_dark_3",
L"HTMLColor_dark_4",
L"HTMLColor_dark_5",
L"HTMLColor_dark_6",
L"HTMLColor_dark_7",
L"HTMLColor_dark_8",
L"HTMLColor_dark_9",
L"HTMLColor_dark_a",
L"HTMLColor_dark_b",
L"HTMLColor_dark_c",
L"HTMLColor_dark_d",
L"HTMLColor_dark_e",
L"HTMLColor_dark_f",
L"HTMLColor_T1",
L"HTMLColor_T2",
L"HTMLColor_T3",
L"HTMLColor_Black",
L"HTMLColor_White",
L"Color_EnchantText",
L"Color_EnchantTextFocus",
L"Color_EnchantTextDisabled",
L"Color_RenamedItemTitle",
};
void ColourTable::staticCtor()
{
for(unsigned int i = eMinecraftColour_NOT_SET; i < eMinecraftColour_COUNT; ++i)
{
s_colourNamesMap.insert( unordered_map<wstring,eMinecraftColour>::value_type( ColourTableElements[i], (eMinecraftColour)i) );
}
}
ColourTable::ColourTable(PBYTE pbData, DWORD dwLength)
{
loadColoursFromData(pbData, dwLength);
}
ColourTable::ColourTable(ColourTable *defaultColours, PBYTE pbData, DWORD dwLength)
{
// 4J Stu - Default the colours that of the table passed in
XMemCpy( (void *)m_colourValues, (void *)defaultColours->m_colourValues, sizeof(int) * eMinecraftColour_COUNT);
loadColoursFromData(pbData, dwLength);
}
void ColourTable::loadColoursFromData(PBYTE pbData, DWORD dwLength)
{
byteArray src(pbData, dwLength);
ByteArrayInputStream bais(src);
DataInputStream dis(&bais);
int versionNumber = dis.readInt();
int coloursCount = dis.readInt();
for(int i = 0; i < coloursCount; ++i)
{
wstring colourId = dis.readUTF();
int colourValue = dis.readInt();
setColour(colourId, colourValue);
AUTO_VAR(it,s_colourNamesMap.find(colourId));
}
bais.reset();
}
void ColourTable::setColour(const wstring &colourName, int value)
{
AUTO_VAR(it,s_colourNamesMap.find(colourName));
if(it != s_colourNamesMap.end())
{
m_colourValues[(int)it->second] = value;
}
}
void ColourTable::setColour(const wstring &colourName, const wstring &value)
{
setColour(colourName, _fromHEXString<int>(value));
}
unsigned int ColourTable::getColour(eMinecraftColour id)
{
return m_colourValues[(int)id];
}

View File

@@ -0,0 +1,23 @@
#pragma once
class ColourTable
{
private:
unsigned int m_colourValues[eMinecraftColour_COUNT];
static wchar_t *ColourTableElements[eMinecraftColour_COUNT];
static unordered_map<wstring,eMinecraftColour> s_colourNamesMap;
public:
static void staticCtor();
ColourTable(PBYTE pbData, DWORD dwLength);
ColourTable(ColourTable *defaultColours, PBYTE pbData, DWORD dwLength);
unsigned int getColour(eMinecraftColour id);
unsigned int getColor(eMinecraftColour id) { return getColour(id); }
void loadColoursFromData(PBYTE pbData, DWORD dwLength);
void setColour(const wstring &colourName, int value);
void setColour(const wstring &colourName, const wstring &value);
};

View File

@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonMedia", "CommonMedia.vcxproj", "{21BBD32C-AF5E-4741-8B80-3B73FC0D0F27}"
EndProject
Global
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 2
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://tfs_server:8080/tfs/storiespark
SccProjectUniqueName0 = CommonMedia.vcxproj
SccLocalPath0 = .
SccLocalPath1 = .
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{21BBD32C-AF5E-4741-8B80-3B73FC0D0F27}.Debug|Win32.ActiveCfg = Debug|Win32
{21BBD32C-AF5E-4741-8B80-3B73FC0D0F27}.Debug|Win32.Build.0 = Debug|Win32
{21BBD32C-AF5E-4741-8B80-3B73FC0D0F27}.Release|Win32.ActiveCfg = Release|Win32
{21BBD32C-AF5E-4741-8B80-3B73FC0D0F27}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="Media\ChestMenu720.swf" />
<None Include="Media\CreateWorldMenu720.swf" />
<None Include="Media\CreativeMenu720.swf" />
<None Include="Media\DebugMenu720.swf" />
<None Include="Media\FullscreenProgress720.swf" />
<None Include="Media\HUD720.swf" />
<None Include="Media\InventoryMenu720.swf" />
<None Include="Media\languages.loc" />
<None Include="Media\LaunchMoreOptionsMenu720.swf" />
<None Include="Media\LoadMenu720.swf" />
<None Include="Media\LoadOrJoinMenu720.swf" />
<None Include="Media\MainMenu720.swf" />
<None Include="Media\media.arc" />
<None Include="Media\Panorama720.swf" />
<None Include="Media\PauseMenu720.swf" />
<None Include="Media\skin.swf" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Media\strings.resx" />
</ItemGroup>
<ItemGroup>
<Text Include="Media\media.txt" />
<Text Include="Media\strings_begin.txt" />
<Text Include="Media\strings_Controls.txt" />
<Text Include="Media\strings_Credits.txt" />
<Text Include="Media\strings_Descriptions.txt" />
<Text Include="Media\strings_end.txt" />
<Text Include="Media\strings_HowToPlay.txt" />
<Text Include="Media\strings_ItemsAndTiles.txt" />
<Text Include="Media\strings_Misc.txt" />
<Text Include="Media\strings_PotionsAndEnchantments.txt" />
<Text Include="Media\strings_Tips.txt" />
<Text Include="Media\strings_Tooltips.txt" />
<Text Include="Media\strings_Tutorial.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Durango\strings.h" />
<ClInclude Include="..\Orbis\strings.h" />
<ClInclude Include="..\PS3\strings.h" />
<ClInclude Include="..\Windows64\strings.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{21BBD32C-AF5E-4741-8B80-3B73FC0D0F27}</ProjectGuid>
<Keyword>MakeFileProj</Keyword>
<SccProjectName>SAK</SccProjectName>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeBuildCommandLine>echo Creating languages.loc
copy .\Media\strings.resx .\Media\en-EN.lang
copy .\Media\fr-FR\strings.resx .\Media\fr-FR\fr-FR.lang
copy .\Media\ja-JP\strings.resx .\Media\ja-JP\ja-JP.lang
..\..\..\Tools\NewLocalisationPacker.exe --static .\Media .\Media\languages.loc
echo Making archive
..\..\..\Tools\ArchiveFilePacker.exe -cd $(ProjectDir)\Media media.arc media.txt
echo Copying Durango strings.h
copy .\Media\strings.h ..\Durango\strings.h
echo Copying PS3 strings.h
copy .\Media\strings.h ..\PS3\strings.h
echo Copying PS4 strings.h
copy .\Media\strings.h ..\Orbis\strings.h
echo Copying Win strings.h
copy .\Media\strings.h ..\Windows64\strings.h</NMakeBuildCommandLine>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="IggyMedia">
<UniqueIdentifier>{55c7ab2e-b3e5-4aed-9ffe-3308591d9c34}</UniqueIdentifier>
</Filter>
<Filter Include="Strings">
<UniqueIdentifier>{eaa0eb72-0b27-4080-ad53-f68e42f37ba8}</UniqueIdentifier>
</Filter>
<Filter Include="Archive">
<UniqueIdentifier>{711ad95b-eb56-4e18-b001-34ad7b8075a3}</UniqueIdentifier>
</Filter>
<Filter Include="Archive\Win64">
<UniqueIdentifier>{1432ec3d-c5d0-46da-91b6-e7737095a97e}</UniqueIdentifier>
</Filter>
<Filter Include="Archive\PS4">
<UniqueIdentifier>{4b2aeaf1-04d7-454d-b2d9-08364799831c}</UniqueIdentifier>
</Filter>
<Filter Include="Archive\PS3">
<UniqueIdentifier>{4b0eaef6-fa2f-4605-b0da-a81ffb5659bc}</UniqueIdentifier>
</Filter>
<Filter Include="Archive\Durango">
<UniqueIdentifier>{bf1c74da-21f1-4bdd-98ed-83457946e4cc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="Media\ChestMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\CreateWorldMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\CreativeMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\DebugMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\FullscreenProgress720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\HUD720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\InventoryMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\media.arc">
<Filter>Archive</Filter>
</None>
<None Include="Media\languages.loc">
<Filter>Archive</Filter>
</None>
<None Include="Media\skin.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\MainMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\Panorama720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\LoadOrJoinMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\LaunchMoreOptionsMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\LoadMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
<None Include="Media\PauseMenu720.swf">
<Filter>IggyMedia</Filter>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Media\strings.resx">
<Filter>Strings</Filter>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Text Include="Media\strings_begin.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Controls.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Credits.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Descriptions.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_end.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_HowToPlay.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_ItemsAndTiles.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Misc.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_PotionsAndEnchantments.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Tips.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Tooltips.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\strings_Tutorial.txt">
<Filter>Strings</Filter>
</Text>
<Text Include="Media\media.txt">
<Filter>Archive</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Durango\strings.h">
<Filter>Archive\Durango</Filter>
</ClInclude>
<ClInclude Include="..\PS3\strings.h">
<Filter>Archive\PS3</Filter>
</ClInclude>
<ClInclude Include="..\Orbis\strings.h">
<Filter>Archive\PS4</Filter>
</ClInclude>
<ClInclude Include="..\Windows64\strings.h">
<Filter>Archive\Win64</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,9 @@
#include "stdafx.h"
#include "ConsoleGameMode.h"
#include "..\Common\Tutorial\Tutorial.h"
ConsoleGameMode::ConsoleGameMode(int iPad, Minecraft *minecraft, ClientConnection *connection)
: TutorialMode(iPad, minecraft, connection)
{
tutorial = new Tutorial(iPad);
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "..\Common\Tutorial\TutorialMode.h"
class ConsoleGameMode : public TutorialMode
{
public:
ConsoleGameMode(int iPad, Minecraft *minecraft, ClientConnection *connection);
virtual bool isImplemented() { return true; }
};

View File

@@ -0,0 +1,72 @@
#pragma once
enum eAward
{
eAward_TakingInventory=0,
eAward_GettingWood,
eAward_Benchmarking,
eAward_TimeToMine,
eAward_HotTopic,
eAward_AquireHardware,
eAward_TimeToFarm,
eAward_BakeBread,
eAward_TheLie,
eAward_GettingAnUpgrade,
eAward_DeliciousFish,
eAward_OnARail,
eAward_TimeToStrike,
eAward_MonsterHunter,
eAward_CowTipper,
eAward_WhenPigsFly,
eAward_LeaderOfThePack,
eAward_MOARTools,
eAward_DispenseWithThis,
eAward_InToTheNether,
eAward_mine100Blocks,
eAward_kill10Creepers,
eAward_eatPorkChop,
eAward_play100Days,
eAward_arrowKillCreeper,
eAward_socialPost,
#ifndef _XBOX
// 4J Stu - Does not map to any Xbox achievements
eAward_snipeSkeleton,
eAward_diamonds,
eAward_portal,
eAward_ghast,
eAward_blazeRod,
eAward_potion,
eAward_theEnd,
eAward_winGame,
eAward_enchantments,
eAward_overkill,
eAward_bookcase,
#endif
#ifdef _EXTENDED_ACHIEVEMENTS
eAward_adventuringTime,
eAward_repopulation,
//eAward_porkChop,
eAward_diamondsToYou,
//eAward_passingTheTime,
//eAward_archer,
eAward_theHaggler,
eAward_potPlanter,
eAward_itsASign,
eAward_ironBelly,
eAward_haveAShearfulDay,
eAward_rainbowCollection,
eAward_stayinFrosty,
eAward_chestfulOfCobblestone,
eAward_renewableEnergy,
eAward_musicToMyEars,
eAward_bodyGuard,
eAward_ironMan,
eAward_zombieDoctor,
eAward_lionTamer,
#endif
eAward_Max,
};

View File

@@ -0,0 +1,42 @@
#pragma once
enum eDebugSetting
{
eDebugSetting_LoadSavesFromDisk,
eDebugSetting_WriteSavesToDisk,
eDebugSetting_FreezePlayers, //eDebugSetting_InterfaceOff,
eDebugSetting_Safearea,
eDebugSetting_MobsDontAttack,
eDebugSetting_FreezeTime,
eDebugSetting_DisableWeather,
eDebugSetting_CraftAnything,
eDebugSetting_UseDpadForDebug,
eDebugSetting_MobsDontTick,
eDebugSetting_InstantDestroy,
eDebugSetting_ShowUIConsole,
eDebugSetting_DistributableSave,
eDebugSetting_DebugLeaderboards,
eDebugSetting_EnableHeightWaterBiomeOverride, //eDebugSetting_TipsAlwaysOn,
eDebugSetting_SuperflatNether,
//eDebugSetting_LightDarkBackground,
eDebugSetting_RegularLightning,
eDebugSetting_GoToNether,
//eDebugSetting_GoToEnd,
eDebugSetting_GoToOverworld,
eDebugSetting_UnlockAllDLC, // eDebugSetting_ToggleFont,
eDebugSetting_ShowUIMarketingGuide,
eDebugSetting_Max,
};
enum eDebugButton
{
eDebugButton_Theme=0,
eDebugButton_Avatar_Item_1,
eDebugButton_Avatar_Item_2,
eDebugButton_Avatar_Item_3,
eDebugButton_Gamerpic_1,
eDebugButton_Gamerpic_2,
eDebugButton_CheckTips,
eDebugButton_WipeLeaderboards,
eDebugButton_Max,
};

View File

@@ -0,0 +1,40 @@
#include "stdafx.h"
//--------------------------------------------------------------------------------------
// Name: DebugSpewV()
// Desc: Internal helper function
//--------------------------------------------------------------------------------------
#ifndef _CONTENT_PACKAGE
static VOID DebugSpewV( const CHAR* strFormat, const va_list pArgList )
{
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
assert(0);
#else
CHAR str[2048];
// Use the secure CRT to avoid buffer overruns. Specify a count of
// _TRUNCATE so that too long strings will be silently truncated
// rather than triggering an error.
_vsnprintf_s( str, _TRUNCATE, strFormat, pArgList );
OutputDebugStringA( str );
#endif
}
#endif
//--------------------------------------------------------------------------------------
// Name: DebugSpew()
// Desc: Prints formatted debug spew
//--------------------------------------------------------------------------------------
#ifdef _Printf_format_string_ // VC++ 2008 and later support this annotation
VOID CDECL DebugSpew( _In_z_ _Printf_format_string_ const CHAR* strFormat, ... )
#else
VOID CDECL DebugPrintf( const CHAR* strFormat, ... )
#endif
{
#ifndef _CONTENT_PACKAGE
va_list pArgList;
va_start( pArgList, strFormat );
DebugSpewV( strFormat, pArgList );
va_end( pArgList );
#endif
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,911 @@
#pragma once
using namespace std;
#include "Audio/Consoles_SoundEngine.h"
#include <xuiapp.h>
#include "..\Common\Tutorial\TutorialEnum.h"
#ifdef _XBOX
#include "..\Common\XUI\XUI_Helper.h"
#include "..\Common\XUI\XUI_HelpCredits.h"
#endif
#include "UI\UIStructs.h"
#include "..\..\Minecraft.World\DisconnectPacket.h"
#include <xsocialpost.h>
#include "..\StringTable.h"
#include "..\Common\DLC\DLCManager.h"
#include "..\Common\GameRules\ConsoleGameRulesConstants.h"
#include "..\Common\GameRules\GameRuleManager.h"
#include "..\SkinBox.h"
#include "..\ArchiveFile.h"
typedef struct _JoinFromInviteData
{
DWORD dwUserIndex; // dwUserIndex
DWORD dwLocalUsersMask; // dwUserMask
const INVITE_INFO *pInviteInfo; // pInviteInfo
}
JoinFromInviteData;
class Player;
class Inventory;
class Level;
class FurnaceTileEntity;
class Container;
class DispenserTileEntity;
class SignTileEntity;
class BrewingStandTileEntity;
class LocalPlayer;
class DLCPack;
class LevelRuleset;
class ConsoleSchematicFile;
class Model;
class ModelPart;
class StringTable;
class Merchant;
class CMinecraftAudio;
class CMinecraftApp
#ifdef _XBOX
: public CXuiModule
#endif
{
private:
static int s_iHTMLFontSizesA[eHTMLSize_COUNT];
public:
CMinecraftApp();
static const float fSafeZoneX; // 5% of 1280
static const float fSafeZoneY; // 5% of 720
typedef std::vector <PMEMDATA> VMEMFILES;
typedef std::vector <PNOTIFICATION> VNOTIFICATIONS;
// storing skin files
std::vector <wstring > vSkinNames;
DLCManager m_dlcManager;
// storing credits text from the DLC
std::vector <wstring > m_vCreditText; // hold the credit text lines so we can avoid duplicating them
// In builds prior to TU5, the size of the GAME_SETTINGS struct was 204 bytes. We added a few new values to the internal struct in TU5, and even though we
// changed the size of the ucUnused array to be decreased by the size of the values we added, the packing of the struct has introduced some extra
// padding that resulted in the GAME_SETTINGS struct being 208 bytes. The knock-on effect from this was that all the stats, which come after the game settings
// in the profile data, we being read offset by 4 bytes. We need to ensure that the GAME_SETTINGS struct does not grow larger than 204 bytes or if we need it
// to then we need to rebuild the profile data completely and increase the profile version. There should be enough free space to grow larger for a few more updates
// as long as we take into account the padding issues and check that settings are still stored at the same positions when we read them
static const int GAME_SETTINGS_PROFILE_DATA_BYTES = 204;
#ifdef _EXTENDED_ACHIEVEMENTS
/* 4J-JEV:
* We need more space in the profile data because of the new achievements and statistics
* necessary for the new expanded achievement set.
*/
static const int GAME_DEFINED_PROFILE_DATA_BYTES = 2*972; // per user
#else
static const int GAME_DEFINED_PROFILE_DATA_BYTES = 972; // per user
#endif
unsigned int uiGameDefinedDataChangedBitmask;
void DebugPrintf(const char *szFormat, ...);
void DebugPrintfVerbose(bool bVerbose, const char *szFormat, ...); // Conditional printf
void DebugPrintf(int user, const char *szFormat, ...);
static const int USER_NONE = 0; // disables printf
static const int USER_GENERAL = 1;
static const int USER_JV = 2;
static const int USER_MH = 3;
static const int USER_PB = 4;
static const int USER_RR = 5;
static const int USER_SR = 6;
static const int USER_UI = 7; // 4J Stu - This also makes it appear on the UI console
void HandleButtonPresses();
bool IntroRunning() { return m_bIntroRunning;}
void SetIntroRunning(bool bSet) {m_bIntroRunning=bSet;}
#ifdef _CONTENT_PACKAGE
#ifndef _FINAL_BUILD
bool PartnernetPasswordRunning() { return m_bPartnernetPasswordRunning;}
void SetPartnernetPasswordRunning(bool bSet) {m_bPartnernetPasswordRunning=bSet;}
#endif
#endif
bool IsAppPaused();
void SetAppPaused(bool val);
static int DisplaySavingMessage(LPVOID pParam,const C4JStorage::ESavingMessage eMsg, int iPad);
bool GetGameStarted() {return m_bGameStarted;}
void SetGameStarted(bool bVal) { if(bVal) DebugPrintf("SetGameStarted - true\n"); else DebugPrintf("SetGameStarted - false\n"); m_bGameStarted = bVal; m_bIsAppPaused = !bVal;}
int GetLocalPlayerCount(void);
bool LoadInventoryMenu(int iPad,shared_ptr<LocalPlayer> player, bool bNavigateBack=false);
bool LoadCreativeMenu(int iPad,shared_ptr<LocalPlayer> player,bool bNavigateBack=false);
bool LoadEnchantingMenu(int iPad,shared_ptr<Inventory> inventory, int x, int y, int z, Level *level);
bool LoadFurnaceMenu(int iPad,shared_ptr<Inventory> inventory, shared_ptr<FurnaceTileEntity> furnace);
bool LoadBrewingStandMenu(int iPad,shared_ptr<Inventory> inventory, shared_ptr<BrewingStandTileEntity> brewingStand);
bool LoadContainerMenu(int iPad,shared_ptr<Container> inventory, shared_ptr<Container> container);
bool LoadTrapMenu(int iPad,shared_ptr<Container> inventory, shared_ptr<DispenserTileEntity> trap);
bool LoadCrafting2x2Menu(int iPad,shared_ptr<LocalPlayer> player);
bool LoadCrafting3x3Menu(int iPad,shared_ptr<LocalPlayer> player, int x, int y, int z);
bool LoadSignEntryMenu(int iPad,shared_ptr<SignTileEntity> sign);
bool LoadRepairingMenu(int iPad,shared_ptr<Inventory> inventory, Level *level, int x, int y, int z);
bool LoadTradingMenu(int iPad, shared_ptr<Inventory> inventory, shared_ptr<Merchant> trader, Level *level);
bool GetTutorialMode() { return m_bTutorialMode;}
void SetTutorialMode(bool bSet) {m_bTutorialMode=bSet;}
void SetSpecialTutorialCompletionFlag(int iPad, int index);
static LPCWSTR GetString(int iID);
eGameMode GetGameMode() { return m_eGameMode;}
void SetGameMode(eGameMode eMode) { m_eGameMode=eMode;}
eXuiAction GetGlobalXuiAction() {return m_eGlobalXuiAction;}
void SetGlobalXuiAction(eXuiAction action) {m_eGlobalXuiAction=action;}
eXuiAction GetXuiAction(int iPad) {return m_eXuiAction[iPad];}
void SetAction(int iPad, eXuiAction action, LPVOID param = NULL);
void SetTMSAction(int iPad, eTMSAction action) {m_eTMSAction[iPad]=action; }
eTMSAction GetTMSAction(int iPad) {return m_eTMSAction[iPad];}
eXuiServerAction GetXuiServerAction(int iPad) {return m_eXuiServerAction[iPad];}
LPVOID GetXuiServerActionParam(int iPad) {return m_eXuiServerActionParam[iPad];}
void SetXuiServerAction(int iPad, eXuiServerAction action, LPVOID param = NULL) {m_eXuiServerAction[iPad]=action; m_eXuiServerActionParam[iPad] = param;}
eXuiServerAction GetGlobalXuiServerAction() {return m_eGlobalXuiServerAction;}
void SetGlobalXuiServerAction(eXuiServerAction action) {m_eGlobalXuiServerAction=action;}
DisconnectPacket::eDisconnectReason GetDisconnectReason() { return m_disconnectReason; }
void SetDisconnectReason(DisconnectPacket::eDisconnectReason bVal) { m_disconnectReason = bVal; }
bool GetChangingSessionType() { return m_bChangingSessionType; }
void SetChangingSessionType(bool bVal) { m_bChangingSessionType = bVal; }
bool GetReallyChangingSessionType() { return m_bReallyChangingSessionType; }
void SetReallyChangingSessionType(bool bVal) { m_bReallyChangingSessionType = bVal; }
// 4J Stu - Added so that we can call this when a confirmation box is selected
static void SetActionConfirmed(LPVOID param);
void HandleXuiActions(void);
// 4J Stu - Functions used for Minecon and other promo work
bool GetLoadSavesFromFolderEnabled() { return m_bLoadSavesFromFolderEnabled; }
void SetLoadSavesFromFolderEnabled(bool bVal) { m_bLoadSavesFromFolderEnabled = bVal; }
// 4J Stu - Useful for debugging
bool GetWriteSavesToFolderEnabled() { return m_bWriteSavesToFolderEnabled; }
void SetWriteSavesToFolderEnabled(bool bVal) { m_bWriteSavesToFolderEnabled = bVal; }
bool GetMobsDontAttackEnabled() { return m_bMobsDontAttack; }
void SetMobsDontAttackEnabled(bool bVal) { m_bMobsDontAttack = bVal; }
bool GetUseDPadForDebug() { return m_bUseDPadForDebug; }
void SetUseDPadForDebug(bool bVal) { m_bUseDPadForDebug = bVal; }
bool GetMobsDontTickEnabled() { return m_bMobsDontTick; }
void SetMobsDontTickEnabled(bool bVal) { m_bMobsDontTick = bVal; }
bool GetFreezePlayers() { return m_bFreezePlayers; }
void SetFreezePlayers(bool bVal) { m_bFreezePlayers = bVal; }
// debug -0 show safe area
void ShowSafeArea(BOOL bShow)
{
#ifdef _XBOX
CXuiSceneBase::ShowSafeArea( bShow );
#endif
}
// 4J-PB - to capture the social post screenshot
virtual void CaptureScreenshot(int iPad) {};
//void GetPreviewImage(int iPad,XSOCIAL_PREVIEWIMAGE *preview);
void InitGameSettings();
static int OldProfileVersionCallback(LPVOID pParam,unsigned char *pucData, const unsigned short usVersion, const int iPad);
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__ )
static int DefaultOptionsCallback(LPVOID pParam,C4JStorage::PROFILESETTINGS *pSettings, const int iPad);
int SetDefaultOptions(C4JStorage::PROFILESETTINGS *pSettings,const int iPad,bool bWriteProfile=true);
#ifdef __ORBIS__
static int OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus,int iBlocksRequired);
int GetOptionsBlocksRequired(int iPad);
#else
static int OptionsDataCallback(LPVOID pParam,int iPad,unsigned short usVersion,C4JStorage::eOptionsCallback eStatus);
#endif
C4JStorage::eOptionsCallback GetOptionsCallbackStatus(int iPad);
void SetOptionsCallbackStatus(int iPad, C4JStorage::eOptionsCallback eStatus);
#else
static int DefaultOptionsCallback(LPVOID pParam,C_4JProfile::PROFILESETTINGS *pSettings, const int iPad);
int SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,const int iPad);
#endif
virtual void SetRichPresenceContext(int iPad, int contextId) = 0;
void SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucVal);
unsigned char GetGameSettings(int iPad,eGameSetting eVal);
unsigned char GetGameSettings(eGameSetting eVal); // for the primary pad
void SetPlayerSkin(int iPad,const wstring &name);
void SetPlayerSkin(int iPad,DWORD dwSkinId);
void SetPlayerCape(int iPad,const wstring &name);
void SetPlayerCape(int iPad,DWORD dwCapeId);
void SetPlayerFavoriteSkin(int iPad, int iIndex,unsigned int uiSkinID);
unsigned int GetPlayerFavoriteSkin(int iPad,int iIndex);
unsigned char GetPlayerFavoriteSkinsPos(int iPad);
void SetPlayerFavoriteSkinsPos(int iPad,int iPos);
unsigned int GetPlayerFavoriteSkinsCount(int iPad);
void ValidateFavoriteSkins(int iPad); // check the DLC is available for the skins
// Mash-up pack worlds hide/display
void HideMashupPackWorld(int iPad, unsigned int iMashupPackID);
void EnableMashupPackWorlds(int iPad);
unsigned int GetMashupPackWorlds(int iPad);
// Minecraft language select
void SetMinecraftLanguage(int iPad, unsigned char ucLanguage);
unsigned char GetMinecraftLanguage(int iPad);
// 4J-PB - set a timer when the user navigates the quickselect, so we can bring the opacity back to defaults for a short time
unsigned int GetOpacityTimer(int iPad) { return m_uiOpacityCountDown[iPad]; }
void SetOpacityTimer(int iPad) { m_uiOpacityCountDown[iPad]=120; } // 6 seconds
void TickOpacityTimer(int iPad) { if(m_uiOpacityCountDown[iPad]>0) m_uiOpacityCountDown[iPad]--;}
public:
wstring GetPlayerSkinName(int iPad);
DWORD GetPlayerSkinId(int iPad);
wstring GetPlayerCapeName(int iPad);
DWORD GetPlayerCapeId(int iPad);
DWORD GetAdditionalModelParts(int iPad);
void CheckGameSettingsChanged(bool bOverride5MinuteTimer=false, int iPad=XUSER_INDEX_ANY);
void ApplyGameSettingsChanged(int iPad);
void ClearGameSettingsChangedFlag(int iPad);
void ActionGameSettings(int iPad,eGameSetting eVal);
unsigned int GetGameSettingsDebugMask(int iPad=-1,bool bOverridePlayer=false);
void SetGameSettingsDebugMask(int iPad, unsigned int uiVal);
void ActionDebugMask(int iPad, bool bSetAllClear=false);
//
bool IsLocalMultiplayerAvailable();
// for sign in change monitoring
static void SignInChangeCallback(LPVOID pParam, bool bVal, unsigned int uiSignInData);
static void ClearSignInChangeUsersMask();
static int SignoutExitWorldThreadProc( void* lpParameter );
static int PrimaryPlayerSignedOutReturned(void *pParam, int iPad, const C4JStorage::EMessageResult);
static int EthernetDisconnectReturned(void *pParam, int iPad, const C4JStorage::EMessageResult);
static void ProfileReadErrorCallback(void *pParam);
// FATAL LOAD ERRORS
virtual void FatalLoadError();
// Notifications from the game listener to be passed to the qnet listener
static void NotificationsCallback(LPVOID pParam,DWORD dwNotification, unsigned int uiParam);
// for the ethernet being disconnected
static void LiveLinkChangeCallback(LPVOID pParam,BOOL bConnected);
bool GetLiveLinkRequired() {return m_bLiveLinkRequired;}
void SetLiveLinkRequired(bool required) {m_bLiveLinkRequired=required;}
static void UpsellReturnedCallback(LPVOID pParam, eUpsellType type, eUpsellResponse result, int iUserData);
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
static int NowDisplayFullVersionPurchase(void *pParam, bool bContinue, int iPad);
static int MustSignInFullVersionPurchaseReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
#endif
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
static int MustSignInFullVersionPurchaseReturnedExitTrial(void *pParam,int iPad,C4JStorage::EMessageResult result);
#endif
#ifdef _DEBUG_MENUS_ENABLED
bool DebugSettingsOn() { return m_bDebugOptions;}
#else
bool DebugSettingsOn() { return false;}
#endif
void SetDebugSequence(const char *pchSeq);
static int DebugInputCallback(LPVOID pParam);
//bool UploadFileToGlobalStorage(int iQuadrant, C4JStorage::eGlobalStorage eStorageFacility, wstring *wsFile );
// Installed DLC
bool StartInstallDLCProcess(int iPad);
static int DLCInstalledCallback(LPVOID pParam,int iOfferC,int iPad);
void HandleDLCLicenseChange();
static int DLCMountedCallback(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask);
void MountNextDLC(int iPad);
//static int DLCReadCallback(LPVOID pParam,C4JStorage::DLC_FILE_DETAILS *pDLCData);
void HandleDLC(DLCPack *pack);
bool DLCInstallPending() {return m_bDLCInstallPending;}
bool DLCInstallProcessCompleted() {return m_bDLCInstallProcessCompleted;}
void ClearDLCInstalled() { m_bDLCInstallProcessCompleted=false;}
static int MarketplaceCountsCallback(LPVOID pParam,C4JStorage::DLC_TMS_DETAILS *,int iPad);
bool AlreadySeenCreditText(const wstring &wstemp);
void ClearNewDLCAvailable(void) { m_bNewDLCAvailable=false; m_bSeenNewDLCTip=true;}
bool GetNewDLCAvailable() { return m_bNewDLCAvailable;}
void DisplayNewDLCTipAgain() { m_bSeenNewDLCTip=false;}
bool DisplayNewDLCTip() { if(!m_bSeenNewDLCTip) { m_bSeenNewDLCTip=true; return true;} else return false;}
// functions to store launch data, and to exit the game - required due to possibly being on a demo disc
virtual void StoreLaunchData();
virtual void ExitGame();
bool isXuidNotch(PlayerUID xuid);
bool isXuidDeadmau5(PlayerUID xuid);
void AddMemoryTextureFile(const wstring &wName, PBYTE pbData, DWORD dwBytes);
void RemoveMemoryTextureFile(const wstring &wName);
void GetMemFileDetails(const wstring &wName,PBYTE *ppbData,DWORD *pdwBytes);
bool IsFileInMemoryTextures(const wstring &wName);
// Texture Pack Data files (icon, banner, comparison shot & text)
void AddMemoryTPDFile(int iConfig,PBYTE pbData,DWORD dwBytes);
void RemoveMemoryTPDFile(int iConfig);
bool IsFileInTPD(int iConfig);
void GetTPD(int iConfig,PBYTE *ppbData,DWORD *pdwBytes);
int GetTPDSize() {return m_MEM_TPD.size();}
#ifndef __PS3__
int GetTPConfigVal(WCHAR *pwchDataFile);
#endif
bool DefaultCapeExists();
//void InstallDefaultCape(); // attempt to install the default cape once per game launch
// invites
//void ProcessInvite(JoinFromInviteData *pJoinData);
void ProcessInvite(DWORD dwUserIndex, DWORD dwLocalUsersMask, const INVITE_INFO * pInviteInfo);
// Add credits for DLC installed
void AddCreditText(LPCWSTR lpStr);
private:
PlayerUID m_xuidNotch;
#ifdef _DURANGO
unordered_map<PlayerUID, PBYTE, PlayerUID::Hash> m_GTS_Files;
#else
unordered_map<PlayerUID, PBYTE> m_GTS_Files;
#endif
// for storing memory textures - player skin
unordered_map<wstring, PMEMDATA> m_MEM_Files;
// for storing texture pack data files
unordered_map<int, PMEMDATA> m_MEM_TPD;
CRITICAL_SECTION csMemFilesLock; // For locking access to the above map
CRITICAL_SECTION csMemTPDLock; // For locking access to the above map
VNOTIFICATIONS m_vNotifications;
public:
// launch data
BYTE* m_pLaunchData;
DWORD m_dwLaunchDataSize;
public:
// BAN LIST
void AddLevelToBannedLevelList(int iPad,PlayerUID xuid, char *pszLevelName, bool bWriteToTMS);
bool IsInBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName);
void RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, char *pszLevelName);
void InvalidateBannedList(int iPad);
void SetUniqueMapName(char *pszUniqueMapName);
char *GetUniqueMapName(void);
#ifdef _XBOX_ONE
void AddLevelToBannedLevelList(int iPad, PBANNEDLISTDATA pBannedListData, bool bWriteToTMS);
#endif
public:
bool GetResourcesLoaded() {return m_bResourcesLoaded;}
void SetResourcesLoaded(bool bVal) {m_bResourcesLoaded=bVal;}
public:
bool m_bGameStarted;
bool m_bIntroRunning;
bool m_bTutorialMode;
bool m_bIsAppPaused;
bool m_bChangingSessionType;
bool m_bReallyChangingSessionType;
bool m_bDisplayFullVersionPurchase; // for after signing in during the trial, and trying to unlock full version on an upsell
void loadMediaArchive();
void loadStringTable();
protected:
ArchiveFile *m_mediaArchive;
StringTable *m_stringTable;
public:
int getArchiveFileSize(const wstring &filename);
bool hasArchiveFile(const wstring &filename);
byteArray getArchiveFile(const wstring &filename);
private:
static int BannedLevelDialogReturned(void *pParam,int iPad,const C4JStorage::EMessageResult);
static int TexturePackDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
VBANNEDLIST *m_vBannedListA[XUSER_MAX_COUNT];
void HandleButtonPresses(int iPad);
bool m_bResourcesLoaded;
// Global string table for this application.
//CXuiStringTable StringTable;
// Container scene for some menu
// CXuiScene debugContainerScene;
//bool m_bSplitScreenEnabled;
#ifdef _CONTENT_PACKAGE
#ifndef _FINAL_BUILD
bool m_bPartnernetPasswordRunning;
#endif
#endif
eGameMode m_eGameMode; // single or multiplayer
static unsigned int m_uiLastSignInData;
// We've got sizeof(GAME_SETTINGS) bytes reserved at the start of the gamedefined data per player for settings
GAME_SETTINGS *GameSettingsA[XUSER_MAX_COUNT];
// For promo work
bool m_bLoadSavesFromFolderEnabled;
// For debugging
bool m_bWriteSavesToFolderEnabled;
bool m_bMobsDontAttack;
bool m_bUseDPadForDebug;
bool m_bMobsDontTick;
bool m_bFreezePlayers;
// 4J : WESTY : For taking screen shots.
//bool m_bInterfaceRenderingOff;
//bool m_bHandRenderingOff;
DisconnectPacket::eDisconnectReason m_disconnectReason;
public:
virtual void RunFrame() {};
static const DWORD m_dwOfferID = 0x00000001;
// timer
void InitTime();
void UpdateTime();
// trial timer
void SetTrialTimerStart(void);
float getTrialTimer(void);
// notifications from the game for qnet
VNOTIFICATIONS *GetNotifications() {return &m_vNotifications;}
private:
// To avoid problems with threads being kicked off from xuis that alter things that may be in progress within the run_middle,
// we'll action these at the end of the game loop
eXuiAction m_eXuiAction[XUSER_MAX_COUNT];
eTMSAction m_eTMSAction[XUSER_MAX_COUNT];
LPVOID m_eXuiActionParam[XUSER_MAX_COUNT];
eXuiAction m_eGlobalXuiAction;
eXuiServerAction m_eXuiServerAction[XUSER_MAX_COUNT];
LPVOID m_eXuiServerActionParam[XUSER_MAX_COUNT];
eXuiServerAction m_eGlobalXuiServerAction;
bool m_bLiveLinkRequired;
static int UnlockFullExitReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int UnlockFullSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int UnlockFullInviteReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int TrialOverReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitAndJoinFromInvite(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitAndJoinFromInviteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitAndJoinFromInviteAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitAndJoinFromInviteDeclineSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int FatalErrorDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int WarningTrialTexturePackReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
JoinFromInviteData m_InviteData;
bool m_bDebugOptions; // toggle debug things on or off
// Trial timer
float m_fTrialTimerStart,mfTrialPausedTime;
typedef struct TimeInfo
{
LARGE_INTEGER qwTime;
LARGE_INTEGER qwAppTime;
float fAppTime;
float fElapsedTime;
float fSecsPerTick;
} TIMEINFO;
TimeInfo m_Time;
protected:
static const int MAX_TIPS_GAMETIP = 50;
static const int MAX_TIPS_TRIVIATIP = 20;
static TIPSTRUCT m_GameTipA[MAX_TIPS_GAMETIP];
static TIPSTRUCT m_TriviaTipA[MAX_TIPS_TRIVIATIP];
static Random *TipRandom;
public:
void InitialiseTips();
UINT GetNextTip();
int GetHTMLColour(eMinecraftColour colour);
int GetHTMLColor(eMinecraftColour colour) { return GetHTMLColour(colour); }
int GetHTMLFontSize(EHTMLFontSize size);
wstring FormatHTMLString(int iPad, const wstring &desc, int shadowColour = 0xFFFFFFFF);
wstring GetActionReplacement(int iPad, unsigned char ucAction);
wstring GetVKReplacement(unsigned int uiVKey);
wstring GetIconReplacement(unsigned int uiIcon);
float getAppTime() { return m_Time.fAppTime; }
void UpdateTrialPausedTimer() { mfTrialPausedTime+= m_Time.fElapsedTime;}
static int RemoteSaveThreadProc( void* lpParameter );
static void ExitGameFromRemoteSave( LPVOID lpParameter );
static int ExitGameFromRemoteSaveDialogReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
private:
UINT m_TipIDA[MAX_TIPS_GAMETIP+MAX_TIPS_TRIVIATIP];
UINT m_uiCurrentTip;
static int TipsSortFunction(const void* a, const void* b);
// XML
public:
// Hold a vector of terrain feature positions
void AddTerrainFeaturePosition(_eTerrainFeatureType,int,int);
void ClearTerrainFeaturePosition();
_eTerrainFeatureType IsTerrainFeature(int x,int z);
bool GetTerrainFeaturePosition(_eTerrainFeatureType eType, int *pX, int *pZ);
std::vector <FEATURE_DATA *> m_vTerrainFeatures;
static HRESULT RegisterMojangData(WCHAR *, PlayerUID, WCHAR *, WCHAR *);
MOJANG_DATA *GetMojangDataForXuid(PlayerUID xuid);
static HRESULT RegisterConfigValues(WCHAR *pType, int iValue);
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
HRESULT RegisterDLCData(char *pchDLCName, unsigned int uiSortIndex, char *pchImageURL);
bool GetDLCFullOfferIDForSkinID(const wstring &FirstSkin,ULONGLONG *pullVal);
DLC_INFO *GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial);
DLC_INFO *GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full);
#elif defined(_XBOX_ONE)
static HRESULT RegisterDLCData(eDLCContentType, WCHAR *, WCHAR *, WCHAR *, WCHAR *, int, unsigned int);
//bool GetDLCFullOfferIDForSkinID(const wstring &FirstSkin,WCHAR *pwchProductId);
bool GetDLCFullOfferIDForSkinID(const wstring &FirstSkin,wstring &wsProductId);
DLC_INFO *GetDLCInfoForFullOfferID(WCHAR *pwchProductId);
DLC_INFO *GetDLCInfoForProductName(WCHAR *pwchProductName);
#else
static HRESULT RegisterDLCData(WCHAR *, WCHAR *, int, __uint64, __uint64, WCHAR *, unsigned int, int, WCHAR *pDataFile);
bool GetDLCFullOfferIDForSkinID(const wstring &FirstSkin,ULONGLONG *pullVal);
DLC_INFO *GetDLCInfoForTrialOfferID(ULONGLONG ullOfferID_Trial);
DLC_INFO *GetDLCInfoForFullOfferID(ULONGLONG ullOfferID_Full);
#endif
unsigned int GetDLCCreditsCount();
SCreditTextItemDef * GetDLCCredits(int iIndex);
// TMS
void ReadDLCFileFromTMS(int iPad,eTMSAction action, bool bCallback=false);
void ReadXuidsFileFromTMS(int iPad,eTMSAction action,bool bCallback=false);
// images for save thumbnail/social post
virtual void CaptureSaveThumbnail() =0;
virtual void GetSaveThumbnail(PBYTE*,DWORD*)=0;
virtual void ReleaseSaveThumbnail()=0;
virtual void GetScreenshot(int iPad,PBYTE *pbData,DWORD *pdwSize)=0;
virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false)=0;
private:
std::vector <SCreditTextItemDef *> vDLCCredits;
#if defined(__PS3__) || defined(__ORBIS__) || defined (__PSVITA__)
static unordered_map<PlayerUID,MOJANG_DATA *, PlayerUID::Hash > MojangData;
static unordered_map<int, char * > DLCTextures_PackID; // for mash-up packs & texture packs
static unordered_map<string,DLC_INFO * > DLCInfo;
static unordered_map<wstring, ULONGLONG > DLCInfo_SkinName; // skin name, full offer id
#elif defined(_DURANGO)
static unordered_map<PlayerUID,MOJANG_DATA *, PlayerUID::Hash > MojangData;
static unordered_map<int, wstring > DLCTextures_PackID; // for mash-up packs & texture packs
//static unordered_map<wstring,DLC_INFO * > DLCInfo_Trial; // full offerid, dlc_info
static unordered_map<wstring,DLC_INFO * > DLCInfo_Full; // full offerid, dlc_info
static unordered_map<wstring, wstring > DLCInfo_SkinName; // skin name, full offer id
#else
static unordered_map<PlayerUID,MOJANG_DATA * > MojangData;
static unordered_map<int, ULONGLONG > DLCTextures_PackID; // for mash-up packs & texture packs
static unordered_map<ULONGLONG,DLC_INFO * > DLCInfo_Trial; // full offerid, dlc_info
static unordered_map<ULONGLONG,DLC_INFO * > DLCInfo_Full; // full offerid, dlc_info
static unordered_map<wstring, ULONGLONG > DLCInfo_SkinName; // skin name, full offer id
#endif
// bool m_bRead_TMS_XUIDS_XML; // track whether we have already read the TMS xuids.xml file
// bool m_bRead_TMS_DLCINFO_XML; // track whether we have already read the TMS DLC.xml file
bool m_bDefaultCapeInstallAttempted; // have we attempted to install the default cape from tms
//bool m_bwasHidingGui; // 4J Stu - Removed 1.8.2 bug fix (TU6) as not needed
bool m_bDLCInstallProcessCompleted;
bool m_bDLCInstallPending;
int m_iTotalDLC;
int m_iTotalDLCInstalled;
public:
// 4J Stu - We need to be able to detect when a guest player signs in or out causing other guest players to change their xuid
// The simplest way to do this is to check if their guest number has changed, so store the last known one here
// 4J Stu - Now storing the whole XUSER_SIGNIN_INFO so we can detect xuid changes
XUSER_SIGNIN_INFO m_currentSigninInfo[XUSER_MAX_COUNT];
//void OverrideFontRenderer(bool set, bool immediate = true);
// void ToggleFontRenderer() { OverrideFontRenderer(!m_bFontRendererOverridden,false); }
BANNEDLIST BannedListA[XUSER_MAX_COUNT];
private:
// XUI_FontRenderer *m_fontRenderer;
// bool m_bFontRendererOverridden;
// bool m_bOverrideFontRenderer;
bool m_bRead_BannedListA[XUSER_MAX_COUNT];
char m_pszUniqueMapName[14];
bool m_BanListCheck[XUSER_MAX_COUNT];
public:
void SetBanListCheck(int iPad,bool bVal) {m_BanListCheck[iPad]=bVal;}
bool GetBanListCheck(int iPad) { return m_BanListCheck[iPad];}
// AUTOSAVE
public:
void SetAutosaveTimerTime(void);
bool AutosaveDue(void);
unsigned int SecondsToAutosave();
private:
unsigned int m_uiAutosaveTimer;
unsigned int m_uiOpacityCountDown[XUSER_MAX_COUNT];
// DLC
bool m_bNewDLCAvailable;
bool m_bSeenNewDLCTip;
// Host options
private:
unsigned int m_uiGameHostSettings;
static unsigned char m_szPNG[8];
unsigned int FromBigEndian(unsigned int uiValue);
public:
void SetGameHostOption(eGameHostOption eVal,unsigned int uiVal);
void SetGameHostOption(unsigned int &uiHostSettings, eGameHostOption eVal,unsigned int uiVal);
unsigned int GetGameHostOption(eGameHostOption eVal);
unsigned int GetGameHostOption(unsigned int uiHostSettings, eGameHostOption eVal);
void SetResetNether(bool bResetNether) {m_bResetNether=bResetNether;}
bool GetResetNether() {return m_bResetNether;}
bool CanRecordStatsAndAchievements();
// World seed from png image
void GetImageTextData(PBYTE pbImageData, DWORD dwImageBytes,unsigned char *pszSeed,unsigned int &uiHostOptions,bool &bHostOptionsRead,DWORD &uiTexturePack);
unsigned int CreateImageTextData(PBYTE bTextMetadata, __int64 seed, bool hasSeed, unsigned int uiHostOptions, unsigned int uiTexturePackId);
// Game rules
GameRuleManager m_gameRules;
public:
void processSchematics(LevelChunk *levelChunk);
void processSchematicsLighting(LevelChunk *levelChunk);
void loadDefaultGameRules();
vector<LevelGenerationOptions *> *getLevelGenerators() { return m_gameRules.getLevelGenerators(); }
void setLevelGenerationOptions(LevelGenerationOptions *levelGen);
LevelRuleset *getGameRuleDefinitions() { return m_gameRules.getGameRuleDefinitions(); }
LevelGenerationOptions *getLevelGenerationOptions() { return m_gameRules.getLevelGenerationOptions(); }
LPCWSTR GetGameRulesString(const wstring &key);
private:
BYTE m_playerColours[MINECRAFT_NET_MAX_PLAYERS]; // An array of QNet small-id's
unsigned int m_playerGamePrivileges[MINECRAFT_NET_MAX_PLAYERS];
public:
void UpdatePlayerInfo(BYTE networkSmallId, SHORT playerColourIndex, unsigned int playerGamePrivileges);
short GetPlayerColour(BYTE networkSmallId);
unsigned int GetPlayerPrivileges(BYTE networkSmallId);
wstring getEntityName(eINSTANCEOF type);
unsigned int AddDLCRequest(eDLCMarketplaceType eContentType, bool bPromote=false);
bool RetrieveNextDLCContent();
bool CheckTMSDLCCanStop();
static int DLCOffersReturned(void *pParam, int iOfferC, DWORD dwType, int iPad);
DWORD GetDLCContentType(eDLCContentType eType) { return m_dwContentTypeA[eType];}
eDLCContentType Find_eDLCContentType(DWORD dwType);
int GetDLCOffersCount() { return m_iDLCOfferC;}
bool DLCContentRetrieved(eDLCMarketplaceType eType);
void TickDLCOffersRetrieved();
void ClearAndResetDLCDownloadQueue();
bool RetrieveNextTMSPPContent();
void TickTMSPPFilesRetrieved();
void ClearTMSPPFilesRetrieved();
unsigned int AddTMSPPFileTypeRequest(eDLCContentType eType, bool bPromote=false);
int GetDLCInfoTexturesOffersCount();
#if defined( __PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
DLC_INFO *GetDLCInfo(int iIndex);
DLC_INFO *GetDLCInfo(char *);
DLC_INFO *GetDLCInfoFromTPackID(int iTPID);
bool GetDLCNameForPackID(const int iPackID,char **ppchKeyID);
char * GetDLCInfoTextures(int iIndex);
int GetDLCInfoCount();
#else
#ifdef _XBOX_ONE
static int TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,LPVOID, WCHAR *wchFilename);
unordered_map<wstring,DLC_INFO * > *GetDLCInfo();
#else
static int TMSPPFileReturned(LPVOID pParam,int iPad,int iUserData,C4JStorage::PTMSPP_FILEDATA pFileData, LPCSTR szFilename);
#endif
DLC_INFO *GetDLCInfoTrialOffer(int iIndex);
DLC_INFO *GetDLCInfoFullOffer(int iIndex);
int GetDLCInfoTrialOffersCount();
int GetDLCInfoFullOffersCount();
#ifdef _XBOX_ONE
bool GetDLCFullOfferIDForPackID(const int iPackID,wstring &wsProductId);
wstring GetDLCInfoTexturesFullOffer(int iIndex);
#else
bool GetDLCFullOfferIDForPackID(const int iPackID,ULONGLONG *pullVal);
ULONGLONG GetDLCInfoTexturesFullOffer(int iIndex);
#endif
#endif
void SetCorruptSaveDeleted(bool bVal) {m_bCorruptSaveDeleted=bVal;}
bool GetCorruptSaveDeleted(void) {return m_bCorruptSaveDeleted;}
void EnterSaveNotificationSection();
void LeaveSaveNotificationSection();
private:
CRITICAL_SECTION m_saveNotificationCriticalSection;
int m_saveNotificationDepth;
// Download Status
//Request current_download;
vector<DLCRequest *> m_DLCDownloadQueue;
vector<TMSPPRequest *> m_TMSPPDownloadQueue;
static DWORD m_dwContentTypeA[e_Marketplace_MAX];
int m_iDLCOfferC;
bool m_bAllDLCContentRetrieved;
bool m_bAllTMSContentRetrieved;
bool m_bTickTMSDLCFiles;
CRITICAL_SECTION csDLCDownloadQueue;
CRITICAL_SECTION csTMSPPDownloadQueue;
CRITICAL_SECTION csAdditionalModelParts;
CRITICAL_SECTION csAdditionalSkinBoxes;
CRITICAL_SECTION csAnimOverrideBitmask;
bool m_bCorruptSaveDeleted;
DWORD m_dwAdditionalModelParts[XUSER_MAX_COUNT];
BYTE *m_pBannedListFileBuffer;
DWORD m_dwBannedListFileSize;
public:
DWORD m_dwDLCFileSize;
BYTE *m_pDLCFileBuffer;
// static int CallbackReadXuidsFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction);
// static int CallbackDLCFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction);
// static int CallbackBannedListFileFromTMS(LPVOID lpParam, WCHAR *wchFilename, int iPad, bool bResult, int iAction);
// Storing additional model parts per skin texture
void SetAdditionalSkinBoxes(DWORD dwSkinID, SKIN_BOX *SkinBoxA, DWORD dwSkinBoxC);
vector<ModelPart *> * SetAdditionalSkinBoxes(DWORD dwSkinID, vector<SKIN_BOX *> *pvSkinBoxA);
vector<ModelPart *> *GetAdditionalModelParts(DWORD dwSkinID);
vector<SKIN_BOX *> *GetAdditionalSkinBoxes(DWORD dwSkinID);
void SetAnimOverrideBitmask(DWORD dwSkinID,unsigned int uiAnimOverrideBitmask);
unsigned int GetAnimOverrideBitmask(DWORD dwSkinID);
static DWORD getSkinIdFromPath(const wstring &skin);
static wstring getSkinPathFromId(DWORD skinId);
virtual int LoadLocalTMSFile(WCHAR *wchTMSFile)=0;
virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt)=0;
virtual void FreeLocalTMSFiles(eTMSFileType eType)=0;
virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT)=0;
virtual bool GetTMSGlobalFileListRead() { return true;}
virtual bool GetTMSDLCInfoRead() { return true;}
virtual bool GetTMSXUIDsFileRead() { return true;}
bool GetBanListRead(int iPad) { return m_bRead_BannedListA[iPad];}
void SetBanListRead(int iPad,bool bVal) { m_bRead_BannedListA[iPad]=bVal;}
void ClearBanList(int iPad) { BannedListA[iPad].pBannedList=NULL;BannedListA[iPad].dwBytes=0;}
DWORD GetRequiredTexturePackID() {return m_dwRequiredTexturePackID;}
void SetRequiredTexturePackID(DWORD dwID) {m_dwRequiredTexturePackID=dwID;}
virtual void GetFileFromTPD(eTPDFileType eType,PBYTE pbData,DWORD dwBytes,PBYTE *ppbData,DWORD *pdwBytes ) {*ppbData = NULL; *pdwBytes = 0;}
//XTITLE_DEPLOYMENT_TYPE getDeploymentType() { return m_titleDeploymentType; }
private:
// vector of additional skin model parts, indexed by the skin texture id
unordered_map<DWORD, vector<ModelPart *> *> m_AdditionalModelParts;
unordered_map<DWORD, vector<SKIN_BOX *> *> m_AdditionalSkinBoxes;
unordered_map<DWORD, unsigned int> m_AnimOverrides;
bool m_bResetNether;
DWORD m_dwRequiredTexturePackID;
#ifdef _XBOX_ONE
vector <PBYTE> m_vTMSPPData;
#endif
#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO || defined __PSVITA__)
C4JStorage::eOptionsCallback m_eOptionsStatusA[XUSER_MAX_COUNT];
#ifdef __ORBIS__
int m_eOptionsBlocksRequiredA[XUSER_MAX_COUNT];
#endif
#endif
// 4J-PB - language and locale functions
public:
void LocaleAndLanguageInit();
void getLocale(vector<wstring> &vecWstrLocales);
DWORD get_eMCLang(WCHAR *pwchLocale);
DWORD get_xcLang(WCHAR *pwchLocale);
void SetTickTMSDLCFiles(bool bVal);
wstring getFilePath(DWORD packId, wstring filename, bool bAddDataFolder);
private:
unordered_map<int, wstring>m_localeA;
unordered_map<wstring, int>m_eMCLangA;
unordered_map<wstring, int>m_xcLangA;
wstring getRootPath(DWORD packId, bool allowOverride, bool bAddDataFolder);
public:
#ifdef _XBOX
// bool m_bTransferSavesToXboxOne;
// unsigned int m_uiTransferSlotC;
#elif defined (__PS3__)
#elif defined _DURANGO
#elif defined _WINDOWS64
//CMinecraftAudio audio;
#else // PS4
#endif
#ifdef _XBOX_ONE
public:
void SetReachedMainMenu();
bool HasReachedMainMenu();
private:
bool m_hasReachedMainMenu;
#endif
};
//singleton
//extern CMinecraftApp app;

View File

@@ -0,0 +1,216 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCAudioFile.h"
#if defined _XBOX || defined _WINDOWS64
#include "..\..\Xbox\XML\ATGXmlParser.h"
#include "..\..\Xbox\XML\xmlFilesCallback.h"
#endif
DLCAudioFile::DLCAudioFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Audio,path)
{
m_pbData = NULL;
m_dwBytes = 0;
}
void DLCAudioFile::addData(PBYTE pbData, DWORD dwBytes)
{
m_pbData = pbData;
m_dwBytes = dwBytes;
processDLCDataFile(pbData,dwBytes);
}
PBYTE DLCAudioFile::getData(DWORD &dwBytes)
{
dwBytes = m_dwBytes;
return m_pbData;
}
WCHAR *DLCAudioFile::wchTypeNamesA[]=
{
L"CUENAME",
L"CREDIT",
};
DLCAudioFile::EAudioParameterType DLCAudioFile::getParameterType(const wstring &paramName)
{
EAudioParameterType type = e_AudioParamType_Invalid;
for(DWORD i = 0; i < e_AudioParamType_Max; ++i)
{
if(paramName.compare(wchTypeNamesA[i]) == 0)
{
type = (EAudioParameterType)i;
break;
}
}
return type;
}
void DLCAudioFile::addParameter(EAudioType type, EAudioParameterType ptype, const wstring &value)
{
switch(ptype)
{
case e_AudioParamType_Credit: // If this parameter exists, then mark this as free
//add it to the DLC credits list
// we'll need to justify this text since we don't have a lot of room for lines of credits
{
// don't look for duplicate in the music credits
//if(app.AlreadySeenCreditText(value)) break;
int maximumChars = 55;
bool bIsSDMode=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
if(bIsSDMode)
{
maximumChars = 45;
}
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
maximumChars = 35;
break;
}
wstring creditValue = value;
while (creditValue.length() > maximumChars)
{
unsigned int i = 1;
while (i < creditValue.length() && (i + 1) <= maximumChars)
{
i++;
}
int iLast=(int)creditValue.find_last_of(L" ",i);
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
iLast = maximumChars;
break;
default:
iLast=(int)creditValue.find_last_of(L" ",i);
break;
}
// if a space was found, include the space on this line
if(iLast!=i)
{
iLast++;
}
app.AddCreditText((creditValue.substr(0, iLast)).c_str());
creditValue = creditValue.substr(iLast);
}
app.AddCreditText(creditValue.c_str());
}
break;
case e_AudioParamType_Cuename:
m_parameters[type].push_back(value);
//m_parameters[(int)type] = value;
break;
}
}
bool DLCAudioFile::processDLCDataFile(PBYTE pbData, DWORD dwLength)
{
unordered_map<int, EAudioParameterType> parameterMapping;
unsigned int uiCurrentByte=0;
// File format defined in the AudioPacker
// File format: Version 1
unsigned int uiVersion=*(unsigned int *)pbData;
uiCurrentByte+=sizeof(int);
if(uiVersion < CURRENT_AUDIO_VERSION_NUM)
{
if(pbData!=NULL) delete [] pbData;
app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion);
return false;
}
unsigned int uiParameterTypeCount=*(unsigned int *)&pbData[uiCurrentByte];
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_PARAM *pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiParameterTypeCount;i++)
{
// Map DLC strings to application strings, then store the DLC index mapping to application index
wstring parameterName((WCHAR *)pParams->wchData);
EAudioParameterType type = getParameterType(parameterName);
if( type != e_AudioParamType_Invalid )
{
parameterMapping[pParams->dwType] = type;
}
uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR));
pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
}
unsigned int uiFileCount=*(unsigned int *)&pbData[uiCurrentByte];
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_DETAILS *pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
DWORD dwTemp=uiCurrentByte;
for(unsigned int i=0;i<uiFileCount;i++)
{
dwTemp+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
}
PBYTE pbTemp=((PBYTE )pFile);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiFileCount;i++)
{
EAudioType type = (EAudioType)pFile->dwType;
// Params
unsigned int uiParameterCount=*(unsigned int *)pbTemp;
pbTemp+=sizeof(int);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
for(unsigned int j=0;j<uiParameterCount;j++)
{
//EAudioParameterType paramType = e_AudioParamType_Invalid;
AUTO_VAR(it, parameterMapping.find( pParams->dwType ));
if(it != parameterMapping.end() )
{
addParameter(type,(EAudioParameterType)pParams->dwType,(WCHAR *)pParams->wchData);
}
pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
}
// Move the pointer to the start of the next files data;
pbTemp+=pFile->uiFileSize;
uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
}
return true;
}
int DLCAudioFile::GetCountofType(DLCAudioFile::EAudioType eType)
{
return m_parameters[eType].size();
}
wstring &DLCAudioFile::GetSoundName(int iIndex)
{
int iWorldType=e_AudioType_Overworld;
while(iIndex>=m_parameters[iWorldType].size())
{
iIndex-=m_parameters[iWorldType].size();
iWorldType++;
}
return m_parameters[iWorldType].at(iIndex);
}

View File

@@ -0,0 +1,54 @@
#pragma once
#include "DLCFile.h"
class DLCAudioFile : public DLCFile
{
public:
// If you add to the Enum,then you need to add the array of type names
// These are the names used in the XML for the parameters
enum EAudioType
{
e_AudioType_Invalid = -1,
e_AudioType_Overworld = 0,
e_AudioType_Nether,
e_AudioType_End,
e_AudioType_Max,
};
enum EAudioParameterType
{
e_AudioParamType_Invalid = -1,
e_AudioParamType_Cuename = 0,
e_AudioParamType_Credit,
e_AudioParamType_Max,
};
static WCHAR *wchTypeNamesA[e_AudioParamType_Max];
DLCAudioFile(const wstring &path);
virtual void addData(PBYTE pbData, DWORD dwBytes);
virtual PBYTE getData(DWORD &dwBytes);
bool processDLCDataFile(PBYTE pbData, DWORD dwLength);
int GetCountofType(DLCAudioFile::EAudioType ptype);
wstring &GetSoundName(int iIndex);
private:
using DLCFile::addParameter;
PBYTE m_pbData;
DWORD m_dwBytes;
static const int CURRENT_AUDIO_VERSION_NUM=1;
//unordered_map<int, wstring> m_parameters;
vector<wstring> m_parameters[e_AudioType_Max];
// use the EAudioType to order these
void addParameter(DLCAudioFile::EAudioType type, DLCAudioFile::EAudioParameterType ptype, const wstring &value);
DLCAudioFile::EAudioParameterType getParameterType(const wstring &paramName);
};

View File

@@ -0,0 +1,12 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCCapeFile.h"
DLCCapeFile::DLCCapeFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Cape,path)
{
}
void DLCCapeFile::addData(PBYTE pbData, DWORD dwBytes)
{
app.AddMemoryTextureFile(m_path,pbData,dwBytes);
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "DLCFile.h"
class DLCCapeFile : public DLCFile
{
public:
DLCCapeFile(const wstring &path);
virtual void addData(PBYTE pbData, DWORD dwBytes);
};

View File

@@ -0,0 +1,26 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCColourTableFile.h"
#include "..\..\Minecraft.h"
#include "..\..\TexturePackRepository.h"
#include "..\..\TexturePack.h"
DLCColourTableFile::DLCColourTableFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_ColourTable,path)
{
m_colourTable = NULL;
}
DLCColourTableFile::~DLCColourTableFile()
{
if(m_colourTable != NULL)
{
app.DebugPrintf("Deleting DLCColourTableFile data\n");
delete m_colourTable;
}
}
void DLCColourTableFile::addData(PBYTE pbData, DWORD dwBytes)
{
ColourTable *defaultColourTable = Minecraft::GetInstance()->skins->getDefault()->getColourTable();
m_colourTable = new ColourTable(defaultColourTable, pbData, dwBytes);
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "DLCFile.h"
class ColourTable;
class DLCColourTableFile : public DLCFile
{
private:
ColourTable *m_colourTable;
public:
DLCColourTableFile(const wstring &path);
~DLCColourTableFile();
virtual void addData(PBYTE pbData, DWORD dwBytes);
ColourTable *getColourTable() { return m_colourTable; }
};

View File

@@ -0,0 +1,26 @@
#include "stdafx.h"
#include "DLCFile.h"
DLCFile::DLCFile(DLCManager::EDLCType type, const wstring &path)
{
m_type = type;
m_path = path;
// store the id
bool dlcSkin = path.substr(0,3).compare(L"dlc") == 0;
if(dlcSkin)
{
wstring skinValue = path.substr(7,path.size());
skinValue = skinValue.substr(0,skinValue.find_first_of(L'.'));
std::wstringstream ss;
ss << std::dec << skinValue.c_str();
ss >> m_dwSkinId;
m_dwSkinId = MAKE_SKIN_BITMASK(true, m_dwSkinId);
}
else
{
m_dwSkinId=0;
}
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "DLCManager.h"
class DLCFile
{
protected:
DLCManager::EDLCType m_type;
wstring m_path;
DWORD m_dwSkinId;
public:
DLCFile(DLCManager::EDLCType type, const wstring &path);
virtual ~DLCFile() {}
DLCManager::EDLCType getType() { return m_type; }
wstring getPath() { return m_path; }
DWORD getSkinID() { return m_dwSkinId; }
virtual void addData(PBYTE pbData, DWORD dwBytes) {}
virtual PBYTE getData(DWORD &dwBytes) { dwBytes = 0; return NULL; }
virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value) {}
virtual wstring getParameterAsString(DLCManager::EDLCParameterType type) { return L""; }
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type) { return false;}
};

View File

@@ -0,0 +1,10 @@
#pragma once
#include "DLCFile.h"
#include "..\GameRules\LevelGenerationOptions.h"
class DLCGameRules : public DLCFile
{
public:
DLCGameRules(DLCManager::EDLCType type, const wstring &path) : DLCFile(type,path) {}
};

View File

@@ -0,0 +1,21 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCGameRulesFile.h"
DLCGameRulesFile::DLCGameRulesFile(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRules,path)
{
m_pbData = NULL;
m_dwBytes = 0;
}
void DLCGameRulesFile::addData(PBYTE pbData, DWORD dwBytes)
{
m_pbData = pbData;
m_dwBytes = dwBytes;
}
PBYTE DLCGameRulesFile::getData(DWORD &dwBytes)
{
dwBytes = m_dwBytes;
return m_pbData;
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "DLCGameRules.h"
class DLCGameRulesFile : public DLCGameRules
{
private:
PBYTE m_pbData;
DWORD m_dwBytes;
public:
DLCGameRulesFile(const wstring &path);
virtual void addData(PBYTE pbData, DWORD dwBytes);
virtual PBYTE getData(DWORD &dwBytes);
};

View File

@@ -0,0 +1,92 @@
#include "stdafx.h"
#include <string>
#include "..\..\..\Minecraft.World\File.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\InputOutputStream.h"
#include "DLCManager.h"
#include "DLCGameRulesHeader.h"
DLCGameRulesHeader::DLCGameRulesHeader(const wstring &path) : DLCGameRules(DLCManager::e_DLCType_GameRulesHeader,path)
{
m_pbData = NULL;
m_dwBytes = 0;
m_hasData = false;
m_grfPath = path.substr(0, path.length() - 4) + L".grf";
lgo = NULL;
}
void DLCGameRulesHeader::addData(PBYTE pbData, DWORD dwBytes)
{
m_pbData = pbData;
m_dwBytes = dwBytes;
#if 0
byteArray data(m_pbData, m_dwBytes);
ByteArrayInputStream bais(data);
DataInputStream dis(&bais);
// Init values.
int version_number;
byte compression_type;
wstring texturepackid;
// Read Datastream.
version_number = dis.readInt();
compression_type = dis.readByte();
m_defaultSaveName = dis.readUTF();
m_displayName = dis.readUTF();
texturepackid = dis.readUTF();
m_grfPath = dis.readUTF();
// Debug printout.
app.DebugPrintf (
"DLCGameRulesHeader::readHeader:\n"
"\tversion_number = '%d',\n"
"\tcompression_type = '%d',\n"
"\tdefault_savename = '%s',\n"
"\tdisplayname = '%s',\n"
"\ttexturepackid = '%s',\n"
"\tgrf_path = '%s',\n",
version_number, compression_type,
wstringtofilename(m_defaultSaveName),
wstringtofilename(m_displayName),
wstringtofilename(texturepackid),
wstringtofilename(m_grfPath)
);
// Texture Pack.
m_requiredTexturePackId = _fromString<long>(texturepackid);
m_bRequiresTexturePack = m_requiredTexturePackId > 0;
dis.close();
bais.close();
bais.reset();
#endif
}
PBYTE DLCGameRulesHeader::getData(DWORD &dwBytes)
{
dwBytes = m_dwBytes;
return m_pbData;
}
void DLCGameRulesHeader::setGrfData(PBYTE fData, DWORD fSize, StringTable *st)
{
if (!m_hasData)
{
m_hasData = true;
//app.m_gameRules.loadGameRules(lgo, fData, fSize);
app.m_gameRules.readRuleFile(lgo, fData, fSize, st);
}
}

View File

@@ -0,0 +1,42 @@
#pragma once
#include "DLCGameRules.h"
#include "..\GameRules\LevelGenerationOptions.h"
class DLCGameRulesHeader : public DLCGameRules, public JustGrSource
{
private:
// GR-Header
PBYTE m_pbData;
DWORD m_dwBytes;
bool m_hasData;
public:
virtual bool requiresTexturePack() {return m_bRequiresTexturePack;}
virtual UINT getRequiredTexturePackId() {return m_requiredTexturePackId;}
virtual wstring getDefaultSaveName() {return m_defaultSaveName;}
virtual LPCWSTR getWorldName() {return m_worldName.c_str();}
virtual LPCWSTR getDisplayName() {return m_displayName.c_str();}
virtual wstring getGrfPath() {return L"GameRules.grf";}
virtual void setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;}
virtual void setRequiredTexturePackId(UINT x) {m_requiredTexturePackId = x;}
virtual void setDefaultSaveName(const wstring &x) {m_defaultSaveName = x;}
virtual void setWorldName(const wstring & x) {m_worldName = x;}
virtual void setDisplayName(const wstring & x) {m_displayName = x;}
virtual void setGrfPath(const wstring & x) {m_grfPath = x;}
LevelGenerationOptions *lgo;
public:
DLCGameRulesHeader(const wstring &path);
virtual void addData(PBYTE pbData, DWORD dwBytes);
virtual PBYTE getData(DWORD &dwBytes);
void setGrfData(PBYTE fData, DWORD fSize, StringTable *);
virtual bool ready() { return m_hasData; }
};

View File

@@ -0,0 +1,14 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCLocalisationFile.h"
#include "..\..\StringTable.h"
DLCLocalisationFile::DLCLocalisationFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_LocalisationData,path)
{
m_strings = NULL;
}
void DLCLocalisationFile::addData(PBYTE pbData, DWORD dwBytes)
{
m_strings = new StringTable(pbData, dwBytes);
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "DLCFile.h"
class StringTable;
class DLCLocalisationFile : public DLCFile
{
private:
StringTable *m_strings;
public:
DLCLocalisationFile(const wstring &path);
DLCLocalisationFile(PBYTE pbData, DWORD dwBytes); // when we load in a texture pack details file from TMS++
virtual void addData(PBYTE pbData, DWORD dwBytes);
StringTable *getStringTable() { return m_strings; }
};

View File

@@ -0,0 +1,671 @@
#include "stdafx.h"
#include <algorithm>
#include "DLCManager.h"
#include "DLCPack.h"
#include "DLCFile.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\Minecraft.h"
#include "..\..\TexturePackRepository.h"
WCHAR *DLCManager::wchTypeNamesA[]=
{
L"DISPLAYNAME",
L"THEMENAME",
L"FREE",
L"CREDIT",
L"CAPEPATH",
L"BOX",
L"ANIM",
L"PACKID",
L"NETHERPARTICLECOLOUR",
L"ENCHANTTEXTCOLOUR",
L"ENCHANTTEXTFOCUSCOLOUR",
L"DATAPATH",
L"PACKVERSION",
};
DLCManager::DLCManager()
{
//m_bNeedsUpdated = true;
m_bNeedsCorruptCheck = true;
}
DLCManager::~DLCManager()
{
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *pack = *it;
delete pack;
}
}
DLCManager::EDLCParameterType DLCManager::getParameterType(const wstring &paramName)
{
EDLCParameterType type = e_DLCParamType_Invalid;
for(DWORD i = 0; i < e_DLCParamType_Max; ++i)
{
if(paramName.compare(wchTypeNamesA[i]) == 0)
{
type = (EDLCParameterType)i;
break;
}
}
return type;
}
DWORD DLCManager::getPackCount(EDLCType type /*= e_DLCType_All*/)
{
DWORD packCount = 0;
if( type != e_DLCType_All )
{
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *pack = *it;
if( pack->getDLCItemsCount(type) > 0 )
{
++packCount;
}
}
}
else
{
packCount = (DWORD)m_packs.size();
}
return packCount;
}
void DLCManager::addPack(DLCPack *pack)
{
m_packs.push_back(pack);
}
void DLCManager::removePack(DLCPack *pack)
{
if(pack != NULL)
{
AUTO_VAR(it, find(m_packs.begin(),m_packs.end(),pack));
if(it != m_packs.end() ) m_packs.erase(it);
delete pack;
}
}
DLCPack *DLCManager::getPack(const wstring &name)
{
DLCPack *pack = NULL;
//DWORD currentIndex = 0;
DLCPack *currentPack = NULL;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
currentPack = *it;
wstring wsName=currentPack->getName();
if(wsName.compare(name) == 0)
{
pack = currentPack;
break;
}
}
return pack;
}
#ifdef _XBOX_ONE
DLCPack *DLCManager::getPackFromProductID(const wstring &productID)
{
DLCPack *pack = NULL;
//DWORD currentIndex = 0;
DLCPack *currentPack = NULL;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
currentPack = *it;
wstring wsName=currentPack->getPurchaseOfferId();
if(wsName.compare(productID) == 0)
{
pack = currentPack;
break;
}
}
return pack;
}
#endif
DLCPack *DLCManager::getPack(DWORD index, EDLCType type /*= e_DLCType_All*/)
{
DLCPack *pack = NULL;
if( type != e_DLCType_All )
{
DWORD currentIndex = 0;
DLCPack *currentPack = NULL;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
currentPack = *it;
if(currentPack->getDLCItemsCount(type)>0)
{
if(currentIndex == index)
{
pack = currentPack;
break;
}
++currentIndex;
}
}
}
else
{
if(index >= m_packs.size())
{
app.DebugPrintf("DLCManager: Trying to access a DLC pack beyond the range of valid packs\n");
__debugbreak();
}
pack = m_packs[index];
}
return pack;
}
DWORD DLCManager::getPackIndex(DLCPack *pack, bool &found, EDLCType type /*= e_DLCType_All*/)
{
DWORD foundIndex = 0;
found = false;
if(pack == NULL)
{
app.DebugPrintf("DLCManager: Attempting to find the index for a NULL pack\n");
//__debugbreak();
return foundIndex;
}
if( type != e_DLCType_All )
{
DWORD index = 0;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *thisPack = *it;
if(thisPack->getDLCItemsCount(type)>0)
{
if(thisPack == pack)
{
found = true;
foundIndex = index;
break;
}
++index;
}
}
}
else
{
DWORD index = 0;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *thisPack = *it;
if(thisPack == pack)
{
found = true;
foundIndex = index;
break;
}
++index;
}
}
return foundIndex;
}
DWORD DLCManager::getPackIndexContainingSkin(const wstring &path, bool &found)
{
DWORD foundIndex = 0;
found = false;
DWORD index = 0;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *pack = *it;
if(pack->getDLCItemsCount(e_DLCType_Skin)>0)
{
if(pack->doesPackContainSkin(path))
{
foundIndex = index;
found = true;
break;
}
++index;
}
}
return foundIndex;
}
DLCPack *DLCManager::getPackContainingSkin(const wstring &path)
{
DLCPack *foundPack = NULL;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *pack = *it;
if(pack->getDLCItemsCount(e_DLCType_Skin)>0)
{
if(pack->doesPackContainSkin(path))
{
foundPack = pack;
break;
}
}
}
return foundPack;
}
DLCSkinFile *DLCManager::getSkinFile(const wstring &path)
{
DLCSkinFile *foundSkinfile = NULL;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
DLCPack *pack = *it;
foundSkinfile=pack->getSkinFile(path);
if(foundSkinfile!=NULL)
{
break;
}
}
return foundSkinfile;
}
DWORD DLCManager::checkForCorruptDLCAndAlert(bool showMessage /*= true*/)
{
DWORD corruptDLCCount = m_dwUnnamedCorruptDLCCount;
DLCPack *pack = NULL;
DLCPack *firstCorruptPack = NULL;
for(AUTO_VAR(it, m_packs.begin()); it != m_packs.end(); ++it)
{
pack = *it;
if( pack->IsCorrupt() )
{
++corruptDLCCount;
if(firstCorruptPack == NULL) firstCorruptPack = pack;
}
}
if(corruptDLCCount > 0 && showMessage)
{
UINT uiIDA[1];
uiIDA[0]=IDS_CONFIRM_OK;
if(corruptDLCCount == 1 && firstCorruptPack != NULL)
{
// pass in the pack format string
WCHAR wchFormat[132];
swprintf(wchFormat, 132, L"%ls\n\n%%ls", firstCorruptPack->getName().c_str());
C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable(),wchFormat);
}
else
{
C4JStorage::EMessageResult result = ui.RequestMessageBox( IDS_CORRUPT_DLC_TITLE, IDS_CORRUPT_DLC_MULTIPLE, uiIDA,1,ProfileManager.GetPrimaryPad(),NULL,NULL, app.GetStringTable());
}
}
SetNeedsCorruptCheck(false);
return corruptDLCCount;
}
bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const wstring &path, DLCPack *pack, bool fromArchive)
{
return readDLCDataFile( dwFilesProcessed, wstringtofilename(path), pack, fromArchive);
}
bool DLCManager::readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DLCPack *pack, bool fromArchive)
{
wstring wPath = convStringToWstring(path);
if (fromArchive && app.getArchiveFileSize(wPath) >= 0)
{
byteArray bytes = app.getArchiveFile(wPath);
return processDLCDataFile(dwFilesProcessed, bytes.data, bytes.length, pack);
}
else if (fromArchive) return false;
#ifdef _WINDOWS64
string finalPath = StorageManager.GetMountedPath(path.c_str());
if(finalPath.size() == 0) finalPath = path;
HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#elif defined(_DURANGO)
wstring finalPath = StorageManager.GetMountedPath(wPath.c_str());
if(finalPath.size() == 0) finalPath = wPath;
HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif
if( file == INVALID_HANDLE_VALUE )
{
DWORD error = GetLastError();
app.DebugPrintf("Failed to open DLC data file with error code %d (%x)\n", error, error);
if( dwFilesProcessed == 0 ) removePack(pack);
assert(false);
return false;
}
DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
PBYTE pbData = (PBYTE) new BYTE[dwFileSize];
BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL);
if(bSuccess==FALSE)
{
// need to treat the file as corrupt, and flag it, so can't call fatal error
//app.FatalLoadError();
}
else
{
CloseHandle(file);
}
if(bSuccess==FALSE)
{
// Corrupt or some other error. In any case treat as corrupt
app.DebugPrintf("Failed to read %s from DLC content package\n", path.c_str());
pack->SetIsCorrupt( true );
SetNeedsCorruptCheck(true);
return false;
}
return processDLCDataFile(dwFilesProcessed, pbData, bytesRead, pack);
}
bool DLCManager::processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack)
{
unordered_map<int, DLCManager::EDLCParameterType> parameterMapping;
unsigned int uiCurrentByte=0;
// File format defined in the DLC_Creator
// File format: Version 2
// unsigned long, version number
// unsigned long, t = number of parameter types
// t * DLC_FILE_PARAM structs mapping strings to id's
// unsigned long, n = number of files
// n * DLC_FILE_DETAILS describing each file in the pack
// n * files of the form
// // unsigned long, p = number of parameters
// // p * DLC_FILE_PARAM describing each parameter for this file
// // ulFileSize bytes of data blob of the file added
unsigned int uiVersion=*(unsigned int *)pbData;
uiCurrentByte+=sizeof(int);
if(uiVersion < CURRENT_DLC_VERSION_NUM)
{
if(pbData!=NULL) delete [] pbData;
app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion);
return false;
}
pack->SetDataPointer(pbData);
unsigned int uiParameterCount=*(unsigned int *)&pbData[uiCurrentByte];
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_PARAM *pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
//DWORD dwwchCount=0;
for(unsigned int i=0;i<uiParameterCount;i++)
{
// Map DLC strings to application strings, then store the DLC index mapping to application index
wstring parameterName((WCHAR *)pParams->wchData);
DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName);
if( type != DLCManager::e_DLCParamType_Invalid )
{
parameterMapping[pParams->dwType] = type;
}
uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR));
pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
}
//ulCurrentByte+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
unsigned int uiFileCount=*(unsigned int *)&pbData[uiCurrentByte];
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_DETAILS *pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
DWORD dwTemp=uiCurrentByte;
for(unsigned int i=0;i<uiFileCount;i++)
{
dwTemp+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
}
PBYTE pbTemp=((PBYTE )pFile);//+ sizeof(C4JStorage::DLC_FILE_DETAILS)*ulFileCount;
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiFileCount;i++)
{
DLCManager::EDLCType type = (DLCManager::EDLCType)pFile->dwType;
DLCFile *dlcFile = NULL;
DLCPack *dlcTexturePack = NULL;
if(type == e_DLCType_TexturePack)
{
dlcTexturePack = new DLCPack(pack->getName(), pack->getLicenseMask());
}
else if(type != e_DLCType_PackConfig)
{
dlcFile = pack->addFile(type,(WCHAR *)pFile->wchFile);
}
// Params
uiParameterCount=*(unsigned int *)pbTemp;
pbTemp+=sizeof(int);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
for(unsigned int j=0;j<uiParameterCount;j++)
{
//DLCManager::EDLCParameterType paramType = DLCManager::e_DLCParamType_Invalid;
AUTO_VAR(it, parameterMapping.find( pParams->dwType ));
if(it != parameterMapping.end() )
{
if(type == e_DLCType_PackConfig)
{
pack->addParameter(it->second,(WCHAR *)pParams->wchData);
}
else
{
if(dlcFile != NULL) dlcFile->addParameter(it->second,(WCHAR *)pParams->wchData);
else if(dlcTexturePack != NULL) dlcTexturePack->addParameter(it->second, (WCHAR *)pParams->wchData);
}
}
pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
}
//pbTemp+=ulParameterCount * sizeof(C4JStorage::DLC_FILE_PARAM);
if(dlcTexturePack != NULL)
{
DWORD texturePackFilesProcessed = 0;
bool validPack = processDLCDataFile(texturePackFilesProcessed,pbTemp,pFile->uiFileSize,dlcTexturePack);
pack->SetDataPointer(NULL); // If it's a child pack, it doesn't own the data
if(!validPack || texturePackFilesProcessed == 0)
{
delete dlcTexturePack;
dlcTexturePack = NULL;
}
else
{
pack->addChildPack(dlcTexturePack);
if(dlcTexturePack->getDLCItemsCount(DLCManager::e_DLCType_Texture) > 0)
{
Minecraft::GetInstance()->skins->addTexturePackFromDLC(dlcTexturePack, dlcTexturePack->GetPackId() );
}
}
++dwFilesProcessed;
}
else if(dlcFile != NULL)
{
// Data
dlcFile->addData(pbTemp,pFile->uiFileSize);
// TODO - 4J Stu Remove the need for this vSkinNames vector, or manage it differently
switch(pFile->dwType)
{
case DLCManager::e_DLCType_Skin:
app.vSkinNames.push_back((WCHAR *)pFile->wchFile);
break;
}
++dwFilesProcessed;
}
// Move the pointer to the start of the next files data;
pbTemp+=pFile->uiFileSize;
uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
}
if( pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules) > 0
|| pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader) > 0)
{
app.m_gameRules.loadGameRules(pack);
}
if(pack->getDLCItemsCount(DLCManager::e_DLCType_Audio) > 0)
{
//app.m_Audio.loadAudioDetails(pack);
}
// TODO Should be able to delete this data, but we can't yet due to how it is added to the Memory textures (MEM_file)
return true;
}
DWORD DLCManager::retrievePackIDFromDLCDataFile(const string &path, DLCPack *pack)
{
DWORD packId = 0;
wstring wPath = convStringToWstring(path);
#ifdef _WINDOWS64
string finalPath = StorageManager.GetMountedPath(path.c_str());
if(finalPath.size() == 0) finalPath = path;
HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#elif defined(_DURANGO)
wstring finalPath = StorageManager.GetMountedPath(wPath.c_str());
if(finalPath.size() == 0) finalPath = wPath;
HANDLE file = CreateFile(finalPath.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#endif
if( file == INVALID_HANDLE_VALUE )
{
return 0;
}
DWORD bytesRead,dwFileSize = GetFileSize(file,NULL);
PBYTE pbData = (PBYTE) new BYTE[dwFileSize];
BOOL bSuccess = ReadFile(file,pbData,dwFileSize,&bytesRead,NULL);
if(bSuccess==FALSE)
{
// need to treat the file as corrupt, and flag it, so can't call fatal error
//app.FatalLoadError();
}
else
{
CloseHandle(file);
}
if(bSuccess==FALSE)
{
// Corrupt or some other error. In any case treat as corrupt
app.DebugPrintf("Failed to read %s from DLC content package\n", path.c_str());
delete [] pbData;
return 0;
}
packId=retrievePackID(pbData, bytesRead, pack);
delete [] pbData;
return packId;
}
DWORD DLCManager::retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack)
{
DWORD packId=0;
bool bPackIDSet=false;
unordered_map<int, DLCManager::EDLCParameterType> parameterMapping;
unsigned int uiCurrentByte=0;
// File format defined in the DLC_Creator
// File format: Version 2
// unsigned long, version number
// unsigned long, t = number of parameter types
// t * DLC_FILE_PARAM structs mapping strings to id's
// unsigned long, n = number of files
// n * DLC_FILE_DETAILS describing each file in the pack
// n * files of the form
// // unsigned long, p = number of parameters
// // p * DLC_FILE_PARAM describing each parameter for this file
// // ulFileSize bytes of data blob of the file added
unsigned int uiVersion=*(unsigned int *)pbData;
uiCurrentByte+=sizeof(int);
if(uiVersion < CURRENT_DLC_VERSION_NUM)
{
app.DebugPrintf("DLC version of %d is too old to be read\n", uiVersion);
return 0;
}
pack->SetDataPointer(pbData);
unsigned int uiParameterCount=*(unsigned int *)&pbData[uiCurrentByte];
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_PARAM *pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiParameterCount;i++)
{
// Map DLC strings to application strings, then store the DLC index mapping to application index
wstring parameterName((WCHAR *)pParams->wchData);
DLCManager::EDLCParameterType type = DLCManager::getParameterType(parameterName);
if( type != DLCManager::e_DLCParamType_Invalid )
{
parameterMapping[pParams->dwType] = type;
}
uiCurrentByte+= sizeof(C4JStorage::DLC_FILE_PARAM)+(pParams->dwWchCount*sizeof(WCHAR));
pParams = (C4JStorage::DLC_FILE_PARAM *)&pbData[uiCurrentByte];
}
unsigned int uiFileCount=*(unsigned int *)&pbData[uiCurrentByte];
uiCurrentByte+=sizeof(int);
C4JStorage::DLC_FILE_DETAILS *pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
DWORD dwTemp=uiCurrentByte;
for(unsigned int i=0;i<uiFileCount;i++)
{
dwTemp+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[dwTemp];
}
PBYTE pbTemp=((PBYTE )pFile);
pFile = (C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
for(unsigned int i=0;i<uiFileCount;i++)
{
DLCManager::EDLCType type = (DLCManager::EDLCType)pFile->dwType;
// Params
uiParameterCount=*(unsigned int *)pbTemp;
pbTemp+=sizeof(int);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
for(unsigned int j=0;j<uiParameterCount;j++)
{
AUTO_VAR(it, parameterMapping.find( pParams->dwType ));
if(it != parameterMapping.end() )
{
if(type==e_DLCType_PackConfig)
{
if(it->second==e_DLCParamType_PackId)
{
wstring wsTemp=(WCHAR *)pParams->wchData;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for artists/people to number manually
ss << std::dec << wsTemp.c_str();
ss >> packId;
bPackIDSet=true;
break;
}
}
}
pbTemp+=sizeof(C4JStorage::DLC_FILE_PARAM)+(sizeof(WCHAR)*pParams->dwWchCount);
pParams = (C4JStorage::DLC_FILE_PARAM *)pbTemp;
}
if(bPackIDSet) break;
// Move the pointer to the start of the next files data;
pbTemp+=pFile->uiFileSize;
uiCurrentByte+=sizeof(C4JStorage::DLC_FILE_DETAILS)+pFile->dwWchCount*sizeof(WCHAR);
pFile=(C4JStorage::DLC_FILE_DETAILS *)&pbData[uiCurrentByte];
}
parameterMapping.clear();
return packId;
}

View File

@@ -0,0 +1,99 @@
#pragma once
using namespace std;
#include <vector>
class DLCPack;
class DLCSkinFile;
class DLCManager
{
public:
enum EDLCType
{
e_DLCType_Skin = 0,
e_DLCType_Cape,
e_DLCType_Texture,
e_DLCType_UIData,
e_DLCType_PackConfig,
e_DLCType_TexturePack,
e_DLCType_LocalisationData,
e_DLCType_GameRules,
e_DLCType_Audio,
e_DLCType_ColourTable,
e_DLCType_GameRulesHeader,
e_DLCType_Max,
e_DLCType_All,
};
// If you add to the Enum,then you need to add the array of type names
// These are the names used in the XML for the parameters
enum EDLCParameterType
{
e_DLCParamType_Invalid = -1,
e_DLCParamType_DisplayName = 0,
e_DLCParamType_ThemeName,
e_DLCParamType_Free, // identify free skins
e_DLCParamType_Credit, // legal credits for DLC
e_DLCParamType_Cape,
e_DLCParamType_Box,
e_DLCParamType_Anim,
e_DLCParamType_PackId,
e_DLCParamType_NetherParticleColour,
e_DLCParamType_EnchantmentTextColour,
e_DLCParamType_EnchantmentTextFocusColour,
e_DLCParamType_DataPath,
e_DLCParamType_PackVersion,
e_DLCParamType_Max,
};
static WCHAR *wchTypeNamesA[e_DLCParamType_Max];
private:
vector<DLCPack *> m_packs;
//bool m_bNeedsUpdated;
bool m_bNeedsCorruptCheck;
DWORD m_dwUnnamedCorruptDLCCount;
public:
DLCManager();
~DLCManager();
static EDLCParameterType getParameterType(const wstring &paramName);
DWORD getPackCount(EDLCType type = e_DLCType_All);
//bool NeedsUpdated() { return m_bNeedsUpdated; }
//void SetNeedsUpdated(bool val) { m_bNeedsUpdated = val; }
bool NeedsCorruptCheck() { return m_bNeedsCorruptCheck; }
void SetNeedsCorruptCheck(bool val) { m_bNeedsCorruptCheck = val; }
void resetUnnamedCorruptCount() { m_dwUnnamedCorruptDLCCount = 0; }
void incrementUnnamedCorruptCount() { ++m_dwUnnamedCorruptDLCCount; }
void addPack(DLCPack *pack);
void removePack(DLCPack *pack);
DLCPack *getPack(const wstring &name);
#ifdef _XBOX_ONE
DLCPack *DLCManager::getPackFromProductID(const wstring &productID);
#endif
DLCPack *getPack(DWORD index, EDLCType type = e_DLCType_All);
DWORD getPackIndex(DLCPack *pack, bool &found, EDLCType type = e_DLCType_All);
DLCSkinFile *getSkinFile(const wstring &path); // Will hunt all packs of type skin to find the right skinfile
DLCPack *getPackContainingSkin(const wstring &path);
DWORD getPackIndexContainingSkin(const wstring &path, bool &found);
DWORD checkForCorruptDLCAndAlert(bool showMessage = true);
bool readDLCDataFile(DWORD &dwFilesProcessed, const wstring &path, DLCPack *pack, bool fromArchive = false);
bool readDLCDataFile(DWORD &dwFilesProcessed, const string &path, DLCPack *pack, bool fromArchive = false);
DWORD retrievePackIDFromDLCDataFile(const string &path, DLCPack *pack);
private:
bool processDLCDataFile(DWORD &dwFilesProcessed, PBYTE pbData, DWORD dwLength, DLCPack *pack);
DWORD retrievePackID(PBYTE pbData, DWORD dwLength, DLCPack *pack);
};

View File

@@ -0,0 +1,410 @@
#include "stdafx.h"
#include "DLCPack.h"
#include "DLCSkinFile.h"
#include "DLCCapeFile.h"
#include "DLCTextureFile.h"
#include "DLCUIDataFile.h"
#include "DLCLocalisationFile.h"
#include "DLCGameRulesFile.h"
#include "DLCGameRulesHeader.h"
#include "DLCAudioFile.h"
#include "DLCColourTableFile.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
DLCPack::DLCPack(const wstring &name,DWORD dwLicenseMask)
{
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask=dwLicenseMask;
#ifdef _XBOX_ONE
m_wsProductId = L"";
#else
m_ullFullOfferId = 0LL;
#endif
m_isCorrupt = false;
m_packId = 0;
m_packVersion = 0;
m_parentPack = NULL;
m_dlcMountIndex = -1;
#ifdef _XBOX
m_dlcDeviceID = XCONTENTDEVICE_ANY;
#endif
// This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
m_data = NULL;
}
#ifdef _XBOX_ONE
DLCPack::DLCPack(const wstring &name,const wstring &productID,DWORD dwLicenseMask)
{
m_dataPath = L"";
m_packName = name;
m_dwLicenseMask=dwLicenseMask;
m_wsProductId = productID;
m_isCorrupt = false;
m_packId = 0;
m_packVersion = 0;
m_parentPack = NULL;
m_dlcMountIndex = -1;
// This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
m_data = NULL;
}
#endif
DLCPack::~DLCPack()
{
for(AUTO_VAR(it, m_childPacks.begin()); it != m_childPacks.end(); ++it)
{
delete *it;
}
for(unsigned int i = 0; i < DLCManager::e_DLCType_Max; ++i)
{
for(AUTO_VAR(it,m_files[i].begin()); it != m_files[i].end(); ++it)
{
delete *it;
}
}
// This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
if(m_data)
{
#ifndef _CONTENT_PACKAGE
wprintf(L"Deleting data for DLC pack %ls\n", m_packName.c_str());
#endif
// For the same reason, don't delete data pointer for any child pack as it just points to a region within the parent pack that has already been freed
if( m_parentPack == NULL )
{
delete [] m_data;
}
}
}
DWORD DLCPack::GetDLCMountIndex()
{
if(m_parentPack != NULL)
{
return m_parentPack->GetDLCMountIndex();
}
return m_dlcMountIndex;
}
XCONTENTDEVICEID DLCPack::GetDLCDeviceID()
{
if(m_parentPack != NULL )
{
return m_parentPack->GetDLCDeviceID();
}
return m_dlcDeviceID;
}
void DLCPack::addChildPack(DLCPack *childPack)
{
int packId = childPack->GetPackId();
#ifndef _CONTENT_PACKAGE
if(packId < 0 || packId > 15)
{
__debugbreak();
}
#endif
childPack->SetPackId( (packId<<24) | m_packId );
m_childPacks.push_back(childPack);
childPack->setParentPack(this);
childPack->m_packName = m_packName + childPack->getName();
}
void DLCPack::setParentPack(DLCPack *parentPack)
{
m_parentPack = parentPack;
}
void DLCPack::addParameter(DLCManager::EDLCParameterType type, const wstring &value)
{
switch(type)
{
case DLCManager::e_DLCParamType_PackId:
{
DWORD packId = 0;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for artists/people to number manually
ss << std::dec << value.c_str();
ss >> packId;
SetPackId(packId);
}
break;
case DLCManager::e_DLCParamType_PackVersion:
{
DWORD version = 0;
std::wstringstream ss;
// 4J Stu - numbered using decimal to make it easier for artists/people to number manually
ss << std::dec << value.c_str();
ss >> version;
SetPackVersion(version);
}
break;
case DLCManager::e_DLCParamType_DisplayName:
m_packName = value;
break;
case DLCManager::e_DLCParamType_DataPath:
m_dataPath = value;
break;
default:
m_parameters[(int)type] = value;
break;
}
}
bool DLCPack::getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned int &param)
{
AUTO_VAR(it,m_parameters.find((int)type));
if(it != m_parameters.end())
{
switch(type)
{
case DLCManager::e_DLCParamType_NetherParticleColour:
case DLCManager::e_DLCParamType_EnchantmentTextColour:
case DLCManager::e_DLCParamType_EnchantmentTextFocusColour:
{
std::wstringstream ss;
ss << std::hex << it->second.c_str();
ss >> param;
}
break;
default:
param = _fromString<unsigned int>(it->second);
}
return true;
}
return false;
}
DLCFile *DLCPack::addFile(DLCManager::EDLCType type, const wstring &path)
{
DLCFile *newFile = NULL;
switch(type)
{
case DLCManager::e_DLCType_Skin:
{
std::vector<std::wstring> splitPath = stringSplit(path,L'/');
wstring strippedPath = splitPath.back();
newFile = new DLCSkinFile(strippedPath);
// check to see if we can get the full offer id using this skin name
#ifdef _XBOX_ONE
app.GetDLCFullOfferIDForSkinID(strippedPath,m_wsProductId);
#else
ULONGLONG ullVal=0LL;
if(app.GetDLCFullOfferIDForSkinID(strippedPath,&ullVal))
{
m_ullFullOfferId=ullVal;
}
#endif
}
break;
case DLCManager::e_DLCType_Cape:
{
std::vector<std::wstring> splitPath = stringSplit(path,L'/');
wstring strippedPath = splitPath.back();
newFile = new DLCCapeFile(strippedPath);
}
break;
case DLCManager::e_DLCType_Texture:
newFile = new DLCTextureFile(path);
break;
case DLCManager::e_DLCType_UIData:
newFile = new DLCUIDataFile(path);
break;
case DLCManager::e_DLCType_LocalisationData:
newFile = new DLCLocalisationFile(path);
break;
case DLCManager::e_DLCType_GameRules:
newFile = new DLCGameRulesFile(path);
break;
case DLCManager::e_DLCType_Audio:
newFile = new DLCAudioFile(path);
break;
case DLCManager::e_DLCType_ColourTable:
newFile = new DLCColourTableFile(path);
break;
case DLCManager::e_DLCType_GameRulesHeader:
newFile = new DLCGameRulesHeader(path);
break;
};
if( newFile != NULL )
{
m_files[newFile->getType()].push_back(newFile);
}
return newFile;
}
// MGH - added this comp func, as the embedded func in find_if was confusing the PS3 compiler
static const wstring *g_pathCmpString = NULL;
static bool pathCmp(DLCFile *val)
{
return (g_pathCmpString->compare(val->getPath()) == 0);
}
bool DLCPack::doesPackContainFile(DLCManager::EDLCType type, const wstring &path)
{
bool hasFile = false;
if(type == DLCManager::e_DLCType_All)
{
for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1))
{
hasFile = doesPackContainFile(currentType,path);
if(hasFile) break;
}
}
else
{
g_pathCmpString = &path;
AUTO_VAR(it, find_if( m_files[type].begin(), m_files[type].end(), pathCmp ));
hasFile = it != m_files[type].end();
if(!hasFile && m_parentPack )
{
hasFile = m_parentPack->doesPackContainFile(type,path);
}
}
return hasFile;
}
DLCFile *DLCPack::getFile(DLCManager::EDLCType type, DWORD index)
{
DLCFile *file = NULL;
if(type == DLCManager::e_DLCType_All)
{
for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1))
{
file = getFile(currentType,index);
if(file != NULL) break;
}
}
else
{
if(m_files[type].size() > index) file = m_files[type][index];
if(!file && m_parentPack)
{
file = m_parentPack->getFile(type,index);
}
}
return file;
}
DLCFile *DLCPack::getFile(DLCManager::EDLCType type, const wstring &path)
{
DLCFile *file = NULL;
if(type == DLCManager::e_DLCType_All)
{
for(DLCManager::EDLCType currentType = (DLCManager::EDLCType)0; currentType < DLCManager::e_DLCType_Max; currentType = (DLCManager::EDLCType)(currentType + 1))
{
file = getFile(currentType,path);
if(file != NULL) break;
}
}
else
{
g_pathCmpString = &path;
AUTO_VAR(it, find_if( m_files[type].begin(), m_files[type].end(), pathCmp ));
if(it == m_files[type].end())
{
// Not found
file = NULL;
}
else
{
file = *it;
}
if(!file && m_parentPack)
{
file = m_parentPack->getFile(type,path);
}
}
return file;
}
DWORD DLCPack::getDLCItemsCount(DLCManager::EDLCType type /*= DLCManager::e_DLCType_All*/)
{
DWORD count = 0;
switch(type)
{
case DLCManager::e_DLCType_All:
for(int i = 0; i < DLCManager::e_DLCType_Max; ++i)
{
count += getDLCItemsCount((DLCManager::EDLCType)i);
}
break;
default:
count = (DWORD)m_files[(int)type].size();
break;
};
return count;
};
DWORD DLCPack::getFileIndexAt(DLCManager::EDLCType type, const wstring &path, bool &found)
{
if(type == DLCManager::e_DLCType_All)
{
app.DebugPrintf("Unimplemented\n");
#ifndef __CONTENT_PACKAGE
__debugbreak();
#endif
return 0;
}
DWORD foundIndex = 0;
found = false;
DWORD index = 0;
for(AUTO_VAR(it, m_files[type].begin()); it != m_files[type].end(); ++it)
{
if(path.compare((*it)->getPath()) == 0)
{
foundIndex = index;
found = true;
break;
}
++index;
}
return foundIndex;
}
bool DLCPack::hasPurchasedFile(DLCManager::EDLCType type, const wstring &path)
{
if(type == DLCManager::e_DLCType_All)
{
app.DebugPrintf("Unimplemented\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
#endif
return false;
}
#ifndef _CONTENT_PACKAGE
if( app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_UnlockAllDLC) )
{
return true;
}
else
#endif
if ( m_dwLicenseMask == 0 )
{
//not purchased.
return false;
}
else
{
//purchased
return true;
}
}

View File

@@ -0,0 +1,93 @@
#pragma once
using namespace std;
#include "DLCManager.h"
class DLCFile;
class DLCSkinFile;
class DLCPack
{
private:
vector<DLCFile *> m_files[DLCManager::e_DLCType_Max];
vector<DLCPack *> m_childPacks;
DLCPack *m_parentPack;
unordered_map<int, wstring> m_parameters;
wstring m_packName;
wstring m_dataPath;
DWORD m_dwLicenseMask;
int m_dlcMountIndex;
XCONTENTDEVICEID m_dlcDeviceID;
#ifdef _XBOX_ONE
wstring m_wsProductId;
#else
ULONGLONG m_ullFullOfferId;
#endif
bool m_isCorrupt;
DWORD m_packId;
DWORD m_packVersion;
PBYTE m_data; // This pointer is for all the data used for this pack, so deleting it invalidates ALL of it's children.
public:
DLCPack(const wstring &name,DWORD dwLicenseMask);
#ifdef _XBOX_ONE
DLCPack(const wstring &name,const wstring &productID,DWORD dwLicenseMask);
#endif
~DLCPack();
wstring getFullDataPath() { return m_dataPath; }
void SetDataPointer(PBYTE pbData) { m_data = pbData; }
bool IsCorrupt() { return m_isCorrupt; }
void SetIsCorrupt(bool val) { m_isCorrupt = val; }
void SetPackId(DWORD id) { m_packId = id; }
DWORD GetPackId() { return m_packId; }
void SetPackVersion(DWORD version) { m_packVersion = version; }
DWORD GetPackVersion() { return m_packVersion; }
DLCPack * GetParentPack() { return m_parentPack; }
DWORD GetParentPackId() { return m_parentPack->m_packId; }
void SetDLCMountIndex(DWORD id) { m_dlcMountIndex = id; }
DWORD GetDLCMountIndex();
void SetDLCDeviceID(XCONTENTDEVICEID deviceId) { m_dlcDeviceID = deviceId; }
XCONTENTDEVICEID GetDLCDeviceID();
void addChildPack(DLCPack *childPack);
void setParentPack(DLCPack *parentPack);
void addParameter(DLCManager::EDLCParameterType type, const wstring &value);
bool getParameterAsUInt(DLCManager::EDLCParameterType type, unsigned int &param);
void updateLicenseMask( DWORD dwLicenseMask ) { m_dwLicenseMask = dwLicenseMask; }
DWORD getLicenseMask( ) { return m_dwLicenseMask; }
wstring getName() { return m_packName; }
#ifdef _XBOX_ONE
wstring getPurchaseOfferId() { return m_wsProductId; }
#else
ULONGLONG getPurchaseOfferId() { return m_ullFullOfferId; }
#endif
DLCFile *addFile(DLCManager::EDLCType type, const wstring &path);
DLCFile *getFile(DLCManager::EDLCType type, DWORD index);
DLCFile *getFile(DLCManager::EDLCType type, const wstring &path);
DWORD getDLCItemsCount(DLCManager::EDLCType type = DLCManager::e_DLCType_All);
DWORD getFileIndexAt(DLCManager::EDLCType type, const wstring &path, bool &found);
bool doesPackContainFile(DLCManager::EDLCType type, const wstring &path);
DWORD GetPackID() {return m_packId;}
DWORD getSkinCount() { return getDLCItemsCount(DLCManager::e_DLCType_Skin); }
DWORD getSkinIndexAt(const wstring &path, bool &found) { return getFileIndexAt(DLCManager::e_DLCType_Skin, path, found); }
DLCSkinFile *getSkinFile(const wstring &path) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, path); }
DLCSkinFile *getSkinFile(DWORD index) { return (DLCSkinFile *)getFile(DLCManager::e_DLCType_Skin, index); }
bool doesPackContainSkin(const wstring &path) { return doesPackContainFile(DLCManager::e_DLCType_Skin, path); }
bool hasPurchasedFile(DLCManager::EDLCType type, const wstring &path);
};

View File

@@ -0,0 +1,212 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCSkinFile.h"
#include "..\..\ModelPart.h"
#include "..\..\EntityRenderer.h"
#include "..\..\EntityRenderDispatcher.h"
#include "..\..\..\Minecraft.World\Player.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
DLCSkinFile::DLCSkinFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Skin,path)
{
m_displayName = L"";
m_themeName = L"";
m_cape = L"";
m_bIsFree = false;
m_uiAnimOverrideBitmask=0L;
}
void DLCSkinFile::addData(PBYTE pbData, DWORD dwBytes)
{
app.AddMemoryTextureFile(m_path,pbData,dwBytes);
}
void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, const wstring &value)
{
switch(type)
{
case DLCManager::e_DLCParamType_DisplayName:
{
// 4J Stu - In skin pack 2, the name for Zap is mis-spelt with two p's as Zapp
// dlcskin00000109.png
if( m_path.compare(L"dlcskin00000109.png") == 0)
{
m_displayName = L"Zap";
}
else
{
m_displayName = value;
}
}
break;
case DLCManager::e_DLCParamType_ThemeName:
m_themeName = value;
break;
case DLCManager::e_DLCParamType_Free: // If this parameter exists, then mark this as free
m_bIsFree = true;
break;
case DLCManager::e_DLCParamType_Credit: // If this parameter exists, then mark this as free
//add it to the DLC credits list
// we'll need to justify this text since we don't have a lot of room for lines of credits
{
if(app.AlreadySeenCreditText(value)) break;
// first add a blank string for spacing
app.AddCreditText(L"");
int maximumChars = 55;
bool bIsSDMode=!RenderManager.IsHiDef() && !RenderManager.IsWidescreen();
if(bIsSDMode)
{
maximumChars = 45;
}
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
maximumChars = 35;
break;
}
wstring creditValue = value;
while (creditValue.length() > maximumChars)
{
unsigned int i = 1;
while (i < creditValue.length() && (i + 1) <= maximumChars)
{
i++;
}
int iLast=(int)creditValue.find_last_of(L" ",i);
switch(XGetLanguage())
{
case XC_LANGUAGE_JAPANESE:
case XC_LANGUAGE_TCHINESE:
case XC_LANGUAGE_KOREAN:
iLast = maximumChars;
break;
default:
iLast=(int)creditValue.find_last_of(L" ",i);
break;
}
// if a space was found, include the space on this line
if(iLast!=i)
{
iLast++;
}
app.AddCreditText((creditValue.substr(0, iLast)).c_str());
creditValue = creditValue.substr(iLast);
}
app.AddCreditText(creditValue.c_str());
}
break;
case DLCManager::e_DLCParamType_Cape:
m_cape = value;
break;
case DLCManager::e_DLCParamType_Box:
{
WCHAR wchBodyPart[10];
SKIN_BOX *pSkinBox = new SKIN_BOX;
ZeroMemory(pSkinBox,sizeof(SKIN_BOX));
#ifdef __PS3__
// 4J Stu - The Xbox version used swscanf_s which isn't available in GCC.
swscanf(value.c_str(), L"%10ls%f%f%f%f%f%f%f%f", wchBodyPart,
#else
swscanf_s(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart,10,
#endif
&pSkinBox->fX,
&pSkinBox->fY,
&pSkinBox->fZ,
&pSkinBox->fW,
&pSkinBox->fH,
&pSkinBox->fD,
&pSkinBox->fU,
&pSkinBox->fV);
if(wcscmp(wchBodyPart,L"HEAD")==0)
{
pSkinBox->ePart=eBodyPart_Head;
}
else if(wcscmp(wchBodyPart,L"BODY")==0)
{
pSkinBox->ePart=eBodyPart_Body;
}
else if(wcscmp(wchBodyPart,L"ARM0")==0)
{
pSkinBox->ePart=eBodyPart_Arm0;
}
else if(wcscmp(wchBodyPart,L"ARM1")==0)
{
pSkinBox->ePart=eBodyPart_Arm1;
}
else if(wcscmp(wchBodyPart,L"LEG0")==0)
{
pSkinBox->ePart=eBodyPart_Leg0;
}
else if(wcscmp(wchBodyPart,L"LEG1")==0)
{
pSkinBox->ePart=eBodyPart_Leg1;
}
// add this to the skin's vector of parts
m_AdditionalBoxes.push_back(pSkinBox);
}
break;
case DLCManager::e_DLCParamType_Anim:
#ifdef __PS3__
// 4J Stu - The Xbox version used swscanf_s which isn't available in GCC.
swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask);
#else
swscanf_s(value.c_str(), L"%X", &m_uiAnimOverrideBitmask,sizeof(unsigned int));
#endif
DWORD skinId = app.getSkinIdFromPath(m_path);
app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
break;
}
}
// vector<ModelPart *> *DLCSkinFile::getAdditionalModelParts()
// {
// return &m_AdditionalModelParts;
// }
int DLCSkinFile::getAdditionalBoxesCount()
{
return (int)m_AdditionalBoxes.size();
}
vector<SKIN_BOX *> *DLCSkinFile::getAdditionalBoxes()
{
return &m_AdditionalBoxes;
}
wstring DLCSkinFile::getParameterAsString(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_DisplayName:
return m_displayName;
case DLCManager::e_DLCParamType_ThemeName:
return m_themeName;
case DLCManager::e_DLCParamType_Cape:
return m_cape;
default:
return L"";
}
}
bool DLCSkinFile::getParameterAsBool(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_Free:
return m_bIsFree;
default:
return false;
}
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "DLCFile.h"
#include "..\..\..\Minecraft.Client\HumanoidModel.h"
class DLCSkinFile : public DLCFile
{
private:
wstring m_displayName;
wstring m_themeName;
wstring m_cape;
unsigned int m_uiAnimOverrideBitmask;
bool m_bIsFree;
vector<SKIN_BOX *> m_AdditionalBoxes;
public:
DLCSkinFile(const wstring &path);
virtual void addData(PBYTE pbData, DWORD dwBytes);
virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value);
virtual wstring getParameterAsString(DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
vector<SKIN_BOX *> *getAdditionalBoxes();
int getAdditionalBoxesCount();
unsigned int getAnimOverrideBitmask() { return m_uiAnimOverrideBitmask;}
bool isFree() {return m_bIsFree;}
};

View File

@@ -0,0 +1,59 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCTextureFile.h"
DLCTextureFile::DLCTextureFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_Texture,path)
{
m_bIsAnim = false;
m_animString = L"";
m_pbData = NULL;
m_dwBytes = 0;
}
void DLCTextureFile::addData(PBYTE pbData, DWORD dwBytes)
{
//app.AddMemoryTextureFile(m_path,pbData,dwBytes);
m_pbData = pbData;
m_dwBytes = dwBytes;
}
PBYTE DLCTextureFile::getData(DWORD &dwBytes)
{
dwBytes = m_dwBytes;
return m_pbData;
}
void DLCTextureFile::addParameter(DLCManager::EDLCParameterType type, const wstring &value)
{
switch(type)
{
case DLCManager::e_DLCParamType_Anim:
m_animString = value;
m_bIsAnim = true;
break;
}
}
wstring DLCTextureFile::getParameterAsString(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_Anim:
return m_animString;
default:
return L"";
}
}
bool DLCTextureFile::getParameterAsBool(DLCManager::EDLCParameterType type)
{
switch(type)
{
case DLCManager::e_DLCParamType_Anim:
return m_bIsAnim;
default:
return false;
}
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include "DLCFile.h"
class DLCTextureFile : public DLCFile
{
private:
bool m_bIsAnim;
wstring m_animString;
PBYTE m_pbData;
DWORD m_dwBytes;
public:
DLCTextureFile(const wstring &path);
virtual void addData(PBYTE pbData, DWORD dwBytes);
virtual PBYTE getData(DWORD &dwBytes);
virtual void addParameter(DLCManager::EDLCParameterType type, const wstring &value);
virtual wstring getParameterAsString(DLCManager::EDLCParameterType type);
virtual bool getParameterAsBool(DLCManager::EDLCParameterType type);
};

View File

@@ -0,0 +1,32 @@
#include "stdafx.h"
#include "DLCManager.h"
#include "DLCUIDataFile.h"
DLCUIDataFile::DLCUIDataFile(const wstring &path) : DLCFile(DLCManager::e_DLCType_UIData,path)
{
m_pbData = NULL;
m_dwBytes = 0;
m_canDeleteData = false;
}
DLCUIDataFile::~DLCUIDataFile()
{
if(m_canDeleteData && m_pbData != NULL)
{
app.DebugPrintf("Deleting DLCUIDataFile data\n");
delete [] m_pbData;
}
}
void DLCUIDataFile::addData(PBYTE pbData, DWORD dwBytes,bool canDeleteData)
{
m_pbData = pbData;
m_dwBytes = dwBytes;
m_canDeleteData = canDeleteData;
}
PBYTE DLCUIDataFile::getData(DWORD &dwBytes)
{
dwBytes = m_dwBytes;
return m_pbData;
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "DLCFile.h"
class DLCUIDataFile : public DLCFile
{
private:
PBYTE m_pbData;
DWORD m_dwBytes;
bool m_canDeleteData;
public:
DLCUIDataFile(const wstring &path);
~DLCUIDataFile();
using DLCFile::addData;
using DLCFile::addParameter;
virtual void addData(PBYTE pbData, DWORD dwBytes,bool canDeleteData = false);
virtual PBYTE getData(DWORD &dwBytes);
};

View File

@@ -0,0 +1 @@
This file only exists so that I can add this folder to TFS. I am not ready to add the contents. Stu

View File

@@ -0,0 +1,70 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.enchantment.h"
#include "AddEnchantmentRuleDefinition.h"
AddEnchantmentRuleDefinition::AddEnchantmentRuleDefinition()
{
m_enchantmentId = m_enchantmentLevel = 0;
}
void AddEnchantmentRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes)
{
GameRuleDefinition::writeAttributes(dos, numAttributes + 2);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_enchantmentId);
dos->writeUTF( _toString( m_enchantmentId ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_enchantmentLevel);
dos->writeUTF( _toString( m_enchantmentLevel ) );
}
void AddEnchantmentRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"enchantmentId") == 0)
{
int value = _fromString<int>(attributeValue);
if(value < 0) value = 0;
if(value >= 256) value = 255;
m_enchantmentId = value;
app.DebugPrintf("AddEnchantmentRuleDefinition: Adding parameter enchantmentId=%d\n",m_enchantmentId);
}
else if(attributeName.compare(L"enchantmentLevel") == 0)
{
int value = _fromString<int>(attributeValue);
if(value < 0) value = 0;
m_enchantmentLevel = value;
app.DebugPrintf("AddEnchantmentRuleDefinition: Adding parameter enchantmentLevel=%d\n",m_enchantmentLevel);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool AddEnchantmentRuleDefinition::enchantItem(shared_ptr<ItemInstance> item)
{
bool enchanted = false;
if (item != NULL)
{
// 4J-JEV: Ripped code from enchantmenthelpers
// Maybe we want to add an addEnchantment method to EnchantmentHelpers
if (item->id == Item::enchantedBook_Id)
{
Item::enchantedBook->addEnchantment( item, new EnchantmentInstance(m_enchantmentId, m_enchantmentLevel) );
}
else if (item->isEnchantable())
{
Enchantment *e = Enchantment::enchantments[m_enchantmentId];
if(e != NULL && e->category->canEnchant(item->getItem()))
{
int level = min(e->getMaxLevel(), m_enchantmentLevel);
item->enchant(e, m_enchantmentLevel);
enchanted = true;
}
}
}
return enchanted;
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "GameRuleDefinition.h"
class ItemInstance;
class AddEnchantmentRuleDefinition : public GameRuleDefinition
{
private:
int m_enchantmentId;
int m_enchantmentLevel;
public:
AddEnchantmentRuleDefinition();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_AddEnchantment; }
virtual void writeAttributes(DataOutputStream *, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool enchantItem(shared_ptr<ItemInstance> item);
};

View File

@@ -0,0 +1,127 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "AddItemRuleDefinition.h"
#include "AddEnchantmentRuleDefinition.h"
AddItemRuleDefinition::AddItemRuleDefinition()
{
m_itemId = m_quantity = m_auxValue = m_dataTag = 0;
m_slot = -1;
}
void AddItemRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_itemId);
dos->writeUTF( _toString( m_itemId ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_quantity);
dos->writeUTF( _toString( m_quantity ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_auxValue);
dos->writeUTF( _toString( m_auxValue ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dataTag);
dos->writeUTF( _toString( m_dataTag ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_slot);
dos->writeUTF( _toString( m_slot ) );
}
void AddItemRuleDefinition::getChildren(vector<GameRuleDefinition *> *children)
{
GameRuleDefinition::getChildren( children );
for (AUTO_VAR(it, m_enchantments.begin()); it != m_enchantments.end(); it++)
children->push_back( *it );
}
GameRuleDefinition *AddItemRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_AddEnchantment)
{
rule = new AddEnchantmentRuleDefinition();
m_enchantments.push_back((AddEnchantmentRuleDefinition *)rule);
}
else
{
#ifndef _CONTENT_PACKAGE
//wprintf(L"AddItemRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
return rule;
}
void AddItemRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"itemId") == 0)
{
int value = _fromString<int>(attributeValue);
m_itemId = value;
//app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter itemId=%d\n",m_itemId);
}
else if(attributeName.compare(L"quantity") == 0)
{
int value = _fromString<int>(attributeValue);
m_quantity = value;
//app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter quantity=%d\n",m_quantity);
}
else if(attributeName.compare(L"auxValue") == 0)
{
int value = _fromString<int>(attributeValue);
m_auxValue = value;
//app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter auxValue=%d\n",m_auxValue);
}
else if(attributeName.compare(L"dataTag") == 0)
{
int value = _fromString<int>(attributeValue);
m_dataTag = value;
//app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter dataTag=%d\n",m_dataTag);
}
else if(attributeName.compare(L"slot") == 0)
{
int value = _fromString<int>(attributeValue);
m_slot = value;
//app.DebugPrintf(2,"AddItemRuleDefinition: Adding parameter slot=%d\n",m_slot);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool AddItemRuleDefinition::addItemToContainer(shared_ptr<Container> container, int slotId)
{
bool added = false;
if(Item::items[m_itemId] != NULL)
{
int quantity = min(m_quantity, Item::items[m_itemId]->getMaxStackSize());
shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>(new ItemInstance(m_itemId,quantity,m_auxValue) );
newItem->set4JData(m_dataTag);
for(AUTO_VAR(it, m_enchantments.begin()); it != m_enchantments.end(); ++it)
{
(*it)->enchantItem(newItem);
}
if(m_slot >= 0 && m_slot < container->getContainerSize() )
{
container->setItem( m_slot, newItem );
added = true;
}
else if(slotId >= 0 && slotId < container->getContainerSize() )
{
container->setItem( slotId, newItem );
added = true;
}
else if(dynamic_pointer_cast<Inventory>(container) != NULL)
{
added = dynamic_pointer_cast<Inventory>(container)->add(newItem);
}
}
return added;
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include "GameRuleDefinition.h"
class Container;
class AddEnchantmentRuleDefinition;
class AddItemRuleDefinition : public GameRuleDefinition
{
private:
int m_itemId;
int m_quantity;
int m_auxValue;
int m_dataTag;
int m_slot;
vector<AddEnchantmentRuleDefinition *> m_enchantments;
public:
AddItemRuleDefinition();
virtual void writeAttributes(DataOutputStream *, UINT numAttributes);
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_AddItem; }
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool addItemToContainer(shared_ptr<Container> container, int slotId);
};

View File

@@ -0,0 +1,249 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.phys.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.dimension.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.chunk.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
#include "ApplySchematicRuleDefinition.h"
#include "LevelGenerationOptions.h"
#include "ConsoleSchematicFile.h"
ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(LevelGenerationOptions *levelGenOptions)
{
m_levelGenOptions = levelGenOptions;
m_location = Vec3::newPermanent(0,0,0);
m_locationBox = NULL;
m_totalBlocksChanged = 0;
m_totalBlocksChangedLighting = 0;
m_rotation = ConsoleSchematicFile::eSchematicRot_0;
m_completed = false;
m_dimension = 0;
m_schematic = NULL;
}
ApplySchematicRuleDefinition::~ApplySchematicRuleDefinition()
{
app.DebugPrintf("Deleting ApplySchematicRuleDefinition.\n");
if(!m_completed) m_levelGenOptions->releaseSchematicFile(m_schematicName);
m_schematic = NULL;
delete m_location;
}
void ApplySchematicRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_filename);
dos->writeUTF(m_schematicName);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_location->x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_location->y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_location->z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_rot);
switch (m_rotation)
{
case ConsoleSchematicFile::eSchematicRot_0: dos->writeUTF(_toString( 0 )); break;
case ConsoleSchematicFile::eSchematicRot_90: dos->writeUTF(_toString( 90 )); break;
case ConsoleSchematicFile::eSchematicRot_180: dos->writeUTF(_toString( 180 )); break;
case ConsoleSchematicFile::eSchematicRot_270: dos->writeUTF(_toString( 270 )); break;
}
}
void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"filename") == 0)
{
m_schematicName = attributeValue;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter filename=%s\n",m_schematicName.c_str());
if(!m_schematicName.empty())
{
if(m_schematicName.substr( m_schematicName.length() - 4, m_schematicName.length()).compare(L".sch") != 0)
{
m_schematicName.append(L".sch");
}
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
}
}
else if(attributeName.compare(L"x") == 0)
{
m_location->x = _fromString<int>(attributeValue);
if( ((int)abs(m_location->x))%2 != 0) m_location->x -=1;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter x=%f\n",m_location->x);
}
else if(attributeName.compare(L"y") == 0)
{
m_location->y = _fromString<int>(attributeValue);
if( ((int)abs(m_location->y))%2 != 0) m_location->y -= 1;
if(m_location->y < 0) m_location->y = 0;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter y=%f\n",m_location->y);
}
else if(attributeName.compare(L"z") == 0)
{
m_location->z = _fromString<int>(attributeValue);
if(((int)abs(m_location->z))%2 != 0) m_location->z -= 1;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter z=%f\n",m_location->z);
}
else if(attributeName.compare(L"rot") == 0)
{
int degrees = _fromString<int>(attributeValue);
while(degrees < 0) degrees += 360;
while(degrees >= 360) degrees -= 360;
float quad = degrees/90;
degrees = (int)(quad + 0.5f);
switch(degrees)
{
case 1:
m_rotation = ConsoleSchematicFile::eSchematicRot_90;
break;
case 2:
m_rotation = ConsoleSchematicFile::eSchematicRot_180;
break;
case 3:
case 4:
m_rotation = ConsoleSchematicFile::eSchematicRot_270;
break;
case 0:
default:
m_rotation = ConsoleSchematicFile::eSchematicRot_0;
break;
};
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter rot=%d\n",m_rotation);
}
else if(attributeName.compare(L"dim") == 0)
{
m_dimension = _fromString<int>(attributeValue);
if(m_dimension > 1 || m_dimension < -1) m_dimension = 0;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter dimension=%d\n",m_dimension);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
void ApplySchematicRuleDefinition::updateLocationBox()
{
if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
m_locationBox = AABB::newPermanent(0,0,0,0,0,0);
m_locationBox->x0 = m_location->x;
m_locationBox->y0 = m_location->y;
m_locationBox->z0 = m_location->z;
m_locationBox->y1 = m_location->y + m_schematic->getYSize();
switch(m_rotation)
{
case ConsoleSchematicFile::eSchematicRot_90:
case ConsoleSchematicFile::eSchematicRot_270:
m_locationBox->x1 = m_location->x + m_schematic->getZSize();
m_locationBox->z1 = m_location->z + m_schematic->getXSize();
break;
case ConsoleSchematicFile::eSchematicRot_0:
case ConsoleSchematicFile::eSchematicRot_180:
default:
m_locationBox->x1 = m_location->x + m_schematic->getXSize();
m_locationBox->z1 = m_location->z + m_schematic->getZSize();
break;
};
}
void ApplySchematicRuleDefinition::processSchematic(AABB *chunkBox, LevelChunk *chunk)
{
if( m_completed ) return;
if(chunk->level->dimension->id != m_dimension) return;
PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition");
if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
if(m_locationBox == NULL) updateLocationBox();
if(chunkBox->intersects( m_locationBox ))
{
m_locationBox->y1 = min((double)Level::maxBuildHeight, m_locationBox->y1 );
#ifdef _DEBUG
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",m_schematicName.c_str(),chunk->x, chunk->z);
#endif
PIXBeginNamedEvent(0,"Applying blocks and data");
m_totalBlocksChanged += m_schematic->applyBlocksAndData(chunk, chunkBox, m_locationBox, m_rotation);
PIXEndNamedEvent();
// Add the tileEntities
PIXBeginNamedEvent(0,"Applying tile entities");
m_schematic->applyTileEntities(chunk, chunkBox, m_locationBox, m_rotation);
PIXEndNamedEvent();
// TODO This does not take into account things that go outside the bounds of the world
int targetBlocks = (m_locationBox->x1 - m_locationBox->x0)
* (m_locationBox->y1 - m_locationBox->y0)
* (m_locationBox->z1 - m_locationBox->z0);
if( (m_totalBlocksChanged == targetBlocks) && (m_totalBlocksChangedLighting == targetBlocks) )
{
m_completed = true;
//m_levelGenOptions->releaseSchematicFile(m_schematicName);
//m_schematic = NULL;
}
}
PIXEndNamedEvent();
}
void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, LevelChunk *chunk)
{
if( m_completed ) return;
if(chunk->level->dimension->id != m_dimension) return;
PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition (lighting)");
if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
if(m_locationBox == NULL) updateLocationBox();
if(chunkBox->intersects( m_locationBox ))
{
m_locationBox->y1 = min((double)Level::maxBuildHeight, m_locationBox->y1 );
#ifdef _DEBUG
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",m_schematicName.c_str(),chunk->x, chunk->z);
#endif
PIXBeginNamedEvent(0,"Patching lighting");
m_totalBlocksChangedLighting += m_schematic->applyLighting(chunk, chunkBox, m_locationBox, m_rotation);
PIXEndNamedEvent();
// TODO This does not take into account things that go outside the bounds of the world
int targetBlocks = (m_locationBox->x1 - m_locationBox->x0)
* (m_locationBox->y1 - m_locationBox->y0)
* (m_locationBox->z1 - m_locationBox->z0);
if( (m_totalBlocksChanged == targetBlocks) && (m_totalBlocksChangedLighting == targetBlocks) )
{
m_completed = true;
//m_levelGenOptions->releaseSchematicFile(m_schematicName);
//m_schematic = NULL;
}
}
PIXEndNamedEvent();
}
bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1)
{
if( m_locationBox == NULL ) updateLocationBox();
return m_locationBox->intersects(x0,y0,z0,x1,y1,z1);
}
int ApplySchematicRuleDefinition::getMinY()
{
if( m_locationBox == NULL ) updateLocationBox();
return m_locationBox->y0;
}
void ApplySchematicRuleDefinition::reset()
{
m_totalBlocksChanged = 0;
m_totalBlocksChangedLighting = 0;
m_completed = false;
}

View File

@@ -0,0 +1,51 @@
#pragma once
#include "GameRuleDefinition.h"
#include "ConsoleSchematicFile.h"
class AABB;
class Vec3;
class LevelChunk;
class LevelGenerationOptions;
class GRFObject;
class ApplySchematicRuleDefinition : public GameRuleDefinition
{
private:
LevelGenerationOptions *m_levelGenOptions;
wstring m_schematicName;
ConsoleSchematicFile *m_schematic;
Vec3 *m_location;
AABB *m_locationBox;
ConsoleSchematicFile::ESchematicRotation m_rotation;
int m_dimension;
__int64 m_totalBlocksChanged;
__int64 m_totalBlocksChangedLighting;
bool m_completed;
void updateLocationBox();
public:
ApplySchematicRuleDefinition(LevelGenerationOptions *levelGenOptions);
~ApplySchematicRuleDefinition();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_ApplySchematic; }
virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
void processSchematic(AABB *chunkBox, LevelChunk *chunk);
void processSchematicLighting(AABB *chunkBox, LevelChunk *chunk);
bool checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1);
int getMinY();
bool isComplete() { return m_completed; }
wstring getSchematicName() { return m_schematicName; }
/** 4J-JEV:
* This GameRuleDefinition contains limited game state.
* Reset any state to how it should be before a new game.
*/
void reset();
};

View File

@@ -0,0 +1,59 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "BiomeOverride.h"
BiomeOverride::BiomeOverride()
{
m_tile = 0;
m_topTile = 0;
m_biomeId = 0;
}
void BiomeOverride::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
GameRuleDefinition::writeAttributes(dos, numAttrs + 3);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_biomeId);
dos->writeUTF(_toString(m_biomeId));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_tileId);
dos->writeUTF(_toString(m_tile));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_topTileId);
dos->writeUTF(_toString(m_topTile));
}
void BiomeOverride::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"tileId") == 0)
{
int value = _fromString<int>(attributeValue);
m_tile = value;
app.DebugPrintf("BiomeOverride: Adding parameter tileId=%d\n",m_tile);
}
else if(attributeName.compare(L"topTileId") == 0)
{
int value = _fromString<int>(attributeValue);
m_topTile = value;
app.DebugPrintf("BiomeOverride: Adding parameter topTileId=%d\n",m_topTile);
}
else if(attributeName.compare(L"biomeId") == 0)
{
int value = _fromString<int>(attributeValue);
m_biomeId = value;
app.DebugPrintf("BiomeOverride: Adding parameter biomeId=%d\n",m_biomeId);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool BiomeOverride::isBiome(int id)
{
return m_biomeId == id;
}
void BiomeOverride::getTileValues(BYTE &tile, BYTE &topTile)
{
if(m_tile != 0) tile = (BYTE)m_tile;
if(m_topTile != 0) topTile = (BYTE)m_topTile;
}

View File

@@ -0,0 +1,23 @@
#pragma once
using namespace std;
#include "GameRuleDefinition.h"
class BiomeOverride : public GameRuleDefinition
{
private:
BYTE m_topTile;
BYTE m_tile;
int m_biomeId;
public:
BiomeOverride();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_BiomeOverride; }
virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool isBiome(int id);
void getTileValues(BYTE &tile, BYTE &topTile);
};

View File

@@ -0,0 +1,117 @@
#include "stdafx.h"
#include "..\..\WstringLookup.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "CollectItemRuleDefinition.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "..\..\..\Minecraft.World\Connection.h"
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
CollectItemRuleDefinition::CollectItemRuleDefinition()
{
m_itemId = 0;
m_auxValue = 0;
m_quantity = 0;
}
CollectItemRuleDefinition::~CollectItemRuleDefinition()
{
}
void CollectItemRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes)
{
GameRuleDefinition::writeAttributes(dos, numAttributes + 3);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_itemId);
dos->writeUTF( _toString( m_itemId ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_auxValue);
dos->writeUTF( _toString( m_auxValue ) );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_quantity);
dos->writeUTF( _toString( m_quantity ) );
}
void CollectItemRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"itemId") == 0)
{
m_itemId = _fromString<int>(attributeValue);
app.DebugPrintf("CollectItemRule: Adding parameter itemId=%d\n",m_itemId);
}
else if(attributeName.compare(L"auxValue") == 0)
{
m_auxValue = _fromString<int>(attributeValue);
app.DebugPrintf("CollectItemRule: Adding parameter m_auxValue=%d\n",m_auxValue);
}
else if(attributeName.compare(L"quantity") == 0)
{
m_quantity = _fromString<int>(attributeValue);
app.DebugPrintf("CollectItemRule: Adding parameter m_quantity=%d\n",m_quantity);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
int CollectItemRuleDefinition::getGoal()
{
return m_quantity;
}
int CollectItemRuleDefinition::getProgress(GameRule *rule)
{
GameRule::ValueType value = rule->getParameter(L"iQuantity");
return value.i;
}
void CollectItemRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule)
{
GameRule::ValueType value;
value.i = 0;
rule->setParameter(L"iQuantity",value);
GameRuleDefinition::populateGameRule(type, rule);
}
bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
{
bool statusChanged = false;
if(item != NULL && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue)
{
if(!getComplete(rule))
{
GameRule::ValueType value = rule->getParameter(L"iQuantity");
int quantityCollected = (value.i += item->count);
rule->setParameter(L"iQuantity",value);
statusChanged = true;
if(quantityCollected >= m_quantity)
{
setComplete(rule, true);
app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId,m_auxValue,m_quantity,m_4JDataValue);
if(rule->getConnection() != NULL)
{
rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,NULL,0)));
}
}
}
}
return statusChanged;
}
wstring CollectItemRuleDefinition::generateXml(shared_ptr<ItemInstance> item)
{
// 4J Stu - This should be kept in sync with the GameRulesDefinition.xsd
wstring xml = L"";
if(item != NULL)
{
xml = L"<CollectItemRule itemId=\"" + _toString<int>(item->id) + L"\" quantity=\"SET\" descriptionName=\"OPTIONAL\" promptName=\"OPTIONAL\"";
if(item->getAuxValue() != 0) xml += L" auxValue=\"" + _toString<int>(item->getAuxValue()) + L"\"";
if(item->get4JData() != 0) xml += L" dataTag=\"" + _toString<int>(item->get4JData()) + L"\"";
xml += L"/>\n";
}
return xml;
}

View File

@@ -0,0 +1,40 @@
#pragma once
#include "GameRuleDefinition.h"
class Pos;
class UseTileRuleDefinition;
class ItemInstance;
class CollectItemRuleDefinition : public GameRuleDefinition
{
private:
// These values should map directly to the xsd definition for this Rule
int m_itemId;
unsigned char m_auxValue;
int m_quantity;
public:
CollectItemRuleDefinition();
~CollectItemRuleDefinition();
ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_CollectItemRule; }
virtual void writeAttributes(DataOutputStream *, UINT numAttributes);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
virtual int getGoal();
virtual int getProgress(GameRule *rule);
virtual int getIcon() { return m_itemId; }
virtual int getAuxValue() { return m_auxValue; }
void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule);
bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item);
static wstring generateXml(shared_ptr<ItemInstance> item);
private:
//static wstring generateXml(CollectItemRuleDefinition *ruleDef);
};

View File

@@ -0,0 +1,66 @@
#include "stdafx.h"
#include "CompleteAllRuleDefinition.h"
#include "ConsoleGameRules.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\Connection.h"
#include "..\..\..\Minecraft.World\net.minecraft.network.packet.h"
void CompleteAllRuleDefinition::getChildren(vector<GameRuleDefinition *> *children)
{
CompoundGameRuleDefinition::getChildren(children);
}
bool CompleteAllRuleDefinition::onUseTile(GameRule *rule, int tileId, int x, int y, int z)
{
bool statusChanged = CompoundGameRuleDefinition::onUseTile(rule,tileId,x,y,z);
if(statusChanged) updateStatus(rule);
return statusChanged;
}
bool CompleteAllRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
{
bool statusChanged = CompoundGameRuleDefinition::onCollectItem(rule,item);
if(statusChanged) updateStatus(rule);
return statusChanged;
}
void CompleteAllRuleDefinition::updateStatus(GameRule *rule)
{
int goal = 0;
int progress = 0;
for(AUTO_VAR(it, rule->m_parameters.begin()); it != rule->m_parameters.end(); ++it)
{
if(it->second.isPointer)
{
goal += it->second.gr->getGameRuleDefinition()->getGoal();
progress += it->second.gr->getGameRuleDefinition()->getProgress(it->second.gr);
}
}
if(rule->getConnection() != NULL)
{
PacketData data;
data.goal = goal;
data.progress = progress;
int icon = -1;
int auxValue = 0;
if(m_lastRuleStatusChanged != NULL)
{
icon = m_lastRuleStatusChanged->getIcon();
auxValue = m_lastRuleStatusChanged->getAuxValue();
m_lastRuleStatusChanged = NULL;
}
rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData))));
}
app.DebugPrintf("Updated CompleteAllRule - Completed %d of %d\n", progress, goal);
}
wstring CompleteAllRuleDefinition::generateDescriptionString(const wstring &description, void *data, int dataLength)
{
PacketData *values = (PacketData *)data;
wstring newDesc = description;
newDesc = replaceAll(newDesc,L"{*progress*}",_toString<int>(values->progress));
newDesc = replaceAll(newDesc,L"{*goal*}",_toString<int>(values->goal));
return newDesc;
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "CompoundGameRuleDefinition.h"
class CompleteAllRuleDefinition : public CompoundGameRuleDefinition
{
private:
typedef struct _packetData
{
int goal;
int progress;
} PacketData;
public:
ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_CompleteAllRule; }
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z);
virtual bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item);
static wstring generateDescriptionString(const wstring &description, void *data, int dataLength);
private:
void updateStatus(GameRule *rule);
};

View File

@@ -0,0 +1,118 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
#include "CompoundGameRuleDefinition.h"
#include "ConsoleGameRules.h"
CompoundGameRuleDefinition::CompoundGameRuleDefinition()
{
m_lastRuleStatusChanged = NULL;
}
CompoundGameRuleDefinition::~CompoundGameRuleDefinition()
{
for(AUTO_VAR(it, m_children.begin()); it != m_children.end(); ++it)
{
delete (*it);
}
}
void CompoundGameRuleDefinition::getChildren(vector<GameRuleDefinition *> *children)
{
GameRuleDefinition::getChildren(children);
for (AUTO_VAR(it, m_children.begin()); it != m_children.end(); it++)
children->push_back(*it);
}
GameRuleDefinition *CompoundGameRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_CompleteAllRule)
{
rule = new CompleteAllRuleDefinition();
}
else if(ruleType == ConsoleGameRules::eGameRuleType_CollectItemRule)
{
rule = new CollectItemRuleDefinition();
}
else if(ruleType == ConsoleGameRules::eGameRuleType_UseTileRule)
{
rule = new UseTileRuleDefinition();
}
else if(ruleType == ConsoleGameRules::eGameRuleType_UpdatePlayerRule)
{
rule = new UpdatePlayerRuleDefinition();
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"CompoundGameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
if(rule != NULL) m_children.push_back(rule);
return rule;
}
void CompoundGameRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule)
{
GameRule *newRule = NULL;
int i = 0;
for(AUTO_VAR(it, m_children.begin()); it != m_children.end(); ++it)
{
newRule = new GameRule(*it, rule->getConnection() );
(*it)->populateGameRule(type,newRule);
GameRule::ValueType value;
value.gr = newRule;
value.isPointer = true;
// Somehow add the newRule to the current rule
rule->setParameter(L"rule" + _toString<int>(i),value);
++i;
}
GameRuleDefinition::populateGameRule(type, rule);
}
bool CompoundGameRuleDefinition::onUseTile(GameRule *rule, int tileId, int x, int y, int z)
{
bool statusChanged = false;
for(AUTO_VAR(it, rule->m_parameters.begin()); it != rule->m_parameters.end(); ++it)
{
if(it->second.isPointer)
{
bool changed = it->second.gr->getGameRuleDefinition()->onUseTile(it->second.gr,tileId,x,y,z);
if(!statusChanged && changed)
{
m_lastRuleStatusChanged = it->second.gr->getGameRuleDefinition();
statusChanged = true;
}
}
}
return statusChanged;
}
bool CompoundGameRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
{
bool statusChanged = false;
for(AUTO_VAR(it, rule->m_parameters.begin()); it != rule->m_parameters.end(); ++it)
{
if(it->second.isPointer)
{
bool changed = it->second.gr->getGameRuleDefinition()->onCollectItem(it->second.gr,item);
if(!statusChanged && changed)
{
m_lastRuleStatusChanged = it->second.gr->getGameRuleDefinition();
statusChanged = true;
}
}
}
return statusChanged;
}
void CompoundGameRuleDefinition::postProcessPlayer(shared_ptr<Player> player)
{
for(AUTO_VAR(it, m_children.begin()); it != m_children.end(); ++it)
{
(*it)->postProcessPlayer(player);
}
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "GameRuleDefinition.h"
class CompoundGameRuleDefinition : public GameRuleDefinition
{
protected:
vector<GameRuleDefinition *> m_children;
protected:
GameRuleDefinition *m_lastRuleStatusChanged;
public:
CompoundGameRuleDefinition();
virtual ~CompoundGameRuleDefinition();
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule);
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z);
virtual bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item);
virtual void postProcessPlayer(shared_ptr<Player> player);
};

View File

@@ -0,0 +1,32 @@
#pragma once
#include "ConsoleGameRulesConstants.h"
#include "GameRuleManager.h"
#include "GameRule.h"
#include "GameRuleDefinition.h"
#include "LevelRuleset.h"
#include "NamedAreaRuleDefinition.h"
#include "CollectItemRuleDefinition.h"
#include "CompleteAllRuleDefinition.h"
#include "CompoundGameRuleDefinition.h"
#include "UseTileRuleDefinition.h"
#include "UpdatePlayerRuleDefinition.h"
#include "AddItemRuleDefinition.h"
#include "AddEnchantmentRuleDefinition.h"
#include "LevelGenerationOptions.h"
#include "ApplySchematicRuleDefinition.h"
#include "ConsoleGenerateStructure.h"
#include "ConsoleGenerateStructureAction.h"
#include "XboxStructureActionGenerateBox.h"
#include "XboxStructureActionPlaceBlock.h"
#include "XboxStructureActionPlaceContainer.h"
#include "XboxStructureActionPlaceSpawner.h"
#include "BiomeOverride.h"
#include "StartFeature.h"
#include "GameRulesInstance.h"

View File

@@ -0,0 +1,119 @@
#pragma once
//#include "
class ConsoleGameRules
{
public:
enum EGameRuleType
{
eGameRuleType_Invalid = -1,
eGameRuleType_Root = 0, // This is the top level rule that defines a game mode, this is used to generate data for new players
eGameRuleType_LevelGenerationOptions,
eGameRuleType_ApplySchematic,
eGameRuleType_GenerateStructure,
eGameRuleType_GenerateBox,
eGameRuleType_PlaceBlock,
eGameRuleType_PlaceContainer,
eGameRuleType_PlaceSpawner,
eGameRuleType_BiomeOverride,
eGameRuleType_StartFeature,
eGameRuleType_AddItem,
eGameRuleType_AddEnchantment,
eGameRuleType_LevelRules,
eGameRuleType_NamedArea,
eGameRuleType_UseTileRule,
eGameRuleType_CollectItemRule,
eGameRuleType_CompleteAllRule,
eGameRuleType_UpdatePlayerRule,
eGameRuleType_Count
};
enum EGameRuleAttr
{
eGameRuleAttr_Invalid = -1,
eGameRuleAttr_descriptionName = 0,
eGameRuleAttr_promptName,
eGameRuleAttr_dataTag,
eGameRuleAttr_enchantmentId,
eGameRuleAttr_enchantmentLevel,
eGameRuleAttr_itemId,
eGameRuleAttr_quantity,
eGameRuleAttr_auxValue,
eGameRuleAttr_slot,
eGameRuleAttr_name,
eGameRuleAttr_food,
eGameRuleAttr_health,
eGameRuleAttr_tileId,
eGameRuleAttr_useCoords,
eGameRuleAttr_seed,
eGameRuleAttr_flatworld,
eGameRuleAttr_filename,
eGameRuleAttr_rot,
eGameRuleAttr_data,
eGameRuleAttr_block,
eGameRuleAttr_entity,
eGameRuleAttr_facing,
eGameRuleAttr_edgeTile,
eGameRuleAttr_fillTile,
eGameRuleAttr_skipAir,
eGameRuleAttr_x,
eGameRuleAttr_x0,
eGameRuleAttr_x1,
eGameRuleAttr_y,
eGameRuleAttr_y0,
eGameRuleAttr_y1,
eGameRuleAttr_z,
eGameRuleAttr_z0,
eGameRuleAttr_z1,
eGameRuleAttr_chunkX,
eGameRuleAttr_chunkZ,
eGameRuleAttr_yRot,
eGameRuleAttr_spawnX,
eGameRuleAttr_spawnY,
eGameRuleAttr_spawnZ,
eGameRuleAttr_orientation,
eGameRuleAttr_dimension,
eGameRuleAttr_topTileId,
eGameRuleAttr_biomeId,
eGameRuleAttr_feature,
eGameRuleAttr_Count
};
static void write(DataOutputStream *dos, ConsoleGameRules::EGameRuleType eType)
{
dos->writeInt(eType);
}
static void write(DataOutputStream *dos, ConsoleGameRules::EGameRuleAttr eAttr)
{
dos->writeInt( eGameRuleType_Count + eAttr );
}
};

View File

@@ -0,0 +1,181 @@
#include "stdafx.h"
#include "ConsoleGenerateStructure.h"
#include "ConsoleGameRules.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.dimension.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.levelgen.structure.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.h"
ConsoleGenerateStructure::ConsoleGenerateStructure() : StructurePiece(0)
{
m_x = m_y = m_z = 0;
boundingBox = NULL;
orientation = Direction::NORTH;
m_dimension = 0;
}
void ConsoleGenerateStructure::getChildren(vector<GameRuleDefinition *> *children)
{
GameRuleDefinition::getChildren(children);
for(AUTO_VAR(it, m_actions.begin()); it != m_actions.end(); it++)
children->push_back( *it );
}
GameRuleDefinition *ConsoleGenerateStructure::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_GenerateBox)
{
rule = new XboxStructureActionGenerateBox();
m_actions.push_back((XboxStructureActionGenerateBox *)rule);
}
else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceBlock)
{
rule = new XboxStructureActionPlaceBlock();
m_actions.push_back((XboxStructureActionPlaceBlock *)rule);
}
else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceContainer)
{
rule = new XboxStructureActionPlaceContainer();
m_actions.push_back((XboxStructureActionPlaceContainer *)rule);
}
else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceSpawner)
{
rule = new XboxStructureActionPlaceSpawner();
m_actions.push_back((XboxStructureActionPlaceSpawner *)rule);
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"ConsoleGenerateStructure: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
return rule;
}
void ConsoleGenerateStructure::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_orientation);
dos->writeUTF(_toString(orientation));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dimension);
dos->writeUTF(_toString(m_dimension));
}
void ConsoleGenerateStructure::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"x") == 0)
{
int value = _fromString<int>(attributeValue);
m_x = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter x=%d\n",m_x);
}
else if(attributeName.compare(L"y") == 0)
{
int value = _fromString<int>(attributeValue);
m_y = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter y=%d\n",m_y);
}
else if(attributeName.compare(L"z") == 0)
{
int value = _fromString<int>(attributeValue);
m_z = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter z=%d\n",m_z);
}
else if(attributeName.compare(L"orientation") == 0)
{
int value = _fromString<int>(attributeValue);
orientation = value;
app.DebugPrintf("ConsoleGenerateStructure: Adding parameter orientation=%d\n",orientation);
}
else if(attributeName.compare(L"dim") == 0)
{
m_dimension = _fromString<int>(attributeValue);
if(m_dimension > 1 || m_dimension < -1) m_dimension = 0;
app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter dimension=%d\n",m_dimension);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
BoundingBox* ConsoleGenerateStructure::getBoundingBox()
{
if(boundingBox == NULL)
{
// Find the max bounds
int maxX, maxY, maxZ;
maxX = maxY = maxZ = 1;
for(AUTO_VAR(it, m_actions.begin()); it != m_actions.end(); ++it)
{
ConsoleGenerateStructureAction *action = *it;
maxX = max(maxX,action->getEndX());
maxY = max(maxY,action->getEndY());
maxZ = max(maxZ,action->getEndZ());
}
boundingBox = new BoundingBox(m_x, m_y, m_z, m_x + maxX, m_y + maxY, m_z + maxZ);
}
return boundingBox;
}
bool ConsoleGenerateStructure::postProcess(Level *level, Random *random, BoundingBox *chunkBB)
{
if(level->dimension->id != m_dimension) return false;
for(AUTO_VAR(it, m_actions.begin()); it != m_actions.end(); ++it)
{
ConsoleGenerateStructureAction *action = *it;
switch(action->getActionType())
{
case ConsoleGameRules::eGameRuleType_GenerateBox:
{
XboxStructureActionGenerateBox *genBox = (XboxStructureActionGenerateBox *)action;
genBox->generateBoxInLevel(this,level,chunkBB);
}
break;
case ConsoleGameRules::eGameRuleType_PlaceBlock:
{
XboxStructureActionPlaceBlock *pPlaceBlock = (XboxStructureActionPlaceBlock *)action;
pPlaceBlock->placeBlockInLevel(this,level,chunkBB);
}
break;
case ConsoleGameRules::eGameRuleType_PlaceContainer:
{
XboxStructureActionPlaceContainer *pPlaceContainer = (XboxStructureActionPlaceContainer *)action;
pPlaceContainer->placeContainerInLevel(this,level,chunkBB);
}
break;
case ConsoleGameRules::eGameRuleType_PlaceSpawner:
{
XboxStructureActionPlaceSpawner *pPlaceSpawner = (XboxStructureActionPlaceSpawner *)action;
pPlaceSpawner->placeSpawnerInLevel(this,level,chunkBB);
}
break;
};
}
return false;
}
bool ConsoleGenerateStructure::checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1)
{
return getBoundingBox()->intersects(x0,y0,z0,x1,y1,z1);
}
int ConsoleGenerateStructure::getMinY()
{
return getBoundingBox()->y0;
}

View File

@@ -0,0 +1,38 @@
#pragma once
#include "GameRuleDefinition.h"
#include "..\..\..\Minecraft.World\StructurePiece.h"
class Level;
class Random;
class BoundingBox;
class ConsoleGenerateStructureAction;
class XboxStructureActionPlaceContainer;
class GRFObject;
class ConsoleGenerateStructure : public GameRuleDefinition, public StructurePiece
{
private:
int m_x, m_y, m_z;
vector<ConsoleGenerateStructureAction *> m_actions;
int m_dimension;
public:
ConsoleGenerateStructure();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_GenerateStructure; }
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
// StructurePiece
virtual BoundingBox *getBoundingBox();
virtual bool postProcess(Level *level, Random *random, BoundingBox *chunkBB);
void createContainer(XboxStructureActionPlaceContainer *action, Level *level, BoundingBox *chunkBB);
bool checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1);
virtual int getMinY();
};

View File

@@ -0,0 +1,11 @@
#pragma once
#include "GameRuleDefinition.h"
class ConsoleGenerateStructureAction : public GameRuleDefinition
{
public:
virtual int getEndX() = 0;
virtual int getEndY() = 0;
virtual int getEndZ() = 0;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,90 @@
#pragma once
using namespace std;
#define XBOX_SCHEMATIC_ORIGINAL_VERSION 1
#define XBOX_SCHEMATIC_CURRENT_VERSION 2
#include "..\..\..\Minecraft.World\ArrayWithLength.h"
class Level;
class DataOutputStream;
class DataInputStream;
class TileEntity;
class LevelChunk;
class AABB;
class Vec3;
class ConsoleSchematicFile
{
public:
enum ESchematicRotation
{
eSchematicRot_0,
eSchematicRot_90,
eSchematicRot_180,
eSchematicRot_270
};
private:
int m_refCount;
public:
void incrementRefCount() { ++m_refCount; }
void decrementRefCount() { --m_refCount; }
bool shouldDelete() { return m_refCount <= 0; }
typedef struct _XboxSchematicInitParam
{
wchar_t name[64];
int startX;
int startY;
int startZ;
int endX;
int endY;
int endZ;
bool bSaveMobs;
Compression::ECompressionTypes compressionType;
_XboxSchematicInitParam()
{
ZeroMemory(name,64*(sizeof(wchar_t)));
startX = startY = startZ = endX = endY = endZ = 0;
bSaveMobs = false;
compressionType = Compression::eCompressionType_None;
}
} XboxSchematicInitParam;
private:
int m_xSize, m_ySize, m_zSize;
vector<shared_ptr<TileEntity> > m_tileEntities;
vector< pair<Vec3 *, CompoundTag *> > m_entities;
public:
byteArray m_data;
public:
ConsoleSchematicFile();
~ConsoleSchematicFile();
int getXSize() { return m_xSize; }
int getYSize() { return m_ySize; }
int getZSize() { return m_zSize; }
void save(DataOutputStream *dos);
void load(DataInputStream *dis);
__int64 applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot);
__int64 applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot);
void applyTileEntities(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot);
static void generateSchematicFile(DataOutputStream *dos, Level *level, int xStart, int yStart, int zStart, int xEnd, int yEnd, int zEnd, bool bSaveMobs, Compression::ECompressionTypes);
static void setBlocksAndData(LevelChunk *chunk, byteArray blockData, byteArray dataData, byteArray data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP);
private:
void save_tags(DataOutputStream *dos);
void load_tags(DataInputStream *dis);
static void getBlocksAndData(LevelChunk *chunk, byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP);
static vector<shared_ptr<TileEntity> > *getTileEntitiesInRegion(LevelChunk *chunk, int x0, int y0, int z0, int x1, int y1, int z1);
void chunkCoordToSchematicCoord(AABB *destinationBox, int chunkX, int chunkZ, ESchematicRotation rot, int &schematicX, int &schematicZ);
void schematicCoordToChunkCoord(AABB *destinationBox, double schematicX, double schematicZ, ESchematicRotation rot, double &chunkX, double &chunkZ);
};

View File

@@ -0,0 +1,97 @@
#include "stdafx.h"
#include "ConsoleGameRules.h"
GameRule::GameRule(GameRuleDefinition *definition, Connection *connection)
{
m_definition = definition;
m_connection = connection;
}
GameRule::~GameRule()
{
for(AUTO_VAR(it, m_parameters.begin()); it != m_parameters.end(); ++it)
{
if(it->second.isPointer)
{
delete it->second.gr;
}
}
}
GameRule::ValueType GameRule::getParameter(const wstring &parameterName)
{
if(m_parameters.find(parameterName) == m_parameters.end())
{
#ifndef _CONTENT_PACKAGE
wprintf(L"WARNING: Parameter %ls was not set before being fetched\n", parameterName.c_str());
__debugbreak();
#endif
}
return m_parameters[parameterName];
}
void GameRule::setParameter(const wstring &parameterName,ValueType value)
{
if(m_parameters.find(parameterName) == m_parameters.end())
{
#ifndef _CONTENT_PACKAGE
wprintf(L"Adding parameter %ls to GameRule\n", parameterName.c_str());
#endif
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"Setting parameter %ls for GameRule\n", parameterName.c_str());
#endif
}
m_parameters[parameterName] = value;
}
GameRuleDefinition *GameRule::getGameRuleDefinition()
{
return m_definition;
}
void GameRule::onUseTile(int tileId, int x, int y, int z) { m_definition->onUseTile(this,tileId,x,y,z); }
void GameRule::onCollectItem(shared_ptr<ItemInstance> item) { m_definition->onCollectItem(this,item); }
void GameRule::write(DataOutputStream *dos)
{
// Find required parameters.
dos->writeInt(m_parameters.size());
for (AUTO_VAR(it, m_parameters.begin()); it != m_parameters.end(); it++)
{
wstring pName = (*it).first;
ValueType vType = (*it).second;
dos->writeUTF( (*it).first );
dos->writeBoolean( vType.isPointer );
if (vType.isPointer)
vType.gr->write(dos);
else
dos->writeLong( vType.i64 );
}
}
void GameRule::read(DataInputStream *dis)
{
int savedParams = dis->readInt();
for (int i = 0; i < savedParams; i++)
{
wstring pNames = dis->readUTF();
ValueType vType = getParameter(pNames);
if (dis->readBoolean())
{
vType.gr->read(dis);
}
else
{
vType.isPointer = false;
vType.i64 = dis->readLong();
setParameter(pNames, vType);
}
}
}

View File

@@ -0,0 +1,62 @@
#pragma once
using namespace std;
#include <unordered_map>
class CompoundTag;
class GameRuleDefinition;
class Connection;
// A game rule maintains the state for one particular definition
class GameRule
{
public:
typedef struct _ValueType
{
union{
__int64 i64;
int i;
char c;
bool b;
float f;
double d;
GameRule *gr;
};
bool isPointer;
_ValueType()
{
i64 = 0;
isPointer = false;
}
} ValueType;
private:
GameRuleDefinition *m_definition;
Connection *m_connection;
public:
typedef unordered_map<wstring,ValueType> stringValueMapType;
stringValueMapType m_parameters; // These are the members of this rule that maintain it's state
public:
GameRule(GameRuleDefinition *definition, Connection *connection = NULL);
virtual ~GameRule();
Connection *getConnection() { return m_connection; }
ValueType getParameter(const wstring &parameterName);
void setParameter(const wstring &parameterName,ValueType value);
GameRuleDefinition *getGameRuleDefinition();
// All the hooks go here
void onUseTile(int tileId, int x, int y, int z);
void onCollectItem(shared_ptr<ItemInstance> item);
// 4J-JEV: For saving.
//CompoundTag *toTags(unordered_map<GameRuleDefinition *, int> *map);
//static GameRule *fromTags(Connection *c, CompoundTag *cTag, vector<GameRuleDefinition *> *grds);
void write(DataOutputStream *dos);
void read(DataInputStream *dos);
};

View File

@@ -0,0 +1,151 @@
#include "stdafx.h"
#include "..\..\WstringLookup.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "ConsoleGameRules.h"
GameRuleDefinition::GameRuleDefinition()
{
m_descriptionId = L"";
m_promptId = L"";
m_4JDataValue = 0;
}
void GameRuleDefinition::write(DataOutputStream *dos)
{
// Write EGameRuleType.
ConsoleGameRules::EGameRuleType eType = getActionType();
assert( eType != ConsoleGameRules::eGameRuleType_Invalid );
ConsoleGameRules::write(dos, eType); // stringID
writeAttributes(dos, 0);
// 4J-JEV: Get children.
vector<GameRuleDefinition *> *children = new vector<GameRuleDefinition *>();
getChildren( children );
// Write children.
dos->writeInt( children->size() );
for (AUTO_VAR(it, children->begin()); it != children->end(); it++)
(*it)->write(dos);
}
void GameRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes)
{
dos->writeInt(numAttributes + 3);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_descriptionName);
dos->writeUTF(m_descriptionId);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_promptName);
dos->writeUTF(m_promptId);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_dataTag);
dos->writeUTF(_toString(m_4JDataValue));
}
void GameRuleDefinition::getChildren(vector<GameRuleDefinition *> *children) {}
GameRuleDefinition *GameRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
#ifndef _CONTENT_PACKAGE
wprintf(L"GameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType );
#endif
return NULL;
}
void GameRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"descriptionName") == 0)
{
m_descriptionId = attributeValue;
#ifndef _CONTENT_PACKAGE
wprintf(L"GameRuleDefinition: Adding parameter descriptionId=%ls\n",m_descriptionId.c_str());
#endif
}
else if(attributeName.compare(L"promptName") == 0)
{
m_promptId = attributeValue;
#ifndef _CONTENT_PACKAGE
wprintf(L"GameRuleDefinition: Adding parameter m_promptId=%ls\n",m_promptId.c_str());
#endif
}
else if(attributeName.compare(L"dataTag") == 0)
{
m_4JDataValue = _fromString<int>(attributeValue);
app.DebugPrintf("GameRuleDefinition: Adding parameter m_4JDataValue=%d\n",m_4JDataValue);
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"GameRuleDefinition: Attempted to add invalid attribute: %ls\n", attributeName.c_str());
#endif
}
}
void GameRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule)
{
GameRule::ValueType value;
value.b = false;
rule->setParameter(L"bComplete",value);
}
bool GameRuleDefinition::getComplete(GameRule *rule)
{
GameRule::ValueType value;
value = rule->getParameter(L"bComplete");
return value.b;
}
void GameRuleDefinition::setComplete(GameRule *rule, bool val)
{
GameRule::ValueType value;
value = rule->getParameter(L"bComplete");
value.b = val;
rule->setParameter(L"bComplete",value);
}
vector<GameRuleDefinition *> *GameRuleDefinition::enumerate()
{
// Get Vector.
vector<GameRuleDefinition *> *gRules;
gRules = new vector<GameRuleDefinition *>();
gRules->push_back(this);
getChildren(gRules);
return gRules;
}
unordered_map<GameRuleDefinition *, int> *GameRuleDefinition::enumerateMap()
{
unordered_map<GameRuleDefinition *, int> *out
= new unordered_map<GameRuleDefinition *, int>();
int i = 0;
vector<GameRuleDefinition *> *gRules = enumerate();
for (AUTO_VAR(it, gRules->begin()); it != gRules->end(); it++)
out->insert( pair<GameRuleDefinition *, int>( *it, i++ ) );
return out;
}
GameRulesInstance *GameRuleDefinition::generateNewGameRulesInstance(GameRulesInstance::EGameRulesInstanceType type, LevelRuleset *rules, Connection *connection)
{
GameRulesInstance *manager = new GameRulesInstance(rules, connection);
rules->populateGameRule(type, manager);
return manager;
}
wstring GameRuleDefinition::generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data, int dataLength)
{
wstring formatted = description;
switch(defType)
{
case ConsoleGameRules::eGameRuleType_CompleteAllRule:
formatted = CompleteAllRuleDefinition::generateDescriptionString(description,data,dataLength);
break;
default:
break;
};
return formatted;
}

View File

@@ -0,0 +1,66 @@
#pragma once
using namespace std;
#include <unordered_map>
#include <string>
#include "..\..\..\Minecraft.World\ItemInstance.h"
#include "ConsoleGameRulesConstants.h"
#include "GameRulesInstance.h"
class GameRule;
class LevelRuleset;
class Player;
class WstringLookup;
class GameRuleDefinition
{
private:
// Owner type defines who this rule applies to
GameRulesInstance::EGameRulesInstanceType m_ownerType;
protected:
// These attributes should map to those in the XSD GameRuleType
wstring m_descriptionId;
wstring m_promptId;
int m_4JDataValue;
public:
GameRuleDefinition();
virtual ConsoleGameRules::EGameRuleType getActionType() = 0;
void setOwnerType(GameRulesInstance::EGameRulesInstanceType ownerType) { m_ownerType = ownerType;}
virtual void write(DataOutputStream *);
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void getChildren(vector<GameRuleDefinition *> *);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
virtual void populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule);
bool getComplete(GameRule *rule);
void setComplete(GameRule *rule, bool val);
virtual int getGoal() { return 0; }
virtual int getProgress(GameRule *rule) { return 0; }
virtual int getIcon() { return -1; }
virtual int getAuxValue() { return 0; }
// Here we should have functions for all the hooks, with a GameRule* as the first parameter
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z) { return false; }
virtual bool onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item) { return false; }
virtual void postProcessPlayer(shared_ptr<Player> player) { }
vector<GameRuleDefinition *> *enumerate();
unordered_map<GameRuleDefinition *, int> *enumerateMap();
// Static functions
static GameRulesInstance *generateNewGameRulesInstance(GameRulesInstance::EGameRulesInstanceType type, LevelRuleset *rules, Connection *connection);
static wstring generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data = NULL, int dataLength = 0);
};

View File

@@ -0,0 +1,767 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\compression.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\File.h"
#include "..\..\..\Minecraft.World\compression.h"
#include "..\DLC\DLCPack.h"
#include "..\DLC\DLCLocalisationFile.h"
#include "..\DLC\DLCGameRulesFile.h"
#include "..\DLC\DLCGameRules.h"
#include "..\DLC\DLCGameRulesHeader.h"
#include "..\..\StringTable.h"
#include "ConsoleGameRules.h"
#include "GameRuleManager.h"
WCHAR *GameRuleManager::wchTagNameA[] =
{
L"", // eGameRuleType_Root
L"MapOptions", // eGameRuleType_LevelGenerationOptions
L"ApplySchematic", // eGameRuleType_ApplySchematic
L"GenerateStructure", // eGameRuleType_GenerateStructure
L"GenerateBox", // eGameRuleType_GenerateBox
L"PlaceBlock", // eGameRuleType_PlaceBlock
L"PlaceContainer", // eGameRuleType_PlaceContainer
L"PlaceSpawner", // eGameRuleType_PlaceSpawner
L"BiomeOverride", // eGameRuleType_BiomeOverride
L"StartFeature", // eGameRuleType_StartFeature
L"AddItem", // eGameRuleType_AddItem
L"AddEnchantment", // eGameRuleType_AddEnchantment
L"LevelRules", // eGameRuleType_LevelRules
L"NamedArea", // eGameRuleType_NamedArea
L"UseTile", // eGameRuleType_UseTileRule
L"CollectItem", // eGameRuleType_CollectItemRule
L"CompleteAll", // eGameRuleType_CompleteAllRule
L"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
};
WCHAR *GameRuleManager::wchAttrNameA[] =
{
L"descriptionName", // eGameRuleAttr_descriptionName
L"promptName", // eGameRuleAttr_promptName
L"dataTag", // eGameRuleAttr_dataTag
L"enchantmentId", // eGameRuleAttr_enchantmentId
L"enchantmentLevel", // eGameRuleAttr_enchantmentLevel
L"itemId", // eGameRuleAttr_itemId
L"quantity", // eGameRuleAttr_quantity
L"auxValue", // eGameRuleAttr_auxValue
L"slot", // eGameRuleAttr_slot
L"name", // eGameRuleAttr_name
L"food", // eGameRuleAttr_food
L"health", // eGameRuleAttr_health
L"tileId", // eGameRuleAttr_tileId
L"useCoords", // eGameRuleAttr_useCoords
L"seed", // eGameRuleAttr_seed
L"flatworld", // eGameRuleAttr_flatworld
L"filename", // eGameRuleAttr_filename
L"rot", // eGameRuleAttr_rot
L"data", // eGameRuleAttr_data
L"block", // eGameRuleAttr_block
L"entity", // eGameRuleAttr_entity
L"facing", // eGameRuleAttr_facing
L"edgeTile", // eGameRuleAttr_edgeTile
L"fillTile", // eGameRuleAttr_fillTile
L"skipAir", // eGameRuleAttr_skipAir
L"x", // eGameRuleAttr_x
L"x0", // eGameRuleAttr_x0
L"x1", // eGameRuleAttr_x1
L"y", // eGameRuleAttr_y
L"y0", // eGameRuleAttr_y0
L"y1", // eGameRuleAttr_y1
L"z", // eGameRuleAttr_z
L"z0", // eGameRuleAttr_z0
L"z1", // eGameRuleAttr_z1
L"chunkX", // eGameRuleAttr_chunkX
L"chunkZ", // eGameRuleAttr_chunkZ
L"yRot", // eGameRuleAttr_yRot
L"spawnX", // eGameRuleAttr_spawnX
L"spawnY", // eGameRuleAttr_spawnY
L"spawnZ", // eGameRuleAttr_spawnZ
L"orientation",
L"dimension",
L"topTileId", // eGameRuleAttr_topTileId
L"biomeId", // eGameRuleAttr_biomeId
L"feature", // eGameRuleAttr_feature
};
GameRuleManager::GameRuleManager()
{
m_currentGameRuleDefinitions = NULL;
m_currentLevelGenerationOptions = NULL;
}
void GameRuleManager::loadGameRules(DLCPack *pack)
{
StringTable *strings = NULL;
if(pack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData,L"languages.loc"))
{
DLCLocalisationFile *localisationFile = (DLCLocalisationFile *)pack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc");
strings = localisationFile->getStringTable();
}
int gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader);
for(int i = 0; i < gameRulesCount; ++i)
{
DLCGameRulesHeader *dlcHeader = (DLCGameRulesHeader *)pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i);
DWORD dSize;
byte *dData = dlcHeader->getData(dSize);
LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions();
// = loadGameRules(dData, dSize); //, strings);
createdLevelGenerationOptions->setGrSource( dlcHeader );
readRuleFile(createdLevelGenerationOptions, dData, dSize, strings);
createdLevelGenerationOptions->setSrc( LevelGenerationOptions::eSrc_fromDLC );
//createdLevelGenerationOptions->setSrc( LevelGenerationOptions::eSrc_fromDLC );
dlcHeader->lgo = createdLevelGenerationOptions;
}
gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules);
for (int i = 0; i < gameRulesCount; ++i)
{
DLCGameRulesFile *dlcFile = (DLCGameRulesFile *)pack->getFile(DLCManager::e_DLCType_GameRules, i);
DWORD dSize;
byte *dData = dlcFile->getData(dSize);
LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions();
// = loadGameRules(dData, dSize); //, strings);
createdLevelGenerationOptions->setGrSource( new JustGrSource() );
readRuleFile(createdLevelGenerationOptions, dData, dSize, strings);
createdLevelGenerationOptions->setSrc( LevelGenerationOptions::eSrc_tutorial );
//createdLevelGenerationOptions->set_DLCGameRulesFile( dlcFile );
createdLevelGenerationOptions->setLoadedData();
}
}
LevelGenerationOptions *GameRuleManager::loadGameRules(byte *dIn, UINT dSize)
{
LevelGenerationOptions *lgo = new LevelGenerationOptions();
lgo->setGrSource( new JustGrSource() );
lgo->setSrc( LevelGenerationOptions::eSrc_fromSave );
loadGameRules(lgo, dIn, dSize);
lgo->setLoadedData();
return lgo;
}
// 4J-JEV: Reverse of saveGameRules.
void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT dSize)
{
app.DebugPrintf("GameRuleManager::LoadingGameRules:\n");
ByteArrayInputStream bais( byteArray(dIn,dSize) );
DataInputStream dis(&bais);
// Read file header.
//dis.readInt(); // File Size
short version = dis.readShort();
assert( 0x1 == version );
app.DebugPrintf("\tversion=%d.\n", version);
for (int i = 0; i < 8; i++) dis.readByte();
BYTE compression_type = dis.readByte();
app.DebugPrintf("\tcompressionType=%d.\n", compression_type);
UINT compr_len, decomp_len;
compr_len = dis.readInt();
decomp_len = dis.readInt();
app.DebugPrintf("\tcompr_len=%d.\n\tdecomp_len=%d.\n", compr_len, decomp_len);
// Decompress File Body
byteArray content(new BYTE[decomp_len], decomp_len),
compr_content(new BYTE[compr_len], compr_len);
dis.read(compr_content);
Compression::getCompression()->SetDecompressionType( (Compression::ECompressionTypes)compression_type );
Compression::getCompression()->DecompressLZXRLE( content.data, &content.length,
compr_content.data, compr_content.length);
Compression::getCompression()->SetDecompressionType( SAVE_FILE_PLATFORM_LOCAL );
dis.close();
bais.close();
delete [] compr_content.data;
ByteArrayInputStream bais2( content );
DataInputStream dis2( &bais2 );
// Read StringTable.
byteArray bStringTable;
bStringTable.length = dis2.readInt();
bStringTable.data = new BYTE[ bStringTable.length ];
dis2.read(bStringTable);
StringTable *strings = new StringTable(bStringTable.data, bStringTable.length);
// Read RuleFile.
byteArray bRuleFile;
bRuleFile.length = content.length - bStringTable.length;
bRuleFile.data = new BYTE[ bRuleFile.length ];
dis2.read(bRuleFile);
// 4J-JEV: I don't believe that the path-name is ever used.
//DLCGameRulesFile *dlcgr = new DLCGameRulesFile(L"__PLACEHOLDER__");
//dlcgr->addData(bRuleFile.data,bRuleFile.length);
if (readRuleFile(lgo, bRuleFile.data, bRuleFile.length, strings))
{
// Set current gen options and ruleset.
//createdLevelGenerationOptions->setFromSaveGame(true);
lgo->setSrc(LevelGenerationOptions::eSrc_fromSave);
setLevelGenerationOptions( lgo );
//m_currentGameRuleDefinitions = lgo->getRequiredGameRules();
}
else
{
delete lgo;
}
//delete [] content.data;
// Close and return.
dis2.close();
bais2.close();
return ;
}
// 4J-JEV: Reverse of loadGameRules.
void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize)
{
if (m_currentGameRuleDefinitions == NULL &&
m_currentLevelGenerationOptions == NULL)
{
app.DebugPrintf("GameRuleManager:: Nothing here to save.");
*dOut = NULL;
*dSize = 0;
return;
}
app.DebugPrintf("GameRuleManager::saveGameRules:\n");
// Initialise output stream.
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
// Write header.
// VERSION NUMBER
dos.writeShort( 0x1 ); // version_number
// Write 8 bytes of empty space in case we need them later.
// Mainly useful for the ones we save embedded in game saves.
for (UINT i = 0; i < 8; i++)
dos.writeByte(0x0);
dos.writeByte(APPROPRIATE_COMPRESSION_TYPE); // m_compressionType
// -- START COMPRESSED -- //
ByteArrayOutputStream compr_baos;
DataOutputStream compr_dos(&compr_baos);
if (m_currentGameRuleDefinitions == NULL)
{
compr_dos.writeInt( 0 ); // numStrings for StringTable
compr_dos.writeInt( version_number );
compr_dos.writeByte(Compression::eCompressionType_None); // compression type
for (int i=0; i<2; i++) compr_dos.writeByte(0x0); // Padding.
compr_dos.writeInt( 0 ); // StringLookup.length
compr_dos.writeInt( 0 ); // SchematicFiles.length
compr_dos.writeInt( 0 ); // XmlObjects.length
}
else
{
StringTable *st = m_currentGameRuleDefinitions->getStringTable();
if (st == NULL)
{
app.DebugPrintf("GameRuleManager::saveGameRules: StringTable == NULL!");
}
else
{
// Write string table.
byteArray stba;
m_currentGameRuleDefinitions->getStringTable()->getData(&stba.data, &stba.length);
compr_dos.writeInt( stba.length );
compr_dos.write( stba );
// Write game rule file to second
// buffer and generate string lookup.
writeRuleFile(&compr_dos);
}
}
// Compress compr_dos and write to dos.
byteArray compr_ba(new BYTE[ compr_baos.buf.length ], compr_baos.buf.length);
Compression::getCompression()->CompressLZXRLE( compr_ba.data, &compr_ba.length,
compr_baos.buf.data, compr_baos.buf.length );
app.DebugPrintf("\tcompr_ba.length=%d.\n\tcompr_baos.buf.length=%d.\n",
compr_ba.length, compr_baos.buf.length );
dos.writeInt( compr_ba.length ); // Write length
dos.writeInt( compr_baos.buf.length );
dos.write(compr_ba);
delete [] compr_ba.data;
compr_dos.close();
compr_baos.close();
// -- END COMPRESSED -- //
// return
*dSize = baos.buf.length;
*dOut = baos.buf.data;
baos.buf.data = NULL;
dos.close(); baos.close();
}
// 4J-JEV: Reverse of readRuleFile.
void GameRuleManager::writeRuleFile(DataOutputStream *dos)
{
// Write Header
dos->writeShort(version_number); // Version number.
dos->writeByte(Compression::eCompressionType_None); // compression type
for (int i=0; i<8; i++) dos->writeBoolean(false); // Padding.
// Write string lookup.
int numStrings = ConsoleGameRules::eGameRuleType_Count + ConsoleGameRules::eGameRuleAttr_Count;
dos->writeInt(numStrings);
for (int i = 0; i < ConsoleGameRules::eGameRuleType_Count; i++) dos->writeUTF( wchTagNameA[i] );
for (int i = 0; i < ConsoleGameRules::eGameRuleAttr_Count; i++) dos->writeUTF( wchAttrNameA[i] );
// Write schematic files.
unordered_map<wstring, ConsoleSchematicFile *> *files;
files = getLevelGenerationOptions()->getUnfinishedSchematicFiles();
dos->writeInt( files->size() );
for (AUTO_VAR(it, files->begin()); it != files->end(); it++)
{
wstring filename = it->first;
ConsoleSchematicFile *file = it->second;
ByteArrayOutputStream fileBaos;
DataOutputStream fileDos(&fileBaos);
file->save(&fileDos);
dos->writeUTF(filename);
//dos->writeInt(file->m_data.length);
dos->writeInt(fileBaos.buf.length);
dos->write((byteArray)fileBaos.buf);
fileDos.close(); fileBaos.close();
}
// Write xml objects.
dos->writeInt( 2 ); // numChildren
m_currentLevelGenerationOptions->write(dos);
m_currentGameRuleDefinitions->write(dos);
}
bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT dSize, StringTable *strings) //(DLCGameRulesFile *dlcFile, StringTable *strings)
{
bool levelGenAdded = false;
bool gameRulesAdded = false;
LevelGenerationOptions *levelGenerator = lgo;//new LevelGenerationOptions();
LevelRuleset *gameRules = new LevelRuleset();
//DWORD dwLen = 0;
//PBYTE pbData = dlcFile->getData(dwLen);
//byteArray data(pbData,dwLen);
byteArray data(dIn, dSize);
ByteArrayInputStream bais(data);
DataInputStream dis(&bais);
// Read File.
// version_number
__int64 version = dis.readShort();
unsigned char compressionType = 0;
if(version == 0)
{
for (int i = 0; i < 14; i++) dis.readByte(); // Read padding.
}
else
{
compressionType = dis.readByte();
// Read the spare bytes we inserted for future use
for(int i = 0; i < 8; ++i) dis.readBoolean();
}
ByteArrayInputStream *contentBais = NULL;
DataInputStream *contentDis = NULL;
if(compressionType == Compression::eCompressionType_None)
{
// No compression
// No need to read buffer size, as we can read the stream as it is;
app.DebugPrintf("De-compressing game rules with: None\n");
contentDis = &dis;
}
else
{
unsigned int uncompressedSize = dis.readInt();
unsigned int compressedSize = dis.readInt();
byteArray compressedBuffer(compressedSize);
dis.read(compressedBuffer);
byteArray decompressedBuffer = byteArray(uncompressedSize);
switch(compressionType)
{
case Compression::eCompressionType_None:
memcpy(decompressedBuffer.data, compressedBuffer.data, uncompressedSize);
break;
case Compression::eCompressionType_RLE:
app.DebugPrintf("De-compressing game rules with: RLE\n");
Compression::getCompression()->Decompress( decompressedBuffer.data, &decompressedBuffer.length, compressedBuffer.data, compressedSize);
break;
default:
app.DebugPrintf("De-compressing game rules.");
#ifndef _CONTENT_PACKAGE
assert( compressionType == APPROPRIATE_COMPRESSION_TYPE );
#endif
// 4J-JEV: DecompressLZXRLE uses the correct platform specific compression type. (need to assert that the data is compressed with it though).
Compression::getCompression()->DecompressLZXRLE(decompressedBuffer.data, &decompressedBuffer.length, compressedBuffer.data, compressedSize);
break;
/* 4J-JEV:
Each platform has only 1 method of compression, 'compression.h' file deals with it.
case Compression::eCompressionType_LZXRLE:
app.DebugPrintf("De-compressing game rules with: LZX+RLE\n");
Compression::getCompression()->DecompressLZXRLE( decompressedBuffer.data, &uncompressedSize, compressedBuffer.data, compressedSize);
break;
default:
app.DebugPrintf("Invalid compression type %d found\n", compressionType);
__debugbreak();
delete [] compressedBuffer.data; delete [] decompressedBuffer.data;
dis.close(); bais.reset();
if(!gameRulesAdded) delete gameRules;
return false;
*/
};
delete [] compressedBuffer.data;
contentBais = new ByteArrayInputStream(decompressedBuffer);
contentDis = new DataInputStream(contentBais);
}
// string lookup.
UINT numStrings = contentDis->readInt();
vector<wstring> tagsAndAtts;
for (UINT i = 0; i < numStrings; i++)
tagsAndAtts.push_back( contentDis->readUTF() );
unordered_map<int, ConsoleGameRules::EGameRuleType> tagIdMap;
for(int type = (int)ConsoleGameRules::eGameRuleType_Root; type < (int)ConsoleGameRules::eGameRuleType_Count; ++type)
{
for(UINT i = 0; i < numStrings; ++i)
{
if(tagsAndAtts[i].compare(wchTagNameA[type]) == 0)
{
tagIdMap.insert( unordered_map<int, ConsoleGameRules::EGameRuleType>::value_type(i, (ConsoleGameRules::EGameRuleType)type) );
break;
}
}
}
// 4J-JEV: TODO: As yet unused.
/*
unordered_map<int, ConsoleGameRules::EGameRuleAttr> attrIdMap;
for(int attr = (int)ConsoleGameRules::eGameRuleAttr_descriptionName; attr < (int)ConsoleGameRules::eGameRuleAttr_Count; ++attr)
{
for (UINT i = 0; i < numStrings; i++)
{
if (tagsAndAtts[i].compare(wchAttrNameA[attr]) == 0)
{
tagIdMap.insert( unordered_map<int, ConsoleGameRules::EGameRuleAttr>::value_type(i , (ConsoleGameRules::EGameRuleAttr)attr) );
break;
}
}
}*/
// subfile
UINT numFiles = contentDis->readInt();
for (UINT i = 0; i < numFiles; i++)
{
wstring sFilename = contentDis->readUTF();
int length = contentDis->readInt();
byteArray ba( length );
contentDis->read(ba);
levelGenerator->loadSchematicFile(sFilename, ba.data, ba.length);
}
LEVEL_GEN_ID lgoID = LEVEL_GEN_ID_NULL;
// xml objects
UINT numObjects = contentDis->readInt();
for(UINT i = 0; i < numObjects; ++i)
{
int tagId = contentDis->readInt();
ConsoleGameRules::EGameRuleType tagVal = ConsoleGameRules::eGameRuleType_Invalid;
AUTO_VAR(it,tagIdMap.find(tagId));
if(it != tagIdMap.end()) tagVal = it->second;
GameRuleDefinition *rule = NULL;
if(tagVal == ConsoleGameRules::eGameRuleType_LevelGenerationOptions)
{
rule = levelGenerator;
levelGenAdded = true;
//m_levelGenerators.addLevelGenerator(L"",levelGenerator);
lgoID = addLevelGenerationOptions(levelGenerator);
levelGenerator->loadStringTable(strings);
}
else if(tagVal == ConsoleGameRules::eGameRuleType_LevelRules)
{
rule = gameRules;
gameRulesAdded = true;
m_levelRules.addLevelRule(L"",gameRules);
levelGenerator->setRequiredGameRules(gameRules);
gameRules->loadStringTable(strings);
}
readAttributes(contentDis, &tagsAndAtts, rule);
readChildren(contentDis, &tagsAndAtts, &tagIdMap, rule);
}
if(compressionType != 0)
{
// Not default
contentDis->close();
if(contentBais != NULL) delete contentBais;
delete contentDis;
}
dis.close();
bais.reset();
//if(!levelGenAdded) { delete levelGenerator; levelGenerator = NULL; }
if(!gameRulesAdded) delete gameRules;
return true;
//return levelGenerator;
}
LevelGenerationOptions *GameRuleManager::readHeader(DLCGameRulesHeader *grh)
{
LevelGenerationOptions *out =
new LevelGenerationOptions();
out->setSrc(LevelGenerationOptions::eSrc_fromDLC);
out->setGrSource(grh);
addLevelGenerationOptions(out);
return out;
}
void GameRuleManager::readAttributes(DataInputStream *dis, vector<wstring> *tagsAndAtts, GameRuleDefinition *rule)
{
int numAttrs = dis->readInt();
for (UINT att = 0; att < numAttrs; ++att)
{
int attID = dis->readInt();
wstring value = dis->readUTF();
if(rule != NULL) rule->addAttribute(tagsAndAtts->at(attID),value);
}
}
void GameRuleManager::readChildren(DataInputStream *dis, vector<wstring> *tagsAndAtts, unordered_map<int, ConsoleGameRules::EGameRuleType> *tagIdMap, GameRuleDefinition *rule)
{
int numChildren = dis->readInt();
for(UINT child = 0; child < numChildren; ++child)
{
int tagId = dis->readInt();
ConsoleGameRules::EGameRuleType tagVal = ConsoleGameRules::eGameRuleType_Invalid;
AUTO_VAR(it,tagIdMap->find(tagId));
if(it != tagIdMap->end()) tagVal = it->second;
GameRuleDefinition *childRule = NULL;
if(rule != NULL) childRule = rule->addChild(tagVal);
readAttributes(dis,tagsAndAtts,childRule);
readChildren(dis,tagsAndAtts,tagIdMap,childRule);
}
}
void GameRuleManager::processSchematics(LevelChunk *levelChunk)
{
if(getLevelGenerationOptions() != NULL)
{
LevelGenerationOptions *levelGenOptions = getLevelGenerationOptions();
levelGenOptions->processSchematics(levelChunk);
}
}
void GameRuleManager::processSchematicsLighting(LevelChunk *levelChunk)
{
if(getLevelGenerationOptions() != NULL)
{
LevelGenerationOptions *levelGenOptions = getLevelGenerationOptions();
levelGenOptions->processSchematicsLighting(levelChunk);
}
}
void GameRuleManager::loadDefaultGameRules()
{
#ifdef _XBOX
#ifdef _TU_BUILD
wstring fileRoot = L"UPDATE:\\res\\GameRules\\Tutorial.pck";
#else
wstring fileRoot = L"GAME:\\res\\TitleUpdate\\GameRules\\Tutorial.pck";
#endif
File packedTutorialFile(fileRoot);
if(loadGameRulesPack(&packedTutorialFile))
{
m_levelGenerators.getLevelGenerators()->at(0)->setWorldName(app.GetString(IDS_PLAY_TUTORIAL));
//m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(L"Tutorial");
m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(app.GetString(IDS_TUTORIALSAVENAME));
}
#ifndef _CONTENT_PACKAGE
// 4J Stu - Remove these just now
//File testRulesPath(L"GAME:\\GameRules");
//vector<File *> *packFiles = testRulesPath.listFiles();
//for(AUTO_VAR(it,packFiles->begin()); it != packFiles->end(); ++it)
//{
// loadGameRulesPack(*it);
//}
//delete packFiles;
#endif
#else // _XBOX
wstring fpTutorial = L"Tutorial.pck";
if(app.getArchiveFileSize(fpTutorial) >= 0)
{
DLCPack *pack = new DLCPack(L"",0xffffffff);
DWORD dwFilesProcessed = 0;
if ( app.m_dlcManager.readDLCDataFile(dwFilesProcessed,fpTutorial,pack,true) )
{
app.m_dlcManager.addPack(pack);
m_levelGenerators.getLevelGenerators()->at(0)->setWorldName(app.GetString(IDS_PLAY_TUTORIAL));
m_levelGenerators.getLevelGenerators()->at(0)->setDefaultSaveName(app.GetString(IDS_TUTORIALSAVENAME));
}
else delete pack;
}
/*StringTable *strings = new StringTable(baStrings.data, baStrings.length);
LevelGenerationOptions *lgo = new LevelGenerationOptions();
lgo->setGrSource( new JustGrSource() );
lgo->setSrc( LevelGenerationOptions::eSrc_tutorial );
readRuleFile(lgo, tutorial.data, tutorial.length, strings);
lgo->setLoadedData();*/
#endif
}
bool GameRuleManager::loadGameRulesPack(File *path)
{
bool success = false;
#ifdef _XBOX
if(path->exists())
{
DLCPack *pack = new DLCPack(L"",0xffffffff);
DWORD dwFilesProcessed = 0;
if( app.m_dlcManager.readDLCDataFile(dwFilesProcessed, path->getPath(),pack))
{
app.m_dlcManager.addPack(pack);
success = true;
}
else
{
delete pack;
}
}
#endif
return success;
}
void GameRuleManager::setLevelGenerationOptions(LevelGenerationOptions *levelGen)
{
m_currentGameRuleDefinitions = NULL;
m_currentLevelGenerationOptions = levelGen;
if(m_currentLevelGenerationOptions != NULL && m_currentLevelGenerationOptions->requiresGameRules() )
{
m_currentGameRuleDefinitions = m_currentLevelGenerationOptions->getRequiredGameRules();
}
if(m_currentLevelGenerationOptions != NULL)
m_currentLevelGenerationOptions->reset_start();
}
LPCWSTR GameRuleManager::GetGameRulesString(const wstring &key)
{
if(m_currentGameRuleDefinitions != NULL && !key.empty() )
{
return m_currentGameRuleDefinitions->getString(key);
}
else
{
return L"";
}
}
LEVEL_GEN_ID GameRuleManager::addLevelGenerationOptions(LevelGenerationOptions *lgo)
{
vector<LevelGenerationOptions *> *lgs = m_levelGenerators.getLevelGenerators();
for (int i = 0; i<lgs->size(); i++)
if (lgs->at(i) == lgo)
return i;
lgs->push_back(lgo);
return lgs->size() - 1;
}
void GameRuleManager::unloadCurrentGameRules()
{
if (m_currentLevelGenerationOptions != NULL)
{
if (m_currentGameRuleDefinitions != NULL
&& m_currentLevelGenerationOptions->isFromSave())
m_levelRules.removeLevelRule( m_currentGameRuleDefinitions );
if (m_currentLevelGenerationOptions->isFromSave())
{
m_levelGenerators.removeLevelGenerator( m_currentLevelGenerationOptions );
delete m_currentLevelGenerationOptions;
}
else if (m_currentLevelGenerationOptions->isFromDLC())
{
m_currentLevelGenerationOptions->reset_finish();
}
}
m_currentGameRuleDefinitions = NULL;
m_currentLevelGenerationOptions = NULL;
}

View File

@@ -0,0 +1,80 @@
#pragma once
using namespace std;
#include "LevelGenerators.h"
#include "LevelRules.h"
class LevelGenerationOptions;
class RootGameRulesDefinition;
class LevelChunk;
class DLCPack;
class DLCGameRulesFile;
class DLCGameRulesHeader;
class StringTable;
class GameRuleDefinition;
class DataInputStream;
class DataOutputStream;
class WstringLookup;
#define GAME_RULE_SAVENAME L"requiredGameRules.grf"
// 4J-JEV:
#define LEVEL_GEN_ID int
#define LEVEL_GEN_ID_NULL 0
class GameRuleManager
{
public:
static WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
static WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
static const short version_number = 2;
private:
LevelGenerationOptions *m_currentLevelGenerationOptions;
LevelRuleset *m_currentGameRuleDefinitions;
LevelGenerators m_levelGenerators;
LevelRules m_levelRules;
public:
GameRuleManager();
void loadGameRules(DLCPack *);
LevelGenerationOptions *loadGameRules(byte *dIn, UINT dSize);
void loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT dSize);
void saveGameRules(byte **dOut, UINT *dSize);
private:
LevelGenerationOptions *readHeader(DLCGameRulesHeader *grh);
void writeRuleFile(DataOutputStream *dos);
public:
bool readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT dSize, StringTable *strings); //(DLCGameRulesFile *dlcFile, StringTable *strings);
private:
void readAttributes(DataInputStream *dis, vector<wstring> *tagsAndAtts, GameRuleDefinition *rule);
void readChildren(DataInputStream *dis, vector<wstring> *tagsAndAtts, unordered_map<int, ConsoleGameRules::EGameRuleType> *tagIdMap, GameRuleDefinition *rule);
public:
void processSchematics(LevelChunk *levelChunk);
void processSchematicsLighting(LevelChunk *levelChunk);
void loadDefaultGameRules();
private:
bool loadGameRulesPack(File *path);
LEVEL_GEN_ID addLevelGenerationOptions(LevelGenerationOptions *);
public:
vector<LevelGenerationOptions *> *getLevelGenerators() { return m_levelGenerators.getLevelGenerators(); }
void setLevelGenerationOptions(LevelGenerationOptions *levelGen);
LevelRuleset *getGameRuleDefinitions() { return m_currentGameRuleDefinitions; }
LevelGenerationOptions *getLevelGenerationOptions() { return m_currentLevelGenerationOptions; }
LPCWSTR GetGameRulesString(const wstring &key);
// 4J-JEV:
// Properly cleans-up and unloads the current set of gameRules.
void unloadCurrentGameRules();
};

View File

@@ -0,0 +1,24 @@
#pragma once
using namespace std;
#include <vector>
#include "GameRule.h"
class GameRuleDefinition;
// The game rule manager belongs to a player/server or other object, and maintains their current state for each of
// the rules that apply to them
class GameRulesInstance : public GameRule
{
public:
// These types are used by the GameRuleDefinition to know which rules to add to this GameRulesInstance
enum EGameRulesInstanceType
{
eGameRulesInstanceType_ServerPlayer,
eGameRulesInstanceType_Server,
eGameRulesInstanceType_Count
};
public:
GameRulesInstance(GameRuleDefinition *definition, Connection *connection) : GameRule(definition,connection) {}
// Functions for all the hooks should go here
};

View File

@@ -0,0 +1,514 @@
#include "stdafx.h"
#include <unordered_set>
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\Pos.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.phys.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.chunk.h"
#include "..\..\StringTable.h"
#include "LevelGenerationOptions.h"
#include "ConsoleGameRules.h"
JustGrSource::JustGrSource()
{
m_displayName = L"Default_DisplayName";
m_worldName= L"Default_WorldName";
m_defaultSaveName = L"Default_DefaultSaveName";
m_bRequiresTexturePack = false;
m_requiredTexturePackId = 0;
m_grfPath = L"__NO_GRF_PATH__";
m_bRequiresBaseSave = false;
}
bool JustGrSource::requiresTexturePack() {return m_bRequiresTexturePack;}
UINT JustGrSource::getRequiredTexturePackId() {return m_requiredTexturePackId;}
wstring JustGrSource::getDefaultSaveName() {return m_defaultSaveName;}
LPCWSTR JustGrSource::getWorldName() {return m_worldName.c_str();}
LPCWSTR JustGrSource::getDisplayName() {return m_displayName.c_str();}
wstring JustGrSource::getGrfPath() {return m_grfPath;}
bool JustGrSource::requiresBaseSave() { return m_bRequiresBaseSave; };
wstring JustGrSource::getBaseSavePath() { return m_baseSavePath; };
void JustGrSource::setRequiresTexturePack(bool x) {m_bRequiresTexturePack = x;}
void JustGrSource::setRequiredTexturePackId(UINT x) {m_requiredTexturePackId = x;}
void JustGrSource::setDefaultSaveName(const wstring &x) {m_defaultSaveName = x;}
void JustGrSource::setWorldName(const wstring &x) {m_worldName = x;}
void JustGrSource::setDisplayName(const wstring &x) {m_displayName = x;}
void JustGrSource::setGrfPath(const wstring &x) {m_grfPath = x;}
void JustGrSource::setBaseSavePath(const wstring &x) { m_baseSavePath = x; m_bRequiresBaseSave = true; }
bool JustGrSource::ready() { return true; }
LevelGenerationOptions::LevelGenerationOptions()
{
m_spawnPos = NULL;
m_stringTable = NULL;
m_hasLoadedData = false;
m_seed = 0;
m_useFlatWorld = false;
m_bHaveMinY = false;
m_minY = INT_MAX;
m_bRequiresGameRules = false;
m_pbBaseSaveData = NULL;
m_dwBaseSaveSize = 0;
}
LevelGenerationOptions::~LevelGenerationOptions()
{
clearSchematics();
if(m_spawnPos != NULL) delete m_spawnPos;
for(AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end(); ++it)
{
delete *it;
}
for(AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); ++it)
{
delete *it;
}
for(AUTO_VAR(it, m_biomeOverrides.begin()); it != m_biomeOverrides.end(); ++it)
{
delete *it;
}
for(AUTO_VAR(it, m_features.begin()); it != m_features.end(); ++it)
{
delete *it;
}
if (m_stringTable)
if (!isTutorial())
delete m_stringTable;
if (isFromSave()) delete m_pSrc;
}
ConsoleGameRules::EGameRuleType LevelGenerationOptions::getActionType() { return ConsoleGameRules::eGameRuleType_LevelGenerationOptions; }
void LevelGenerationOptions::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
GameRuleDefinition::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnX);
dos->writeUTF(_toString(m_spawnPos->x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnY);
dos->writeUTF(_toString(m_spawnPos->y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnZ);
dos->writeUTF(_toString(m_spawnPos->z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_seed);
dos->writeUTF(_toString(m_seed));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_flatworld);
dos->writeUTF(_toString(m_useFlatWorld));
}
void LevelGenerationOptions::getChildren(vector<GameRuleDefinition *> *children)
{
GameRuleDefinition::getChildren(children);
vector<ApplySchematicRuleDefinition *> used_schematics;
for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end(); it++)
if ( !(*it)->isComplete() )
used_schematics.push_back( *it );
for(AUTO_VAR(it, m_structureRules.begin()); it!=m_structureRules.end(); it++)
children->push_back( *it );
for(AUTO_VAR(it, used_schematics.begin()); it!=used_schematics.end(); it++)
children->push_back( *it );
for(AUTO_VAR(it, m_biomeOverrides.begin()); it != m_biomeOverrides.end(); ++it)
children->push_back( *it );
for(AUTO_VAR(it, m_features.begin()); it != m_features.end(); ++it)
children->push_back( *it );
}
GameRuleDefinition *LevelGenerationOptions::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_ApplySchematic)
{
rule = new ApplySchematicRuleDefinition(this);
m_schematicRules.push_back((ApplySchematicRuleDefinition *)rule);
}
else if(ruleType == ConsoleGameRules::eGameRuleType_GenerateStructure)
{
rule = new ConsoleGenerateStructure();
m_structureRules.push_back((ConsoleGenerateStructure *)rule);
}
else if(ruleType == ConsoleGameRules::eGameRuleType_BiomeOverride)
{
rule = new BiomeOverride();
m_biomeOverrides.push_back((BiomeOverride *)rule);
}
else if(ruleType == ConsoleGameRules::eGameRuleType_StartFeature)
{
rule = new StartFeature();
m_features.push_back((StartFeature *)rule);
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"LevelGenerationOptions: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
return rule;
}
void LevelGenerationOptions::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"seed") == 0)
{
m_seed = _fromString<__int64>(attributeValue);
app.DebugPrintf("LevelGenerationOptions: Adding parameter m_seed=%I64d\n",m_seed);
}
else if(attributeName.compare(L"spawnX") == 0)
{
if(m_spawnPos == NULL) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->x = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnX=%d\n",value);
}
else if(attributeName.compare(L"spawnY") == 0)
{
if(m_spawnPos == NULL) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->y = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnY=%d\n",value);
}
else if(attributeName.compare(L"spawnZ") == 0)
{
if(m_spawnPos == NULL) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->z = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnZ=%d\n",value);
}
else if(attributeName.compare(L"flatworld") == 0)
{
if(attributeValue.compare(L"true") == 0) m_useFlatWorld = true;
app.DebugPrintf("LevelGenerationOptions: Adding parameter flatworld=%s\n",m_useFlatWorld?"TRUE":"FALSE");
}
else if(attributeName.compare(L"saveName") == 0)
{
wstring string(getString(attributeValue));
if(!string.empty()) setDefaultSaveName( string );
else setDefaultSaveName( attributeValue );
app.DebugPrintf("LevelGenerationOptions: Adding parameter saveName=%ls\n", getDefaultSaveName().c_str());
}
else if(attributeName.compare(L"worldName") == 0)
{
wstring string(getString(attributeValue));
if(!string.empty()) setWorldName( string );
else setWorldName( attributeValue );
app.DebugPrintf("LevelGenerationOptions: Adding parameter worldName=%ls\n", getWorldName());
}
else if(attributeName.compare(L"displayName") == 0)
{
wstring string(getString(attributeValue));
if(!string.empty()) setDisplayName( string );
else setDisplayName( attributeValue );
app.DebugPrintf("LevelGenerationOptions: Adding parameter displayName=%ls\n", getDisplayName());
}
else if(attributeName.compare(L"texturePackId") == 0)
{
setRequiredTexturePackId( _fromString<unsigned int>(attributeValue) );
setRequiresTexturePack( true );
app.DebugPrintf("LevelGenerationOptions: Adding parameter texturePackId=%0x\n", getRequiredTexturePackId());
}
else if(attributeName.compare(L"isTutorial") == 0)
{
if(attributeValue.compare(L"true") == 0) setSrc(eSrc_tutorial);
app.DebugPrintf("LevelGenerationOptions: Adding parameter isTutorial=%s\n",isTutorial()?"TRUE":"FALSE");
}
else if(attributeName.compare(L"baseSaveName") == 0)
{
setBaseSavePath( attributeValue );
app.DebugPrintf("LevelGenerationOptions: Adding parameter baseSaveName=%ls\n", getBaseSavePath().c_str());
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
void LevelGenerationOptions::processSchematics(LevelChunk *chunk)
{
PIXBeginNamedEvent(0,"Processing schematics for chunk (%d,%d)", chunk->x, chunk->z);
AABB *chunkBox = AABB::newTemp(chunk->x*16,0,chunk->z*16,chunk->x*16 + 16,Level::maxBuildHeight,chunk->z*16 + 16);
for( AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();++it)
{
ApplySchematicRuleDefinition *rule = *it;
rule->processSchematic(chunkBox, chunk);
}
int cx = (chunk->x << 4);
int cz = (chunk->z << 4);
for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ )
{
ConsoleGenerateStructure *structureStart = *it;
if (structureStart->getBoundingBox()->intersects(cx, cz, cx + 15, cz + 15))
{
BoundingBox *bb = new BoundingBox(cx, cz, cx + 15, cz + 15);
structureStart->postProcess(chunk->level, NULL, bb);
delete bb;
}
}
PIXEndNamedEvent();
}
void LevelGenerationOptions::processSchematicsLighting(LevelChunk *chunk)
{
PIXBeginNamedEvent(0,"Processing schematics (lighting) for chunk (%d,%d)", chunk->x, chunk->z);
AABB *chunkBox = AABB::newTemp(chunk->x*16,0,chunk->z*16,chunk->x*16 + 16,Level::maxBuildHeight,chunk->z*16 + 16);
for( AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();++it)
{
ApplySchematicRuleDefinition *rule = *it;
rule->processSchematicLighting(chunkBox, chunk);
}
PIXEndNamedEvent();
}
bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1)
{
PIXBeginNamedEvent(0,"Check Intersects");
// As an optimisation, we can quickly discard things below a certain y which makes most ore checks faster due to
// a) ores generally being below ground/sea level and b) tutorial world additions generally being above ground/sea level
if(!m_bHaveMinY)
{
for(AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();++it)
{
ApplySchematicRuleDefinition *rule = *it;
int minY = rule->getMinY();
if(minY < m_minY) m_minY = minY;
}
for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ )
{
ConsoleGenerateStructure *structureStart = *it;
int minY = structureStart->getMinY();
if(minY < m_minY) m_minY = minY;
}
m_bHaveMinY = true;
}
// 4J Stu - We DO NOT intersect if our upper bound is below the lower bound for all schematics
if( y1 < m_minY ) return false;
bool intersects = false;
for(AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end();++it)
{
ApplySchematicRuleDefinition *rule = *it;
intersects = rule->checkIntersects(x0,y0,z0,x1,y1,z1);
if(intersects) break;
}
if(!intersects)
{
for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ )
{
ConsoleGenerateStructure *structureStart = *it;
intersects = structureStart->checkIntersects(x0,y0,z0,x1,y1,z1);
if(intersects) break;
}
}
PIXEndNamedEvent();
return intersects;
}
void LevelGenerationOptions::clearSchematics()
{
for(AUTO_VAR(it, m_schematics.begin()); it != m_schematics.end(); ++it)
{
delete it->second;
}
m_schematics.clear();
}
ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const wstring &filename, PBYTE pbData, DWORD dwLen)
{
// If we have already loaded this, just return
AUTO_VAR(it, m_schematics.find(filename));
if(it != m_schematics.end())
{
#ifndef _CONTENT_PACKAGE
wprintf(L"We have already loaded schematic file %ls\n", filename.c_str() );
#endif
it->second->incrementRefCount();
return it->second;
}
ConsoleSchematicFile *schematic = NULL;
byteArray data(pbData,dwLen);
ByteArrayInputStream bais(data);
DataInputStream dis(&bais);
schematic = new ConsoleSchematicFile();
schematic->load(&dis);
m_schematics[filename] = schematic;
bais.reset();
return schematic;
}
ConsoleSchematicFile *LevelGenerationOptions::getSchematicFile(const wstring &filename)
{
ConsoleSchematicFile *schematic = NULL;
// If we have already loaded this, just return
AUTO_VAR(it, m_schematics.find(filename));
if(it != m_schematics.end())
{
schematic = it->second;
}
return schematic;
}
void LevelGenerationOptions::releaseSchematicFile(const wstring &filename)
{
// 4J Stu - We don't want to delete them when done, but probably want to keep a set of active schematics for the current world
//AUTO_VAR(it, m_schematics.find(filename));
//if(it != m_schematics.end())
//{
// ConsoleSchematicFile *schematic = it->second;
// schematic->decrementRefCount();
// if(schematic->shouldDelete())
// {
// delete schematic;
// m_schematics.erase(it);
// }
//}
}
void LevelGenerationOptions::loadStringTable(StringTable *table)
{
m_stringTable = table;
}
LPCWSTR LevelGenerationOptions::getString(const wstring &key)
{
if(m_stringTable == NULL)
{
return L"";
}
else
{
return m_stringTable->getString(key);
}
}
void LevelGenerationOptions::getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile)
{
for(AUTO_VAR(it, m_biomeOverrides.begin()); it != m_biomeOverrides.end(); ++it)
{
BiomeOverride *bo = *it;
if(bo->isBiome(biomeId))
{
bo->getTileValues(tile,topTile);
break;
}
}
}
bool LevelGenerationOptions::isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature)
{
bool isFeature = false;
for(AUTO_VAR(it, m_features.begin()); it != m_features.end(); ++it)
{
StartFeature *sf = *it;
if(sf->isFeatureChunk(chunkX, chunkZ, feature))
{
isFeature = true;
break;
}
}
return isFeature;
}
unordered_map<wstring, ConsoleSchematicFile *> *LevelGenerationOptions::getUnfinishedSchematicFiles()
{
// Clean schematic rules.
unordered_set<wstring> usedFiles = unordered_set<wstring>();
for (AUTO_VAR(it, m_schematicRules.begin()); it!=m_schematicRules.end(); it++)
if ( !(*it)->isComplete() )
usedFiles.insert( (*it)->getSchematicName() );
// Clean schematic files.
unordered_map<wstring, ConsoleSchematicFile *> *out
= new unordered_map<wstring, ConsoleSchematicFile *>();
for (AUTO_VAR(it, usedFiles.begin()); it!=usedFiles.end(); it++)
out->insert( pair<wstring, ConsoleSchematicFile *>(*it, getSchematicFile(*it)) );
return out;
}
void LevelGenerationOptions::reset_start()
{
for ( AUTO_VAR( it, m_schematicRules.begin());
it != m_schematicRules.end();
it++ )
{
(*it)->reset();
}
}
void LevelGenerationOptions::reset_finish()
{
//if (m_spawnPos) { delete m_spawnPos; m_spawnPos = NULL; }
//if (m_stringTable) { delete m_stringTable; m_stringTable = NULL; }
if (isFromDLC())
{
m_hasLoadedData = false;
}
}
GrSource *LevelGenerationOptions::info() { return m_pSrc; }
void LevelGenerationOptions::setSrc(eSrc src) { m_src = src; }
LevelGenerationOptions::eSrc LevelGenerationOptions::getSrc() { return m_src; }
bool LevelGenerationOptions::isTutorial() { return getSrc() == eSrc_tutorial; }
bool LevelGenerationOptions::isFromSave() { return getSrc() == eSrc_fromSave; }
bool LevelGenerationOptions::isFromDLC() { return getSrc() == eSrc_fromDLC; }
bool LevelGenerationOptions::requiresTexturePack() { return info()->requiresTexturePack(); }
UINT LevelGenerationOptions::getRequiredTexturePackId() { return info()->getRequiredTexturePackId(); }
wstring LevelGenerationOptions::getDefaultSaveName() { return info()->getDefaultSaveName(); }
LPCWSTR LevelGenerationOptions::getWorldName() { return info()->getWorldName(); }
LPCWSTR LevelGenerationOptions::getDisplayName() { return info()->getDisplayName(); }
wstring LevelGenerationOptions::getGrfPath() { return info()->getGrfPath(); }
bool LevelGenerationOptions::requiresBaseSave() { return info()->requiresBaseSave(); }
wstring LevelGenerationOptions::getBaseSavePath() { return info()->getBaseSavePath(); }
void LevelGenerationOptions::setGrSource(GrSource *grs) { m_pSrc = grs; }
void LevelGenerationOptions::setRequiresTexturePack(bool x) { info()->setRequiresTexturePack(x); }
void LevelGenerationOptions::setRequiredTexturePackId(UINT x) { info()->setRequiredTexturePackId(x); }
void LevelGenerationOptions::setDefaultSaveName(const wstring &x) { info()->setDefaultSaveName(x); }
void LevelGenerationOptions::setWorldName(const wstring &x) { info()->setWorldName(x); }
void LevelGenerationOptions::setDisplayName(const wstring &x) { info()->setDisplayName(x); }
void LevelGenerationOptions::setGrfPath(const wstring &x) { info()->setGrfPath(x); }
void LevelGenerationOptions::setBaseSavePath(const wstring &x) { info()->setBaseSavePath(x); }
bool LevelGenerationOptions::ready() { return info()->ready(); }
void LevelGenerationOptions::setBaseSaveData(PBYTE pbData, DWORD dwSize) { m_pbBaseSaveData = pbData; m_dwBaseSaveSize = dwSize; }
PBYTE LevelGenerationOptions::getBaseSaveData(DWORD &size) { size = m_dwBaseSaveSize; return m_pbBaseSaveData; }
bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != NULL; }
void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_dwBaseSaveSize = 0; }
bool LevelGenerationOptions::hasLoadedData() { return m_hasLoadedData; }
void LevelGenerationOptions::setLoadedData() { m_hasLoadedData = true; }
__int64 LevelGenerationOptions::getLevelSeed() { return m_seed; }
Pos *LevelGenerationOptions::getSpawnPos() { return m_spawnPos; }
bool LevelGenerationOptions::getuseFlatWorld() { return m_useFlatWorld; }
bool LevelGenerationOptions::requiresGameRules() { return m_bRequiresGameRules; }
void LevelGenerationOptions::setRequiredGameRules(LevelRuleset *rules) { m_requiredGameRules = rules; m_bRequiresGameRules = true; }
LevelRuleset *LevelGenerationOptions::getRequiredGameRules() { return m_requiredGameRules; }

View File

@@ -0,0 +1,216 @@
#pragma once
using namespace std;
#pragma message("LevelGenerationOptions.h ")
#include "GameRuleDefinition.h"
#include "..\..\..\Minecraft.World\StructureFeature.h"
class ApplySchematicRuleDefinition;
class LevelChunk;
class ConsoleGenerateStructure;
class ConsoleSchematicFile;
class LevelRuleset;
class BiomeOverride;
class StartFeature;
class GrSource
{
public:
// 4J-JEV:
// Moved all this here; I didn't like that all this header information
// was being mixed in with all the game information as they have
// completely different lifespans.
virtual bool requiresTexturePack()=0;
virtual UINT getRequiredTexturePackId()=0;
virtual wstring getDefaultSaveName()=0;
virtual LPCWSTR getWorldName()=0;
virtual LPCWSTR getDisplayName()=0;
virtual wstring getGrfPath()=0;
virtual bool requiresBaseSave() = 0;
virtual wstring getBaseSavePath() = 0;
virtual void setRequiresTexturePack(bool)=0;
virtual void setRequiredTexturePackId(UINT)=0;
virtual void setDefaultSaveName(const wstring &)=0;
virtual void setWorldName(const wstring &)=0;
virtual void setDisplayName(const wstring &)=0;
virtual void setGrfPath(const wstring &)=0;
virtual void setBaseSavePath(const wstring &)=0;
virtual bool ready()=0;
//virtual void getGrfData(PBYTE &pData, DWORD &pSize)=0;
};
class JustGrSource : public GrSource
{
protected:
wstring m_worldName;
wstring m_displayName;
wstring m_defaultSaveName;
bool m_bRequiresTexturePack;
int m_requiredTexturePackId;
wstring m_grfPath;
wstring m_baseSavePath;
bool m_bRequiresBaseSave;
public:
virtual bool requiresTexturePack();
virtual UINT getRequiredTexturePackId();
virtual wstring getDefaultSaveName();
virtual LPCWSTR getWorldName();
virtual LPCWSTR getDisplayName();
virtual wstring getGrfPath();
virtual bool requiresBaseSave();
virtual wstring getBaseSavePath();
virtual void setRequiresTexturePack(bool x);
virtual void setRequiredTexturePackId(UINT x);
virtual void setDefaultSaveName(const wstring &x);
virtual void setWorldName(const wstring &x);
virtual void setDisplayName(const wstring &x);
virtual void setGrfPath(const wstring &x);
virtual void setBaseSavePath(const wstring &x);
virtual bool ready();
JustGrSource();
};
class LevelGenerationOptions : public GameRuleDefinition
{
public:
enum eSrc
{
eSrc_none,
eSrc_fromSave, // Neither content or header is persistent.
eSrc_fromDLC, // Header is persistent, content should be deleted to conserve space.
eSrc_tutorial, // Both header and content is persistent, content cannot be reloaded.
eSrc_MAX
};
private:
eSrc m_src;
GrSource *m_pSrc;
GrSource *info();
bool m_hasLoadedData;
PBYTE m_pbBaseSaveData;
DWORD m_dwBaseSaveSize;
public:
void setSrc(eSrc src);
eSrc getSrc();
bool isTutorial();
bool isFromSave();
bool isFromDLC();
bool requiresTexturePack();
UINT getRequiredTexturePackId();
wstring getDefaultSaveName();
LPCWSTR getWorldName();
LPCWSTR getDisplayName();
wstring getGrfPath();
bool requiresBaseSave();
wstring getBaseSavePath();
void setGrSource(GrSource *grs);
void setRequiresTexturePack(bool x);
void setRequiredTexturePackId(UINT x);
void setDefaultSaveName(const wstring &x);
void setWorldName(const wstring &x);
void setDisplayName(const wstring &x);
void setGrfPath(const wstring &x);
void setBaseSavePath(const wstring &x);
bool ready();
void setBaseSaveData(PBYTE pbData, DWORD dwSize);
PBYTE getBaseSaveData(DWORD &size);
bool hasBaseSaveData();
void deleteBaseSaveData();
bool hasLoadedData();
void setLoadedData();
private:
// This should match the "MapOptionsRule" definition in the XML schema
__int64 m_seed;
bool m_useFlatWorld;
Pos *m_spawnPos;
vector<ApplySchematicRuleDefinition *> m_schematicRules;
vector<ConsoleGenerateStructure *> m_structureRules;
bool m_bHaveMinY;
int m_minY;
unordered_map<wstring, ConsoleSchematicFile *> m_schematics;
vector<BiomeOverride *> m_biomeOverrides;
vector<StartFeature *> m_features;
bool m_bRequiresGameRules;
LevelRuleset *m_requiredGameRules;
StringTable *m_stringTable;
public:
LevelGenerationOptions();
~LevelGenerationOptions();
virtual ConsoleGameRules::EGameRuleType getActionType();
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
__int64 getLevelSeed();
Pos *getSpawnPos();
bool getuseFlatWorld();
void processSchematics(LevelChunk *chunk);
void processSchematicsLighting(LevelChunk *chunk);
bool checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1);
private:
void clearSchematics();
public:
ConsoleSchematicFile *loadSchematicFile(const wstring &filename, PBYTE pbData, DWORD dwLen);
public:
ConsoleSchematicFile *getSchematicFile(const wstring &filename);
void releaseSchematicFile(const wstring &filename);
bool requiresGameRules();
void setRequiredGameRules(LevelRuleset *rules);
LevelRuleset *getRequiredGameRules();
void getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile);
bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature);
void loadStringTable(StringTable *table);
LPCWSTR getString(const wstring &key);
unordered_map<wstring, ConsoleSchematicFile *> *getUnfinishedSchematicFiles();
// 4J-JEV:
// ApplySchematicRules contain limited state
// which needs to be reset BEFORE a new game starts.
void reset_start();
// 4J-JEV:
// This file contains state that needs to be deleted
// or reset once a game has finished.
void reset_finish();
};

View File

@@ -0,0 +1,26 @@
#include "stdafx.h"
#include "LevelGenerationOptions.h"
#include "LevelGenerators.h"
LevelGenerators::LevelGenerators()
{
}
void LevelGenerators::addLevelGenerator(const wstring &displayName, LevelGenerationOptions *generator)
{
if(!displayName.empty()) generator->setDisplayName(displayName);
m_levelGenerators.push_back(generator);
}
void LevelGenerators::removeLevelGenerator(LevelGenerationOptions *generator)
{
vector<LevelGenerationOptions *>::iterator it;
while ( (it = find( m_levelGenerators.begin(),
m_levelGenerators.end(),
generator ) )
!= m_levelGenerators.end() )
{
m_levelGenerators.erase(it);
}
}

View File

@@ -0,0 +1,19 @@
#pragma once
using namespace std;
class LevelGenerationOptions;
class LevelGenerators
{
private:
vector<LevelGenerationOptions *> m_levelGenerators;
public:
LevelGenerators();
void addLevelGenerator(const wstring &displayName, LevelGenerationOptions *generator);
void removeLevelGenerator(LevelGenerationOptions *generator);
vector<LevelGenerationOptions *> *getLevelGenerators() { return &m_levelGenerators; }
};

View File

@@ -0,0 +1,20 @@
#include "stdafx.h"
#include "LevelRules.h"
LevelRules::LevelRules()
{
}
void LevelRules::addLevelRule(const wstring &displayName, PBYTE pbData, DWORD dwLen)
{
}
void LevelRules::addLevelRule(const wstring &displayName, LevelRuleset *rootRule)
{
}
void LevelRules::removeLevelRule(LevelRuleset *removing)
{
// TODO ?
}

View File

@@ -0,0 +1,14 @@
#pragma once
class LevelRuleset;
class LevelRules
{
public:
LevelRules();
void addLevelRule(const wstring &displayName, PBYTE pbData, DWORD dwLen);
void addLevelRule(const wstring &displayName, LevelRuleset *rootRule);
void removeLevelRule(LevelRuleset *removing);
};

View File

@@ -0,0 +1,71 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\StringTable.h"
#include "ConsoleGameRules.h"
#include "LevelRuleset.h"
LevelRuleset::LevelRuleset()
{
m_stringTable = NULL;
}
LevelRuleset::~LevelRuleset()
{
for(AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); ++it)
{
delete *it;
}
}
void LevelRuleset::getChildren(vector<GameRuleDefinition *> *children)
{
CompoundGameRuleDefinition::getChildren(children);
for (AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); it++)
children->push_back(*it);
}
GameRuleDefinition *LevelRuleset::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea)
{
rule = new NamedAreaRuleDefinition();
m_areas.push_back((NamedAreaRuleDefinition *)rule);
}
else
{
rule = CompoundGameRuleDefinition::addChild(ruleType);
}
return rule;
}
void LevelRuleset::loadStringTable(StringTable *table)
{
m_stringTable = table;
}
LPCWSTR LevelRuleset::getString(const wstring &key)
{
if(m_stringTable == NULL)
{
return L"";
}
else
{
return m_stringTable->getString(key);
}
}
AABB *LevelRuleset::getNamedArea(const wstring &areaName)
{
AABB *area = NULL;
for(AUTO_VAR(it, m_areas.begin()); it != m_areas.end(); ++it)
{
if( (*it)->getName().compare(areaName) == 0 )
{
area = (*it)->getArea();
break;
}
}
return area;
}

View File

@@ -0,0 +1,27 @@
#pragma once
#include "CompoundGameRuleDefinition.h"
class NamedAreaRuleDefinition;
class LevelRuleset : public CompoundGameRuleDefinition
{
private:
vector<NamedAreaRuleDefinition *> m_areas;
StringTable *m_stringTable;
public:
LevelRuleset();
~LevelRuleset();
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_LevelRules; }
void loadStringTable(StringTable *table);
LPCWSTR getString(const wstring &key);
AABB *getNamedArea(const wstring &areaName);
StringTable *getStringTable() { return m_stringTable; }
};

View File

@@ -0,0 +1,84 @@
#include "stdafx.h"
#include "NamedAreaRuleDefinition.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.phys.h"
NamedAreaRuleDefinition::NamedAreaRuleDefinition()
{
m_name = L"";
m_area = AABB::newPermanent(0,0,0,0,0,0);
}
NamedAreaRuleDefinition::~NamedAreaRuleDefinition()
{
delete m_area;
}
void NamedAreaRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes)
{
GameRuleDefinition::writeAttributes(dos, numAttributes + 7);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_name);
dos->writeUTF(m_name);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x0);
dos->writeUTF(_toString(m_area->x0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y0);
dos->writeUTF(_toString(m_area->y0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z0);
dos->writeUTF(_toString(m_area->z0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x1);
dos->writeUTF(_toString(m_area->x1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y1);
dos->writeUTF(_toString(m_area->y1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z1);
dos->writeUTF(_toString(m_area->z1));
}
void NamedAreaRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"name") == 0)
{
m_name = attributeValue;
#ifndef _CONTENT_PACKAGE
wprintf(L"NamedAreaRuleDefinition: Adding parameter name=%ls\n",m_name.c_str());
#endif
}
else if(attributeName.compare(L"x0") == 0)
{
m_area->x0 = _fromString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x0=%f\n",m_area->x0);
}
else if(attributeName.compare(L"y0") == 0)
{
m_area->y0 = _fromString<int>(attributeValue);
if(m_area->y0 < 0) m_area->y0 = 0;
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y0=%f\n",m_area->y0);
}
else if(attributeName.compare(L"z0") == 0)
{
m_area->z0 = _fromString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z0=%f\n",m_area->z0);
}
else if(attributeName.compare(L"x1") == 0)
{
m_area->x1 = _fromString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter x1=%f\n",m_area->x1);
}
else if(attributeName.compare(L"y1") == 0)
{
m_area->y1 = _fromString<int>(attributeValue);
if(m_area->y1 < 0) m_area->y1 = 0;
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter y1=%f\n",m_area->y1);
}
else if(attributeName.compare(L"z1") == 0)
{
m_area->z1 = _fromString<int>(attributeValue);
app.DebugPrintf("NamedAreaRuleDefinition: Adding parameter z1=%f\n",m_area->z1);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}

View File

@@ -0,0 +1,23 @@
#pragma once
#include "GameRuleDefinition.h"
class NamedAreaRuleDefinition : public GameRuleDefinition
{
private:
wstring m_name;
AABB *m_area;
public:
NamedAreaRuleDefinition();
~NamedAreaRuleDefinition();
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_NamedArea; }
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
AABB *getArea() { return m_area; }
wstring getName() { return m_name; }
};

View File

@@ -0,0 +1,53 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "StartFeature.h"
StartFeature::StartFeature()
{
m_chunkX = 0;
m_chunkZ = 0;
m_feature = StructureFeature::eFeature_Temples;
}
void StartFeature::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
GameRuleDefinition::writeAttributes(dos, numAttrs + 3);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_chunkX);
dos->writeUTF(_toString(m_chunkX));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_chunkZ);
dos->writeUTF(_toString(m_chunkZ));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_feature);
dos->writeUTF(_toString((int)m_feature));
}
void StartFeature::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"chunkX") == 0)
{
int value = _fromString<int>(attributeValue);
m_chunkX = value;
app.DebugPrintf("StartFeature: Adding parameter chunkX=%d\n",m_chunkX);
}
else if(attributeName.compare(L"chunkZ") == 0)
{
int value = _fromString<int>(attributeValue);
m_chunkZ = value;
app.DebugPrintf("StartFeature: Adding parameter chunkZ=%d\n",m_chunkZ);
}
else if(attributeName.compare(L"feature") == 0)
{
int value = _fromString<int>(attributeValue);
m_feature = (StructureFeature::EFeatureTypes)value;
app.DebugPrintf("StartFeature: Adding parameter feature=%d\n",m_feature);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool StartFeature::isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature)
{
return chunkX == m_chunkX && chunkZ == m_chunkZ && feature == m_feature;
}

View File

@@ -0,0 +1,22 @@
#pragma once
using namespace std;
#include "GameRuleDefinition.h"
#include "..\..\..\Minecraft.World\StructureFeature.h"
class StartFeature : public GameRuleDefinition
{
private:
int m_chunkX, m_chunkZ;
StructureFeature::EFeatureTypes m_feature;
public:
StartFeature();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_StartFeature; }
virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature);
};

View File

@@ -0,0 +1,171 @@
#include "stdafx.h"
#include "UpdatePlayerRuleDefinition.h"
#include "ConsoleGameRules.h"
#include "..\..\..\Minecraft.World\Pos.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.food.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
UpdatePlayerRuleDefinition::UpdatePlayerRuleDefinition()
{
m_bUpdateHealth = m_bUpdateFood = m_bUpdateYRot = false;;
m_health = 0;
m_food = 0;
m_spawnPos = NULL;
m_yRot = 0.0f;
}
UpdatePlayerRuleDefinition::~UpdatePlayerRuleDefinition()
{
for(AUTO_VAR(it, m_items.begin()); it != m_items.end(); ++it)
{
delete *it;
}
}
void UpdatePlayerRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes)
{
int attrCount = 3;
if(m_bUpdateHealth) ++attrCount;
if(m_bUpdateFood) ++attrCount;
if(m_bUpdateYRot) ++attrCount;
GameRuleDefinition::writeAttributes(dos, numAttributes + attrCount );
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnX);
dos->writeUTF(_toString(m_spawnPos->x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnY);
dos->writeUTF(_toString(m_spawnPos->y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnZ);
dos->writeUTF(_toString(m_spawnPos->z));
if(m_bUpdateYRot)
{
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_yRot);
dos->writeUTF(_toString(m_yRot));
}
if(m_bUpdateHealth)
{
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_food);
dos->writeUTF(_toString(m_health));
}
if(m_bUpdateFood)
{
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_health);
dos->writeUTF(_toString(m_food));
}
}
void UpdatePlayerRuleDefinition::getChildren(vector<GameRuleDefinition *> *children)
{
GameRuleDefinition::getChildren(children);
for(AUTO_VAR(it, m_items.begin()); it!=m_items.end(); it++)
children->push_back(*it);
}
GameRuleDefinition *UpdatePlayerRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_AddItem)
{
rule = new AddItemRuleDefinition();
m_items.push_back((AddItemRuleDefinition *)rule);
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"UpdatePlayerRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
return rule;
}
void UpdatePlayerRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"spawnX") == 0)
{
if(m_spawnPos == NULL) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->x = value;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnX=%d\n",value);
}
else if(attributeName.compare(L"spawnY") == 0)
{
if(m_spawnPos == NULL) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->y = value;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnY=%d\n",value);
}
else if(attributeName.compare(L"spawnZ") == 0)
{
if(m_spawnPos == NULL) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->z = value;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnZ=%d\n",value);
}
else if(attributeName.compare(L"health") == 0)
{
int value = _fromString<int>(attributeValue);
m_health = value;
m_bUpdateHealth = true;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter health=%d\n",value);
}
else if(attributeName.compare(L"food") == 0)
{
int value = _fromString<int>(attributeValue);
m_food = value;
m_bUpdateFood = true;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter health=%d\n",value);
}
else if(attributeName.compare(L"yRot") == 0)
{
float value = _fromString<float>(attributeValue);
m_yRot = value;
m_bUpdateYRot = true;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter yRot=%f\n",value);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
void UpdatePlayerRuleDefinition::postProcessPlayer(shared_ptr<Player> player)
{
if(m_bUpdateHealth)
{
player->lastHealth = m_health;
player->setHealth(m_health);
}
if(m_bUpdateFood)
{
player->getFoodData()->setFoodLevel(m_food);
}
double x = player->x;
double y = player->y;
double z = player->z;
float yRot = player->yRot;
float xRot = player->xRot;
if(m_spawnPos != NULL)
{
x = m_spawnPos->x;
y = m_spawnPos->y;
z = m_spawnPos->z;
}
if(m_bUpdateYRot)
{
yRot = m_yRot;
}
if(m_spawnPos != NULL || m_bUpdateYRot) player->absMoveTo(x,y,z,yRot,xRot);
for(AUTO_VAR(it, m_items.begin()); it != m_items.end(); ++it)
{
AddItemRuleDefinition *addItem = *it;
addItem->addItemToContainer(player->inventory, -1);
}
}

View File

@@ -0,0 +1,33 @@
#pragma once
using namespace std;
#include "GameRuleDefinition.h"
class AddItemRuleDefinition;
class Pos;
class UpdatePlayerRuleDefinition : public GameRuleDefinition
{
private:
vector<AddItemRuleDefinition *> m_items;
bool m_bUpdateHealth, m_bUpdateFood, m_bUpdateYRot, m_bUpdateInventory;
int m_health;
int m_food;
Pos *m_spawnPos;
float m_yRot;
public:
UpdatePlayerRuleDefinition();
~UpdatePlayerRuleDefinition();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_UpdatePlayerRule; }
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
virtual void postProcessPlayer(shared_ptr<Player> player);
};

View File

@@ -0,0 +1,82 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "UseTileRuleDefinition.h"
UseTileRuleDefinition::UseTileRuleDefinition()
{
m_tileId = -1;
m_useCoords = false;
}
void UseTileRuleDefinition::writeAttributes(DataOutputStream *dos, UINT numAttributes)
{
GameRuleDefinition::writeAttributes(dos, numAttributes + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_tileId);
dos->writeUTF(_toString(m_tileId));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_useCoords);
dos->writeUTF(_toString(m_useCoords));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_coordinates.x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_coordinates.y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_coordinates.z));
}
void UseTileRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"tileId") == 0)
{
m_tileId = _fromString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter tileId=%d\n",m_tileId);
}
else if(attributeName.compare(L"useCoords") == 0)
{
m_useCoords = _fromString<bool>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter useCoords=%s\n",m_useCoords?"TRUE":"FALSE");
}
else if(attributeName.compare(L"x") == 0)
{
m_coordinates.x = _fromString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter x=%d\n",m_coordinates.x);
}
else if(attributeName.compare(L"y") == 0)
{
m_coordinates.y = _fromString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter y=%d\n",m_coordinates.y);
}
else if(attributeName.compare(L"z") == 0)
{
m_coordinates.z = _fromString<int>(attributeValue);
app.DebugPrintf("UseTileRule: Adding parameter z=%d\n",m_coordinates.z);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool UseTileRuleDefinition::onUseTile(GameRule *rule, int tileId, int x, int y, int z)
{
bool statusChanged = false;
if( m_tileId == tileId )
{
if( !m_useCoords || (m_coordinates.x == x && m_coordinates.y == y && m_coordinates.z == z) )
{
if(!getComplete(rule))
{
statusChanged = true;
setComplete(rule,true);
app.DebugPrintf("Completed UseTileRule with info - t:%d, coords:%s, x:%d, y:%d, z:%d\n", m_tileId,m_useCoords?"TRUE":"FALSE",m_coordinates.x,m_coordinates.y,m_coordinates.z);
// Send a packet or some other announcement here
}
}
}
return statusChanged;
}

View File

@@ -0,0 +1,24 @@
#pragma once
using namespace std;
#include "GameRuleDefinition.h"
#include "..\..\..\Minecraft.World\Pos.h"
class UseTileRuleDefinition : public GameRuleDefinition
{
private:
// These values should map directly to the xsd definition for this Rule
int m_tileId;
bool m_useCoords;
Pos m_coordinates;
public:
UseTileRuleDefinition();
ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_UseTileRule; }
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
virtual bool onUseTile(GameRule *rule, int tileId, int x, int y, int z);
};

View File

@@ -0,0 +1,104 @@
#include "stdafx.h"
#include "XboxStructureActionGenerateBox.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.levelgen.structure.h"
XboxStructureActionGenerateBox::XboxStructureActionGenerateBox()
{
m_x0 = m_y0 = m_z0 = m_x1 = m_y1 = m_z1 = m_edgeTile = m_fillTile = 0;
m_skipAir = false;
}
void XboxStructureActionGenerateBox::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
ConsoleGenerateStructureAction::writeAttributes(dos, numAttrs + 9);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x0);
dos->writeUTF(_toString(m_x0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y0);
dos->writeUTF(_toString(m_y0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z0);
dos->writeUTF(_toString(m_z0));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x1);
dos->writeUTF(_toString(m_x1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y1);
dos->writeUTF(_toString(m_y1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z1);
dos->writeUTF(_toString(m_z1));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_edgeTile);
dos->writeUTF(_toString(m_edgeTile));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_fillTile);
dos->writeUTF(_toString(m_fillTile));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_skipAir);
dos->writeUTF(_toString(m_skipAir));
}
void XboxStructureActionGenerateBox::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"x0") == 0)
{
int value = _fromString<int>(attributeValue);
m_x0 = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter x0=%d\n",m_x0);
}
else if(attributeName.compare(L"y0") == 0)
{
int value = _fromString<int>(attributeValue);
m_y0 = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter y0=%d\n",m_y0);
}
else if(attributeName.compare(L"z0") == 0)
{
int value = _fromString<int>(attributeValue);
m_z0 = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter z0=%d\n",m_z0);
}
else if(attributeName.compare(L"x1") == 0)
{
int value = _fromString<int>(attributeValue);
m_x1 = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter x1=%d\n",m_x1);
}
else if(attributeName.compare(L"y1") == 0)
{
int value = _fromString<int>(attributeValue);
m_y1 = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter y1=%d\n",m_y1);
}
else if(attributeName.compare(L"z1") == 0)
{
int value = _fromString<int>(attributeValue);
m_z1 = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter z1=%d\n",m_z1);
}
else if(attributeName.compare(L"edgeTile") == 0)
{
int value = _fromString<int>(attributeValue);
m_edgeTile = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter edgeTile=%d\n",m_edgeTile);
}
else if(attributeName.compare(L"fillTile") == 0)
{
int value = _fromString<int>(attributeValue);
m_fillTile = value;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter fillTile=%d\n",m_fillTile);
}
else if(attributeName.compare(L"skipAir") == 0)
{
if(attributeValue.compare(L"true") == 0) m_skipAir = true;
app.DebugPrintf("XboxStructureActionGenerateBox: Adding parameter skipAir=%s\n",m_skipAir?"TRUE":"FALSE");
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool XboxStructureActionGenerateBox::generateBoxInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB)
{
app.DebugPrintf("XboxStructureActionGenerateBox - generating a box\n");
structure->generateBox(level,chunkBB,m_x0,m_y0,m_z0,m_x1,m_y1,m_z1,m_edgeTile,m_fillTile,m_skipAir);
return true;
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "ConsoleGenerateStructureAction.h"
class StructurePiece;
class Level;
class BoundingBox;
class XboxStructureActionGenerateBox : public ConsoleGenerateStructureAction
{
private:
int m_x0, m_y0, m_z0, m_x1, m_y1, m_z1, m_edgeTile, m_fillTile;
bool m_skipAir;
public:
XboxStructureActionGenerateBox();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_GenerateBox; }
virtual int getEndX() { return m_x1; }
virtual int getEndY() { return m_y1; }
virtual int getEndZ() { return m_z1; }
virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool generateBoxInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB);
};

View File

@@ -0,0 +1,72 @@
#include "stdafx.h"
#include "XboxStructureActionPlaceBlock.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.levelgen.structure.h"
XboxStructureActionPlaceBlock::XboxStructureActionPlaceBlock()
{
m_x = m_y = m_z = m_tile = m_data = 0;
}
void XboxStructureActionPlaceBlock::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
ConsoleGenerateStructureAction::writeAttributes(dos, numAttrs + 5);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_x);
dos->writeUTF(_toString(m_x));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_y);
dos->writeUTF(_toString(m_y));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_z);
dos->writeUTF(_toString(m_z));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_data);
dos->writeUTF(_toString(m_data));
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_block);
dos->writeUTF(_toString(m_tile));
}
void XboxStructureActionPlaceBlock::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"x") == 0)
{
int value = _fromString<int>(attributeValue);
m_x = value;
app.DebugPrintf("XboxStructureActionPlaceBlock: Adding parameter x=%d\n",m_x);
}
else if(attributeName.compare(L"y") == 0)
{
int value = _fromString<int>(attributeValue);
m_y = value;
app.DebugPrintf("XboxStructureActionPlaceBlock: Adding parameter y=%d\n",m_y);
}
else if(attributeName.compare(L"z") == 0)
{
int value = _fromString<int>(attributeValue);
m_z = value;
app.DebugPrintf("XboxStructureActionPlaceBlock: Adding parameter z=%d\n",m_z);
}
else if(attributeName.compare(L"block") == 0)
{
int value = _fromString<int>(attributeValue);
m_tile = value;
app.DebugPrintf("XboxStructureActionPlaceBlock: Adding parameter block=%d\n",m_tile);
}
else if(attributeName.compare(L"data") == 0)
{
int value = _fromString<int>(attributeValue);
m_data = value;
app.DebugPrintf("XboxStructureActionPlaceBlock: Adding parameter data=%d\n",m_data);
}
else
{
GameRuleDefinition::addAttribute(attributeName, attributeValue);
}
}
bool XboxStructureActionPlaceBlock::placeBlockInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB)
{
app.DebugPrintf("XboxStructureActionPlaceBlock - placing a block\n");
structure->placeBlock(level,m_tile,m_data,m_x,m_y,m_z,chunkBB);
return true;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "ConsoleGenerateStructureAction.h"
class StructurePiece;
class Level;
class BoundingBox;
class XboxStructureActionPlaceBlock : public ConsoleGenerateStructureAction
{
protected:
int m_x, m_y, m_z, m_tile, m_data;
public:
XboxStructureActionPlaceBlock();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_PlaceBlock; }
virtual int getEndX() { return m_x; }
virtual int getEndY() { return m_y; }
virtual int getEndZ() { return m_z; }
virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool placeBlockInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB);
};

View File

@@ -0,0 +1,99 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "XboxStructureActionPlaceContainer.h"
#include "AddItemRuleDefinition.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.levelgen.structure.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
XboxStructureActionPlaceContainer::XboxStructureActionPlaceContainer()
{
m_tile = Tile::chest_Id;
}
XboxStructureActionPlaceContainer::~XboxStructureActionPlaceContainer()
{
for(AUTO_VAR(it, m_items.begin()); it != m_items.end(); ++it)
{
delete *it;
}
}
// 4J-JEV: Super class handles attr-facing fine.
//void XboxStructureActionPlaceContainer::writeAttributes(DataOutputStream *dos, UINT numAttrs)
void XboxStructureActionPlaceContainer::getChildren(vector<GameRuleDefinition *> *children)
{
XboxStructureActionPlaceBlock::getChildren(children);
for(AUTO_VAR(it, m_items.begin()); it!=m_items.end(); it++)
children->push_back( *it );
}
GameRuleDefinition *XboxStructureActionPlaceContainer::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
GameRuleDefinition *rule = NULL;
if(ruleType == ConsoleGameRules::eGameRuleType_AddItem)
{
rule = new AddItemRuleDefinition();
m_items.push_back((AddItemRuleDefinition *)rule);
}
else
{
#ifndef _CONTENT_PACKAGE
wprintf(L"XboxStructureActionPlaceContainer: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
return rule;
}
void XboxStructureActionPlaceContainer::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"facing") == 0)
{
int value = _fromString<int>(attributeValue);
m_data = value;
app.DebugPrintf("XboxStructureActionPlaceContainer: Adding parameter facing=%d\n",m_data);
}
else
{
XboxStructureActionPlaceBlock::addAttribute(attributeName, attributeValue);
}
}
bool XboxStructureActionPlaceContainer::placeContainerInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB)
{
int worldX = structure->getWorldX( m_x, m_z );
int worldY = structure->getWorldY( m_y );
int worldZ = structure->getWorldZ( m_x, m_z );
if ( chunkBB->isInside( worldX, worldY, worldZ ) )
{
if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL )
{
// Remove the current tile entity
level->removeTileEntity( worldX, worldY, worldZ );
level->setTile( worldX, worldY, worldZ, 0 );
}
level->setTile( worldX, worldY, worldZ, m_tile );
shared_ptr<Container> container = dynamic_pointer_cast<Container>(level->getTileEntity( worldX, worldY, worldZ ));
app.DebugPrintf("XboxStructureActionPlaceContainer - placing a container at (%d,%d,%d)\n", worldX, worldY, worldZ);
if ( container != NULL )
{
level->setData( worldX, worldY, worldZ, m_data);
// Add items
int slotId = 0;
for(AUTO_VAR(it, m_items.begin()); it != m_items.end() && (slotId < container->getContainerSize()); ++it, ++slotId )
{
AddItemRuleDefinition *addItem = *it;
addItem->addItemToContainer(container,slotId);
}
}
return true;
}
return false;
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "XboxStructureActionPlaceBlock.h"
class AddItemRuleDefinition;
class StructurePiece;
class Level;
class BoundingBox;
class XboxStructureActionPlaceContainer : public XboxStructureActionPlaceBlock
{
private:
vector<AddItemRuleDefinition *> m_items;
public:
XboxStructureActionPlaceContainer();
~XboxStructureActionPlaceContainer();
virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_PlaceContainer; }
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
// 4J-JEV: Super class handles attr-facing fine.
//virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
bool placeContainerInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB);
};

View File

@@ -0,0 +1,69 @@
#include "stdafx.h"
#include "..\..\..\Minecraft.World\StringHelpers.h"
#include "XboxStructureActionPlaceSpawner.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.levelgen.structure.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
XboxStructureActionPlaceSpawner::XboxStructureActionPlaceSpawner()
{
m_tile = Tile::mobSpawner_Id;
m_entityId = L"Pig";
}
XboxStructureActionPlaceSpawner::~XboxStructureActionPlaceSpawner()
{
}
void XboxStructureActionPlaceSpawner::writeAttributes(DataOutputStream *dos, UINT numAttrs)
{
XboxStructureActionPlaceBlock::writeAttributes(dos, numAttrs + 1);
ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_entity);
dos->writeUTF(m_entityId);
}
void XboxStructureActionPlaceSpawner::addAttribute(const wstring &attributeName, const wstring &attributeValue)
{
if(attributeName.compare(L"entity") == 0)
{
m_entityId = attributeValue;
#ifndef _CONTENT_PACKAGE
wprintf(L"XboxStructureActionPlaceSpawner: Adding parameter entity=%ls\n",m_entityId.c_str());
#endif
}
else
{
XboxStructureActionPlaceBlock::addAttribute(attributeName, attributeValue);
}
}
bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *structure, Level *level, BoundingBox *chunkBB)
{
int worldX = structure->getWorldX( m_x, m_z );
int worldY = structure->getWorldY( m_y );
int worldZ = structure->getWorldZ( m_x, m_z );
if ( chunkBB->isInside( worldX, worldY, worldZ ) )
{
if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL )
{
// Remove the current tile entity
level->removeTileEntity( worldX, worldY, worldZ );
level->setTile( worldX, worldY, worldZ, 0 );
}
level->setTile( worldX, worldY, worldZ, m_tile );
shared_ptr<MobSpawnerTileEntity> entity = dynamic_pointer_cast<MobSpawnerTileEntity>(level->getTileEntity( worldX, worldY, worldZ ));
#ifndef _CONTENT_PACKAGE
wprintf(L"XboxStructureActionPlaceSpawner - placing a %ls spawner at (%d,%d,%d)\n", m_entityId.c_str(), worldX, worldY, worldZ);
#endif
if( entity != NULL )
{
entity->setEntityId(m_entityId);
}
return true;
}
return false;
}

Some files were not shown because too many files have changed in this diff Show More