Merge pull request #227 from 4jcraft/chore/fmt
Some checks are pending
Build (Linux, x86_64) / build-linux (push) Waiting to run
Build (Linux, x86_64) / build-linux-debug (push) Waiting to run
Clang Format / clang-format (push) Waiting to run

chore: fmt
This commit is contained in:
Tropical 2026-03-13 21:12:55 -05:00 committed by GitHub
commit b27c76a696
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2056 changed files with 184448 additions and 185324 deletions

3
.git-blame-ignore-revs Normal file
View file

@ -0,0 +1,3 @@
e8424f2000222490850d2a5227b6b6b0c0a5d6ce
33d0737d1d4a6d8a7f0fa3bf2af2b242b545dc69
631873465238400f8ed8113ac87d63c3d6edf617

View file

@ -8,52 +8,69 @@
C_4JInput InputManager;
static const int KEY_COUNT = SDL_NUM_SCANCODES;
static const int KEY_COUNT = SDL_NUM_SCANCODES;
static const float MOUSE_SCALE = 0.015f;
// Vars
static bool s_sdlInitialized = false;
static bool s_keysCurrent[KEY_COUNT] = {};
static bool s_keysPrev [KEY_COUNT] = {};
static bool s_mouseLeftCurrent = false, s_mouseLeftPrev = false;
static bool s_keysPrev[KEY_COUNT] = {};
static bool s_mouseLeftCurrent = false, s_mouseLeftPrev = false;
static bool s_mouseRightCurrent = false, s_mouseRightPrev = false;
static bool s_menuDisplayed[4] = {};
static bool s_menuDisplayed[4] = {};
static bool s_prevMenuDisplayed = false;
static bool s_snapTaken = false;
static float s_accumRelX = 0, s_accumRelY = 0;
static float s_snapRelX = 0, s_snapRelY = 0;
static float s_snapRelX = 0, s_snapRelY = 0;
static int s_scrollTicksForButtonPressed = 0;
static int s_scrollTicksForGetValue = 0;
static int s_scrollTicksSnap = 0;
static bool s_scrollSnapTaken = false;
static int s_scrollTicksForButtonPressed = 0;
static int s_scrollTicksForGetValue = 0;
static int s_scrollTicksSnap = 0;
static bool s_scrollSnapTaken = false;
// We set all the watched keys
// I don't know if I'll need to change this if we add chat support soon.
static const int s_watchedKeys[] = {
SDL_SCANCODE_W, SDL_SCANCODE_A, SDL_SCANCODE_S, SDL_SCANCODE_D,
SDL_SCANCODE_SPACE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_RSHIFT,
SDL_SCANCODE_E, SDL_SCANCODE_Q, SDL_SCANCODE_F,
SDL_SCANCODE_C, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_RETURN,
SDL_SCANCODE_F3, SDL_SCANCODE_F5,
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, SDL_SCANCODE_RIGHT,
SDL_SCANCODE_PAGEUP, SDL_SCANCODE_PAGEDOWN,
SDL_SCANCODE_TAB, SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL,
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4,
SDL_SCANCODE_5, SDL_SCANCODE_6, SDL_SCANCODE_7, SDL_SCANCODE_8,
SDL_SCANCODE_9,
SDL_SCANCODE_W, SDL_SCANCODE_A, SDL_SCANCODE_S,
SDL_SCANCODE_D, SDL_SCANCODE_SPACE, SDL_SCANCODE_LSHIFT,
SDL_SCANCODE_RSHIFT, SDL_SCANCODE_E, SDL_SCANCODE_Q,
SDL_SCANCODE_F, SDL_SCANCODE_C, SDL_SCANCODE_ESCAPE,
SDL_SCANCODE_RETURN, SDL_SCANCODE_F3, SDL_SCANCODE_F5,
SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT,
SDL_SCANCODE_RIGHT, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_PAGEDOWN,
SDL_SCANCODE_TAB, SDL_SCANCODE_LCTRL, SDL_SCANCODE_RCTRL,
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3,
SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6,
SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9,
};
static const int s_watchedKeyCount = (int)(sizeof(s_watchedKeys) / sizeof(s_watchedKeys[0]));
static const int s_watchedKeyCount =
(int)(sizeof(s_watchedKeys) / sizeof(s_watchedKeys[0]));
static inline bool KDown (int sc) { return (sc > 0 && sc < KEY_COUNT) ? s_keysCurrent[sc] : false; }
static inline bool KPressed (int sc) { return (sc > 0 && sc < KEY_COUNT) ? !s_keysPrev[sc] && s_keysCurrent[sc] : false; }
static inline bool KReleased(int sc) { return (sc > 0 && sc < KEY_COUNT) ? s_keysPrev[sc] && !s_keysCurrent[sc] : false; }
static inline bool KDown(int sc) {
return (sc > 0 && sc < KEY_COUNT) ? s_keysCurrent[sc] : false;
}
static inline bool KPressed(int sc) {
return (sc > 0 && sc < KEY_COUNT) ? !s_keysPrev[sc] && s_keysCurrent[sc]
: false;
}
static inline bool KReleased(int sc) {
return (sc > 0 && sc < KEY_COUNT) ? s_keysPrev[sc] && !s_keysCurrent[sc]
: false;
}
static inline bool MouseLDown () { return s_mouseLeftCurrent; }
static inline bool MouseLPressed () { return s_mouseLeftCurrent && !s_mouseLeftPrev; }
static inline bool MouseLReleased() { return !s_mouseLeftCurrent && s_mouseLeftPrev; }
static inline bool MouseRDown () { return s_mouseRightCurrent; }
static inline bool MouseRPressed () { return s_mouseRightCurrent && !s_mouseRightPrev; }
static inline bool MouseRReleased() { return !s_mouseRightCurrent && s_mouseRightPrev; }
static inline bool MouseLDown() { return s_mouseLeftCurrent; }
static inline bool MouseLPressed() {
return s_mouseLeftCurrent && !s_mouseLeftPrev;
}
static inline bool MouseLReleased() {
return !s_mouseLeftCurrent && s_mouseLeftPrev;
}
static inline bool MouseRDown() { return s_mouseRightCurrent; }
static inline bool MouseRPressed() {
return s_mouseRightCurrent && !s_mouseRightPrev;
}
static inline bool MouseRReleased() {
return !s_mouseRightCurrent && s_mouseRightPrev;
}
// get directly into SDL events before the game queue can steal them.
// this took me a while.
@ -91,8 +108,10 @@ static int ScrollSnap() {
static void TakeSnapIfNeeded() {
if (!s_snapTaken) {
s_snapRelX = s_accumRelX; s_accumRelX = 0;
s_snapRelY = s_accumRelY; s_accumRelY = 0;
s_snapRelX = s_accumRelX;
s_accumRelX = 0;
s_snapRelY = s_accumRelY;
s_accumRelY = 0;
s_snapTaken = true;
}
}
@ -106,27 +125,29 @@ void C_4JInput::Initialise(int, unsigned char, unsigned char, unsigned char) {
s_sdlInitialized = true;
}
memset(s_keysCurrent, 0, sizeof(s_keysCurrent));
memset(s_keysPrev, 0, sizeof(s_keysPrev));
memset(s_keysCurrent, 0, sizeof(s_keysCurrent));
memset(s_keysPrev, 0, sizeof(s_keysPrev));
memset(s_menuDisplayed, 0, sizeof(s_menuDisplayed));
s_mouseLeftCurrent = s_mouseLeftPrev = s_mouseRightCurrent = s_mouseRightPrev = false;
s_mouseLeftCurrent = s_mouseLeftPrev = s_mouseRightCurrent =
s_mouseRightPrev = false;
s_accumRelX = s_accumRelY = s_snapRelX = s_snapRelY = 0;
// i really gotta name these vars better..
s_scrollTicksForButtonPressed = s_scrollTicksForGetValue = s_scrollTicksSnap = 0;
s_scrollTicksForButtonPressed = s_scrollTicksForGetValue =
s_scrollTicksSnap = 0;
s_snapTaken = s_scrollSnapTaken = s_prevMenuDisplayed = false;
if (s_sdlInitialized)
SDL_SetRelativeMouseMode(SDL_TRUE);
if (s_sdlInitialized) SDL_SetRelativeMouseMode(SDL_TRUE);
}
// Each tick we update the input state by polling SDL, this is where we get the kbd and mouse state.
// Each tick we update the input state by polling SDL, this is where we get the
// kbd and mouse state.
void C_4JInput::Tick() {
if (!s_sdlInitialized) return;
memcpy(s_keysPrev, s_keysCurrent, sizeof(s_keysCurrent));
s_mouseLeftPrev = s_mouseLeftCurrent;
s_mouseLeftPrev = s_mouseLeftCurrent;
s_mouseRightPrev = s_mouseRightCurrent;
s_snapTaken = false;
s_snapTaken = false;
s_scrollSnapTaken = false;
s_snapRelX = s_snapRelY = 0;
s_scrollTicksSnap = 0;
@ -137,14 +158,14 @@ void C_4JInput::Tick() {
s_scrollTicksForGetValue = 0;
}
const Uint8 *state = SDL_GetKeyboardState(NULL);
const Uint8* state = SDL_GetKeyboardState(NULL);
for (int i = 0; i < s_watchedKeyCount; ++i) {
int sc = s_watchedKeys[i];
if (sc > 0 && sc < KEY_COUNT) s_keysCurrent[sc] = state[sc] != 0;
}
Uint32 btns = SDL_GetMouseState(NULL, NULL);
s_mouseLeftCurrent = (btns & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
s_mouseLeftCurrent = (btns & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
s_mouseRightCurrent = (btns & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
if (!SDL_GetRelativeMouseMode()) {
@ -153,8 +174,11 @@ void C_4JInput::Tick() {
}
if (!SDL_GetKeyboardFocus()) {
SDL_Window *mf = SDL_GetMouseFocus();
if (mf) { SDL_RaiseWindow(mf); SDL_SetWindowGrab(mf, SDL_TRUE); }
SDL_Window* mf = SDL_GetMouseFocus();
if (mf) {
SDL_RaiseWindow(mf);
SDL_SetWindowGrab(mf, SDL_TRUE);
}
}
}
@ -164,9 +188,9 @@ int C_4JInput::GetHotbarSlotPressed(int iPad) {
constexpr size_t NUM_HOTBAR_SLOTS = 9;
static const int sc[NUM_HOTBAR_SLOTS] = {
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4,
SDL_SCANCODE_5, SDL_SCANCODE_6, SDL_SCANCODE_7, SDL_SCANCODE_8,
SDL_SCANCODE_9,
SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3,
SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6,
SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9,
};
static bool s_wasDown[NUM_HOTBAR_SLOTS] = {};
@ -179,31 +203,55 @@ int C_4JInput::GetHotbarSlotPressed(int iPad) {
return -1;
}
#define ACTION_CASES(FN) \
case ACTION_MENU_UP: return FN(SDL_SCANCODE_UP); \
case ACTION_MENU_DOWN: return FN(SDL_SCANCODE_DOWN); \
case ACTION_MENU_LEFT: return FN(SDL_SCANCODE_LEFT); \
case ACTION_MENU_RIGHT: return FN(SDL_SCANCODE_RIGHT); \
case ACTION_MENU_PAGEUP: return FN(SDL_SCANCODE_PAGEUP); \
case ACTION_MENU_PAGEDOWN: return FN(SDL_SCANCODE_PAGEDOWN); \
case ACTION_MENU_OK: return FN(SDL_SCANCODE_RETURN); \
case ACTION_MENU_CANCEL: return FN(SDL_SCANCODE_ESCAPE); \
case MINECRAFT_ACTION_JUMP: return FN(SDL_SCANCODE_SPACE); \
case MINECRAFT_ACTION_FORWARD: return FN(SDL_SCANCODE_W); \
case MINECRAFT_ACTION_BACKWARD: return FN(SDL_SCANCODE_S); \
case MINECRAFT_ACTION_LEFT: return FN(SDL_SCANCODE_A); \
case MINECRAFT_ACTION_RIGHT: return FN(SDL_SCANCODE_D); \
case MINECRAFT_ACTION_INVENTORY: return FN(SDL_SCANCODE_E); \
case MINECRAFT_ACTION_PAUSEMENU: return FN(SDL_SCANCODE_ESCAPE); \
case MINECRAFT_ACTION_DROP: return FN(SDL_SCANCODE_Q); \
case MINECRAFT_ACTION_CRAFTING: return FN(SDL_SCANCODE_C); \
case MINECRAFT_ACTION_RENDER_THIRD_PERSON:return FN(SDL_SCANCODE_F5); \
case MINECRAFT_ACTION_GAME_INFO: return FN(SDL_SCANCODE_F3); \
case MINECRAFT_ACTION_DPAD_LEFT: return FN(SDL_SCANCODE_LEFT); \
case MINECRAFT_ACTION_DPAD_RIGHT: return FN(SDL_SCANCODE_RIGHT); \
case MINECRAFT_ACTION_DPAD_UP: return FN(SDL_SCANCODE_UP); \
case MINECRAFT_ACTION_DPAD_DOWN: return FN(SDL_SCANCODE_DOWN); \
default: return false;
#define ACTION_CASES(FN) \
case ACTION_MENU_UP: \
return FN(SDL_SCANCODE_UP); \
case ACTION_MENU_DOWN: \
return FN(SDL_SCANCODE_DOWN); \
case ACTION_MENU_LEFT: \
return FN(SDL_SCANCODE_LEFT); \
case ACTION_MENU_RIGHT: \
return FN(SDL_SCANCODE_RIGHT); \
case ACTION_MENU_PAGEUP: \
return FN(SDL_SCANCODE_PAGEUP); \
case ACTION_MENU_PAGEDOWN: \
return FN(SDL_SCANCODE_PAGEDOWN); \
case ACTION_MENU_OK: \
return FN(SDL_SCANCODE_RETURN); \
case ACTION_MENU_CANCEL: \
return FN(SDL_SCANCODE_ESCAPE); \
case MINECRAFT_ACTION_JUMP: \
return FN(SDL_SCANCODE_SPACE); \
case MINECRAFT_ACTION_FORWARD: \
return FN(SDL_SCANCODE_W); \
case MINECRAFT_ACTION_BACKWARD: \
return FN(SDL_SCANCODE_S); \
case MINECRAFT_ACTION_LEFT: \
return FN(SDL_SCANCODE_A); \
case MINECRAFT_ACTION_RIGHT: \
return FN(SDL_SCANCODE_D); \
case MINECRAFT_ACTION_INVENTORY: \
return FN(SDL_SCANCODE_E); \
case MINECRAFT_ACTION_PAUSEMENU: \
return FN(SDL_SCANCODE_ESCAPE); \
case MINECRAFT_ACTION_DROP: \
return FN(SDL_SCANCODE_Q); \
case MINECRAFT_ACTION_CRAFTING: \
return FN(SDL_SCANCODE_C); \
case MINECRAFT_ACTION_RENDER_THIRD_PERSON: \
return FN(SDL_SCANCODE_F5); \
case MINECRAFT_ACTION_GAME_INFO: \
return FN(SDL_SCANCODE_F3); \
case MINECRAFT_ACTION_DPAD_LEFT: \
return FN(SDL_SCANCODE_LEFT); \
case MINECRAFT_ACTION_DPAD_RIGHT: \
return FN(SDL_SCANCODE_RIGHT); \
case MINECRAFT_ACTION_DPAD_UP: \
return FN(SDL_SCANCODE_UP); \
case MINECRAFT_ACTION_DPAD_DOWN: \
return FN(SDL_SCANCODE_DOWN); \
default: \
return false;
bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) {
if (iPad != 0) return false;
@ -213,45 +261,64 @@ bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) {
return s_mouseLeftCurrent || s_mouseRightCurrent;
}
switch (ucAction) {
case MINECRAFT_ACTION_ACTION: return MouseLDown() || KDown(SDL_SCANCODE_RETURN);
case MINECRAFT_ACTION_USE: return MouseRDown() || KDown(SDL_SCANCODE_F);
case MINECRAFT_ACTION_SNEAK_TOGGLE: return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT);
case MINECRAFT_ACTION_SPRINT: return KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL);
case MINECRAFT_ACTION_ACTION:
return MouseLDown() || KDown(SDL_SCANCODE_RETURN);
case MINECRAFT_ACTION_USE:
return MouseRDown() || KDown(SDL_SCANCODE_F);
case MINECRAFT_ACTION_SNEAK_TOGGLE:
return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT);
case MINECRAFT_ACTION_SPRINT:
return KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL);
case MINECRAFT_ACTION_LEFT_SCROLL:
case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0;
case ACTION_MENU_LEFT_SCROLL:
return ScrollSnap() > 0;
case MINECRAFT_ACTION_RIGHT_SCROLL:
case ACTION_MENU_RIGHT_SCROLL: return ScrollSnap() < 0;
ACTION_CASES(KDown)
case ACTION_MENU_RIGHT_SCROLL:
return ScrollSnap() < 0;
ACTION_CASES(KDown)
}
}
// The part that handles completing the action of pressing a button.
bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction) {
if (iPad != 0 || ucAction == 255) return false;
switch (ucAction) {
case MINECRAFT_ACTION_ACTION: return MouseLPressed() || KPressed(SDL_SCANCODE_RETURN);
case MINECRAFT_ACTION_USE: return MouseRPressed() || KPressed(SDL_SCANCODE_F);
case MINECRAFT_ACTION_SNEAK_TOGGLE: return KPressed(SDL_SCANCODE_LSHIFT) || KPressed(SDL_SCANCODE_RSHIFT);
case MINECRAFT_ACTION_SPRINT: return KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL);
case MINECRAFT_ACTION_ACTION:
return MouseLPressed() || KPressed(SDL_SCANCODE_RETURN);
case MINECRAFT_ACTION_USE:
return MouseRPressed() || KPressed(SDL_SCANCODE_F);
case MINECRAFT_ACTION_SNEAK_TOGGLE:
return KPressed(SDL_SCANCODE_LSHIFT) ||
KPressed(SDL_SCANCODE_RSHIFT);
case MINECRAFT_ACTION_SPRINT:
return KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL);
case MINECRAFT_ACTION_LEFT_SCROLL:
case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0;
case ACTION_MENU_LEFT_SCROLL:
return ScrollSnap() > 0;
case MINECRAFT_ACTION_RIGHT_SCROLL:
case ACTION_MENU_RIGHT_SCROLL: return ScrollSnap() < 0;
ACTION_CASES(KPressed)
case ACTION_MENU_RIGHT_SCROLL:
return ScrollSnap() < 0;
ACTION_CASES(KPressed)
}
}
// The part that handles Releasing a button.
bool C_4JInput::ButtonReleased(int iPad, unsigned char ucAction) {
if (iPad != 0 || ucAction == 255) return false;
switch (ucAction) {
case MINECRAFT_ACTION_ACTION: return MouseLReleased() || KReleased(SDL_SCANCODE_RETURN);
case MINECRAFT_ACTION_USE: return MouseRReleased() || KReleased(SDL_SCANCODE_F);
case MINECRAFT_ACTION_SNEAK_TOGGLE: return KReleased(SDL_SCANCODE_LSHIFT) || KReleased(SDL_SCANCODE_RSHIFT);
case MINECRAFT_ACTION_SPRINT: KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL);
case MINECRAFT_ACTION_ACTION:
return MouseLReleased() || KReleased(SDL_SCANCODE_RETURN);
case MINECRAFT_ACTION_USE:
return MouseRReleased() || KReleased(SDL_SCANCODE_F);
case MINECRAFT_ACTION_SNEAK_TOGGLE:
return KReleased(SDL_SCANCODE_LSHIFT) ||
KReleased(SDL_SCANCODE_RSHIFT);
case MINECRAFT_ACTION_SPRINT:
KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL);
case MINECRAFT_ACTION_LEFT_SCROLL:
case ACTION_MENU_LEFT_SCROLL:
case MINECRAFT_ACTION_RIGHT_SCROLL:
case ACTION_MENU_RIGHT_SCROLL: return false;
ACTION_CASES(KReleased)
case ACTION_MENU_RIGHT_SCROLL:
return false;
ACTION_CASES(KReleased)
}
}
@ -275,17 +342,20 @@ unsigned int C_4JInput::GetValue(int iPad, unsigned char ucAction, bool) {
}
return ButtonDown(iPad, ucAction) ? 1u : 0u;
}
// Left stick movement, the one that moves the player around or selects menu options. (Soon be tested.)
// Left stick movement, the one that moves the player around or selects menu
// options. (Soon be tested.)
float C_4JInput::GetJoypadStick_LX(int, bool) {
return (KDown(SDL_SCANCODE_D) ? 1.f : 0.f) - (KDown(SDL_SCANCODE_A) ? 1.f : 0.f);
return (KDown(SDL_SCANCODE_D) ? 1.f : 0.f) -
(KDown(SDL_SCANCODE_A) ? 1.f : 0.f);
}
float C_4JInput::GetJoypadStick_LY(int, bool) {
return (KDown(SDL_SCANCODE_W) ? 1.f : 0.f) - (KDown(SDL_SCANCODE_S) ? 1.f : 0.f);
return (KDown(SDL_SCANCODE_W) ? 1.f : 0.f) -
(KDown(SDL_SCANCODE_S) ? 1.f : 0.f);
}
// We use mouse movement and convert it into a Right Stick output using logarithmic scaling
// This is the most important mouse part. Yet it's so small.
// We use mouse movement and convert it into a Right Stick output using
// logarithmic scaling This is the most important mouse part. Yet it's so small.
static float MouseAxis(float raw) {
if (fabsf(raw) < 0.0001f) return 0.f; // from 4j previous code
if (fabsf(raw) < 0.0001f) return 0.f; // from 4j previous code
return (raw >= 0.f ? 1.f : -1.f) * sqrtf(fabsf(raw));
}
// We apply the Stick movement on the R(Right) X(2D Position)
@ -301,9 +371,14 @@ float C_4JInput::GetJoypadStick_RY(int, bool) {
return MouseAxis(-s_snapRelY * MOUSE_SCALE);
}
unsigned char C_4JInput::GetJoypadLTrigger(int, bool) { return s_mouseRightCurrent ? 255 : 0; }
unsigned char C_4JInput::GetJoypadRTrigger(int, bool) { return s_mouseLeftCurrent ? 255 : 0; }
// We detect if a Menu is visible on the player's screen to the mouse being stuck.
unsigned char C_4JInput::GetJoypadLTrigger(int, bool) {
return s_mouseRightCurrent ? 255 : 0;
}
unsigned char C_4JInput::GetJoypadRTrigger(int, bool) {
return s_mouseLeftCurrent ? 255 : 0;
}
// We detect if a Menu is visible on the player's screen to the mouse being
// stuck.
void C_4JInput::SetMenuDisplayed(int iPad, bool bVal) {
if (iPad >= 0 && iPad < 4) s_menuDisplayed[iPad] = bVal;
if (!s_sdlInitialized || bVal == s_prevMenuDisplayed) return;
@ -311,31 +386,43 @@ void C_4JInput::SetMenuDisplayed(int iPad, bool bVal) {
s_prevMenuDisplayed = bVal;
}
int C_4JInput::GetScrollDelta() {
int C_4JInput::GetScrollDelta() {
int v = s_scrollTicksForButtonPressed;
s_scrollTicksForButtonPressed = 0;
return v;
}
void C_4JInput::SetDeadzoneAndMovementRange(unsigned int, unsigned int){}
void C_4JInput::SetGameJoypadMaps(unsigned char, unsigned char, unsigned int){}
unsigned int C_4JInput::GetGameJoypadMaps(unsigned char, unsigned char){ return 0; }
void C_4JInput::SetJoypadMapVal(int, unsigned char){}
unsigned char C_4JInput::GetJoypadMapVal(int){ return 0; }
void C_4JInput::SetJoypadSensitivity(int, float){}
void C_4JInput::SetJoypadStickAxisMap(int, unsigned int, unsigned int){}
void C_4JInput::SetJoypadStickTriggerMap(int, unsigned int, unsigned int){}
void C_4JInput::SetKeyRepeatRate(float, float){}
void C_4JInput::SetDebugSequence(const char*, int(*)(void *), void *){}
FLOAT C_4JInput::GetIdleSeconds(int){ return 0.f; }
bool C_4JInput::IsPadConnected(int iPad){ return iPad == 0; }
void C_4JInput::SetDeadzoneAndMovementRange(unsigned int, unsigned int) {}
void C_4JInput::SetGameJoypadMaps(unsigned char, unsigned char, unsigned int) {}
unsigned int C_4JInput::GetGameJoypadMaps(unsigned char, unsigned char) {
return 0;
}
void C_4JInput::SetJoypadMapVal(int, unsigned char) {}
unsigned char C_4JInput::GetJoypadMapVal(int) { return 0; }
void C_4JInput::SetJoypadSensitivity(int, float) {}
void C_4JInput::SetJoypadStickAxisMap(int, unsigned int, unsigned int) {}
void C_4JInput::SetJoypadStickTriggerMap(int, unsigned int, unsigned int) {}
void C_4JInput::SetKeyRepeatRate(float, float) {}
void C_4JInput::SetDebugSequence(const char*, int (*)(void*), void*) {}
FLOAT C_4JInput::GetIdleSeconds(int) { return 0.f; }
bool C_4JInput::IsPadConnected(int iPad) { return iPad == 0; }
// Silly check, we check if we have a keyboard.
EKeyboardResult C_4JInput::RequestKeyboard(const wchar_t *, const wchar_t *, int, unsigned int,
int(*)(void *, const bool), void *, C_4JInput::EKeyboardMode)
{ return EKeyboard_Cancelled; }
EKeyboardResult C_4JInput::RequestKeyboard(const wchar_t*, const wchar_t*, int,
unsigned int,
int (*)(void*, const bool), void*,
C_4JInput::EKeyboardMode) {
return EKeyboard_Cancelled;
}
void C_4JInput::GetText(uint16_t *s){ if (s) s[0] = 0; }
bool C_4JInput::VerifyStrings(wchar_t **, int, int(*)(void *, STRING_VERIFY_RESPONSE *), void *){ return true; }
void C_4JInput::CancelQueuedVerifyStrings(int(*)(void *, STRING_VERIFY_RESPONSE *), void *){}
void C_4JInput::CancelAllVerifyInProgress(){}
void C_4JInput::GetText(uint16_t* s) {
if (s) s[0] = 0;
}
bool C_4JInput::VerifyStrings(wchar_t**, int,
int (*)(void*, STRING_VERIFY_RESPONSE*), void*) {
return true;
}
void C_4JInput::CancelQueuedVerifyStrings(int (*)(void*,
STRING_VERIFY_RESPONSE*),
void*) {}
void C_4JInput::CancelAllVerifyInProgress() {}

View file

@ -1,138 +1,163 @@
#pragma once
#define MAP_STYLE_0 0
#define MAP_STYLE_1 1
#define MAP_STYLE_2 2
#define MAP_STYLE_0 0
#define MAP_STYLE_1 1
#define MAP_STYLE_2 2
#define _360_JOY_BUTTON_A 0x00000001
#define _360_JOY_BUTTON_B 0x00000002
#define _360_JOY_BUTTON_X 0x00000004
#define _360_JOY_BUTTON_Y 0x00000008
#define _360_JOY_BUTTON_A 0x00000001
#define _360_JOY_BUTTON_B 0x00000002
#define _360_JOY_BUTTON_X 0x00000004
#define _360_JOY_BUTTON_Y 0x00000008
#define _360_JOY_BUTTON_START 0x00000010
#define _360_JOY_BUTTON_BACK 0x00000020
#define _360_JOY_BUTTON_RB 0x00000040
#define _360_JOY_BUTTON_LB 0x00000080
#define _360_JOY_BUTTON_START 0x00000010
#define _360_JOY_BUTTON_BACK 0x00000020
#define _360_JOY_BUTTON_RB 0x00000040
#define _360_JOY_BUTTON_LB 0x00000080
#define _360_JOY_BUTTON_RTHUMB 0x00000100
#define _360_JOY_BUTTON_LTHUMB 0x00000200
#define _360_JOY_BUTTON_DPAD_UP 0x00000400
#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800
#define _360_JOY_BUTTON_RTHUMB 0x00000100
#define _360_JOY_BUTTON_LTHUMB 0x00000200
#define _360_JOY_BUTTON_DPAD_UP 0x00000400
#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800
#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000
#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000
// fake digital versions of analog values
#define _360_JOY_BUTTON_LSTICK_RIGHT 0x00004000
#define _360_JOY_BUTTON_LSTICK_LEFT 0x00008000
#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000
#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000
// fake digital versions of analog values
#define _360_JOY_BUTTON_LSTICK_RIGHT 0x00004000
#define _360_JOY_BUTTON_LSTICK_LEFT 0x00008000
#define _360_JOY_BUTTON_RSTICK_DOWN 0x00010000
#define _360_JOY_BUTTON_RSTICK_UP 0x00020000
#define _360_JOY_BUTTON_RSTICK_RIGHT 0x00040000
#define _360_JOY_BUTTON_RSTICK_LEFT 0x00080000
#define _360_JOY_BUTTON_RSTICK_DOWN 0x00010000
#define _360_JOY_BUTTON_RSTICK_UP 0x00020000
#define _360_JOY_BUTTON_RSTICK_RIGHT 0x00040000
#define _360_JOY_BUTTON_RSTICK_LEFT 0x00080000
#define _360_JOY_BUTTON_LSTICK_DOWN 0x00100000
#define _360_JOY_BUTTON_LSTICK_UP 0x00200000
#define _360_JOY_BUTTON_RT 0x00400000
#define _360_JOY_BUTTON_LT 0x00800000
#define _360_JOY_BUTTON_LSTICK_DOWN 0x00100000
#define _360_JOY_BUTTON_LSTICK_UP 0x00200000
#define _360_JOY_BUTTON_RT 0x00400000
#define _360_JOY_BUTTON_LT 0x00800000
// Stick axis maps - to allow changes for SouthPaw in-game axis mapping
#define AXIS_MAP_LX 0
#define AXIS_MAP_LY 1
#define AXIS_MAP_RX 2
#define AXIS_MAP_RY 3
#define AXIS_MAP_LX 0
#define AXIS_MAP_LY 1
#define AXIS_MAP_RX 2
#define AXIS_MAP_RY 3
// Trigger map - to allow for swap triggers in-game
#define TRIGGER_MAP_0 0
#define TRIGGER_MAP_1 1
#define TRIGGER_MAP_0 0
#define TRIGGER_MAP_1 1
enum EKeyboardResult
{
EKeyboard_Pending,
EKeyboard_Cancelled,
EKeyboard_ResultAccept,
EKeyboard_ResultDecline,
enum EKeyboardResult {
EKeyboard_Pending,
EKeyboard_Cancelled,
EKeyboard_ResultAccept,
EKeyboard_ResultDecline,
};
typedef struct _STRING_VERIFY_RESPONSE
{
WORD wNumStrings;
HRESULT *pStringResult;
}
STRING_VERIFY_RESPONSE;
typedef struct _STRING_VERIFY_RESPONSE {
WORD wNumStrings;
HRESULT* pStringResult;
} STRING_VERIFY_RESPONSE;
class C_4JInput
{
class C_4JInput {
public:
enum EKeyboardMode {
EKeyboardMode_Default,
EKeyboardMode_Numeric,
EKeyboardMode_Password,
EKeyboardMode_Alphabet,
EKeyboardMode_Full,
EKeyboardMode_Alphabet_Extended,
EKeyboardMode_IP_Address,
EKeyboardMode_Phone
};
void Initialise(int iInputStateC, unsigned char ucMapC,
unsigned char ucActionC, unsigned char ucMenuActionC);
void Tick(void);
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone,
unsigned int uiMovementRangeMax);
void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction,
unsigned int uiActionVal);
unsigned int GetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction);
void SetJoypadMapVal(int iPad, unsigned char ucMap);
unsigned char GetJoypadMapVal(int iPad);
void SetJoypadSensitivity(int iPad, float fSensitivity);
unsigned int GetValue(int iPad, unsigned char ucAction,
bool bRepeat = false);
bool ButtonPressed(int iPad, unsigned char ucAction = 255); // toggled
bool ButtonReleased(int iPad, unsigned char ucAction); // toggled
bool ButtonDown(int iPad,
unsigned char ucAction = 255); // button held down
// Functions to remap the axis and triggers for in-game (not menus) -
// SouthPaw, etc
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom,
unsigned int uiTo);
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom,
unsigned int uiTo);
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
void SetDebugSequence(const char* chSequenceA, int (*Func)(void*),
void* lpParam);
FLOAT GetIdleSeconds(int iPad);
bool IsPadConnected(int iPad);
enum EKeyboardMode
{
EKeyboardMode_Default,
EKeyboardMode_Numeric,
EKeyboardMode_Password,
EKeyboardMode_Alphabet,
EKeyboardMode_Full,
EKeyboardMode_Alphabet_Extended,
EKeyboardMode_IP_Address,
EKeyboardMode_Phone
};
// In-Game values which may have been remapped due to Southpaw, swap
// triggers, etc
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay = true);
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay = true);
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay = true);
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay = true);
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay = true);
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay = true);
void Initialise( int iInputStateC, unsigned char ucMapC,unsigned char ucActionC, unsigned char ucMenuActionC );
void Tick(void);
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, unsigned int uiMovementRangeMax );
void SetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction,unsigned int uiActionVal);
unsigned int GetGameJoypadMaps(unsigned char ucMap,unsigned char ucAction);
void SetJoypadMapVal(int iPad,unsigned char ucMap);
unsigned char GetJoypadMapVal(int iPad);
void SetJoypadSensitivity(int iPad, float fSensitivity);
unsigned int GetValue(int iPad,unsigned char ucAction, bool bRepeat=false);
bool ButtonPressed(int iPad,unsigned char ucAction=255); // toggled
bool ButtonReleased(int iPad,unsigned char ucAction); //toggled
bool ButtonDown(int iPad,unsigned char ucAction=255); // button held down
// Functions to remap the axis and triggers for in-game (not menus) - SouthPaw, etc
void SetJoypadStickAxisMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
void SetJoypadStickTriggerMap(int iPad,unsigned int uiFrom, unsigned int uiTo);
void SetKeyRepeatRate(float fRepeatDelaySecs,float fRepeatRateSecs);
void SetDebugSequence( const char *chSequenceA,int( *Func)(void *),void *lpParam );
FLOAT GetIdleSeconds(int iPad);
bool IsPadConnected(int iPad);
void SetMenuDisplayed(int iPad, bool bVal);
int GetHotbarSlotPressed(int iPad);
int GetScrollDelta();
// In-Game values which may have been remapped due to Southpaw, swap triggers, etc
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true);
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true);
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay=true);
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay=true);
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay=true);
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay=true);
// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT
// uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int(
// *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode
// eMode,C4JStringTable *pStringTable=NULL); EKeyboardResult
// RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD
// dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const
// bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable
// *pStringTable=NULL);
EKeyboardResult RequestKeyboard(const wchar_t* Title, const wchar_t* Text,
int iPad, unsigned int uiMaxChars,
int (*Func)(void*, const bool),
void* lpParam,
C_4JInput::EKeyboardMode eMode);
void GetText(uint16_t* UTF16String);
void SetMenuDisplayed(int iPad, bool bVal);
int GetHotbarSlotPressed(int iPad);
int GetScrollDelta();
// Online check strings against offensive list - TCR 92
// TCR # 092 CMTV Player Text String Verification
// Requirement Any player-entered text visible to another player on
// Xbox LIVE must be verified using the Xbox LIVE service before being
// transmitted. Text that is rejected by the Xbox LIVE service must not be
// displayed.
//
// Remarks
// This requirement applies to any player-entered string that can
// be exposed to other players on Xbox LIVE. It includes session names,
// content descriptions, text messages, tags, team names, mottos, comments,
// and so on.
//
// Games may decide to not send the text, blank it out, or use
// generic text if the text was rejected by the Xbox LIVE service.
//
// Games verify the text by calling the XStringVerify function.
//
// Exemption It is not required to use the Xbox LIVE service to
// verify real-time text communication. An example of real-time text
// communication is in-game text chat.
//
// Intent Protect players from inappropriate language.
bool VerifyStrings(wchar_t** pwStringA, int iStringC,
int (*Func)(void*, STRING_VERIFY_RESPONSE*),
void* lpParam);
void CancelQueuedVerifyStrings(int (*Func)(void*, STRING_VERIFY_RESPONSE*),
void* lpParam);
void CancelAllVerifyInProgress(void);
// EKeyboardResult RequestKeyboard(UINT uiTitle, UINT uiText, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam,EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
// EKeyboardResult RequestKeyboard(UINT uiTitle, LPCWSTR pwchDefault, UINT uiDesc, DWORD dwPad, WCHAR *pwchResult, UINT uiResultSize,int( *Func)(LPVOID,const bool),LPVOID lpParam, EKeyboardMode eMode,C4JStringTable *pStringTable=NULL);
EKeyboardResult RequestKeyboard(const wchar_t *Title, const wchar_t *Text, int iPad, unsigned int uiMaxChars, int( *Func)(void *,const bool), void *lpParam, C_4JInput::EKeyboardMode eMode);
void GetText(uint16_t *UTF16String);
// Online check strings against offensive list - TCR 92
// TCR # 092 CMTV Player Text String Verification
// Requirement Any player-entered text visible to another player on Xbox LIVE must be verified using the Xbox LIVE service before being transmitted. Text that is rejected by the Xbox LIVE service must not be displayed.
//
// Remarks
// This requirement applies to any player-entered string that can be exposed to other players on Xbox LIVE. It includes session names, content descriptions, text messages, tags, team names, mottos, comments, and so on.
//
// Games may decide to not send the text, blank it out, or use generic text if the text was rejected by the Xbox LIVE service.
//
// Games verify the text by calling the XStringVerify function.
//
// Exemption It is not required to use the Xbox LIVE service to verify real-time text communication. An example of real-time text communication is in-game text chat.
//
// Intent Protect players from inappropriate language.
bool VerifyStrings(wchar_t **pwStringA,int iStringC,int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam);
void CancelQueuedVerifyStrings(int( *Func)(void *,STRING_VERIFY_RESPONSE *),void *lpParam);
void CancelAllVerifyInProgress(void);
//bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput);
// bool InputDetected(DWORD dwUserIndex,WCHAR *pwchInput);
};
// Singleton

View file

@ -5,4 +5,4 @@
#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h"
#endif
#endif //_4J_INPUT_STADAFX_H
#endif //_4J_INPUT_STADAFX_H

View file

@ -3,48 +3,85 @@
C_4JProfile ProfileManager;
static void *s_profileData[4] = {};
static void* s_profileData[4] = {};
void C_4JProfile::Initialise(DWORD dwTitleID, DWORD dwOfferID, unsigned short usProfileVersion,
UINT uiProfileValuesC, UINT uiProfileSettingsC, DWORD *pdwProfileSettingsA,
int iGameDefinedDataSizeX4, unsigned int *puiGameDefinedDataChangedBitmask)
{
for (int i = 0; i < 4; i++)
{
void C_4JProfile::Initialise(DWORD dwTitleID, DWORD dwOfferID,
unsigned short usProfileVersion,
UINT uiProfileValuesC, UINT uiProfileSettingsC,
DWORD* pdwProfileSettingsA,
int iGameDefinedDataSizeX4,
unsigned int* puiGameDefinedDataChangedBitmask) {
for (int i = 0; i < 4; i++) {
s_profileData[i] = new unsigned char[iGameDefinedDataSizeX4 / 4];
memset(s_profileData[i], 0, iGameDefinedDataSizeX4 / 4);
}
}
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable *pStringTable, int iAccept, int iReject) {}
void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle, int iText) {}
void C_4JProfile::SetTrialTextStringTable(CXuiStringTable* pStringTable,
int iAccept, int iReject) {}
void C_4JProfile::SetTrialAwardText(eAwardType AwardType, int iTitle,
int iText) {}
int C_4JProfile::GetLockedProfile() { return -1; }
void C_4JProfile::SetLockedProfile(int iProf) {}
bool C_4JProfile::IsSignedIn(int iQuadrant) { return iQuadrant == 0; }
bool C_4JProfile::IsSignedInLive(int iProf) { return false; }
bool C_4JProfile::IsGuest(int iQuadrant) { return false; }
UINT C_4JProfile::RequestSignInUI(bool bFromInvite, bool bLocalGame, bool bNoGuestsAllowed, bool bMultiplayerSignIn, bool bAddUser, int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; }
UINT C_4JProfile::DisplayOfflineProfile(int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; }
UINT C_4JProfile::RequestConvertOfflineToGuestUI(int(*Func)(void *, const bool, const int iPad), void *lpParam, int iQuadrant) { return 0; }
UINT C_4JProfile::RequestSignInUI(bool bFromInvite, bool bLocalGame,
bool bNoGuestsAllowed,
bool bMultiplayerSignIn, bool bAddUser,
int (*Func)(void*, const bool,
const int iPad),
void* lpParam, int iQuadrant) {
return 0;
}
UINT C_4JProfile::DisplayOfflineProfile(int (*Func)(void*, const bool,
const int iPad),
void* lpParam, int iQuadrant) {
return 0;
}
UINT C_4JProfile::RequestConvertOfflineToGuestUI(int (*Func)(void*, const bool,
const int iPad),
void* lpParam, int iQuadrant) {
return 0;
}
void C_4JProfile::SetPrimaryPlayerChanged(bool bVal) {}
bool C_4JProfile::QuerySigninStatus(void) { return true; }
void C_4JProfile::GetXUID(int iPad, PlayerUID *pXuid, bool bOnlineXuid) { if (pXuid) *pXuid = 0; }
bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) { return xuid1 == xuid2; }
void C_4JProfile::GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) {
if (pXuid) *pXuid = 0;
}
bool C_4JProfile::AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2) {
return xuid1 == xuid2;
}
bool C_4JProfile::XUIDIsGuest(PlayerUID xuid) { return false; }
bool C_4JProfile::AllowedToPlayMultiplayer(int iProf) { return true; }
bool C_4JProfile::GetChatAndContentRestrictions(int iPad, bool *pbChatRestricted, bool *pbContentRestricted, int *piAge) {
bool C_4JProfile::GetChatAndContentRestrictions(int iPad,
bool* pbChatRestricted,
bool* pbContentRestricted,
int* piAge) {
if (pbChatRestricted) *pbChatRestricted = false;
if (pbContentRestricted) *pbContentRestricted = false;
if (piAge) *piAge = 18;
return true;
}
void C_4JProfile::StartTrialGame() {}
void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool *allAllowed, bool *friendsAllowed) {
void C_4JProfile::AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
bool* allAllowed,
bool* friendsAllowed) {
if (allAllowed) *allAllowed = true;
if (friendsAllowed) *friendsAllowed = true;
}
bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount) { return true; }
bool C_4JProfile::CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
PPlayerUID pXuids,
unsigned int xuidCount) {
return true;
}
void C_4JProfile::ShowProfileCard(int iPad, PlayerUID targetUid) {}
bool C_4JProfile::GetProfileAvatar(int iPad, int(*Func)(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes), void *lpParam) { return false; }
bool C_4JProfile::GetProfileAvatar(int iPad,
int (*Func)(void* lpParam,
std::uint8_t* thumbnailData,
unsigned int thumbnailBytes),
void* lpParam) {
return false;
}
void C_4JProfile::CancelProfileAvatarRequest() {}
int C_4JProfile::GetPrimaryPad() { return 0; }
void C_4JProfile::SetPrimaryPad(int iPad) {}
@ -53,34 +90,68 @@ static char s_gamertag[64] = "Player";
char* C_4JProfile::GetGamertag(int iPad) { return s_gamertag; }
std::wstring C_4JProfile::GetDisplayName(int iPad) { return L"Player"; }
bool C_4JProfile::IsFullVersion() { return true; }
void C_4JProfile::SetSignInChangeCallback(void(*Func)(void *, bool, unsigned int), void *lpParam) {}
void C_4JProfile::SetNotificationsCallback(void(*Func)(void *, std::uint32_t, unsigned int), void *lpParam) {}
void C_4JProfile::SetSignInChangeCallback(void (*Func)(void*, bool,
unsigned int),
void* lpParam) {}
void C_4JProfile::SetNotificationsCallback(void (*Func)(void*, std::uint32_t,
unsigned int),
void* lpParam) {}
bool C_4JProfile::RegionIsNorthAmerica(void) { return true; }
bool C_4JProfile::LocaleIsUSorCanada(void) { return true; }
HRESULT C_4JProfile::GetLiveConnectionStatus() { return S_OK; }
bool C_4JProfile::IsSystemUIDisplayed() { return false; }
void C_4JProfile::SetProfileReadErrorCallback(void(*Func)(void *), void *lpParam) {}
int C_4JProfile::SetDefaultOptionsCallback(int(*Func)(void *, PROFILESETTINGS *, const int iPad), void *lpParam) { return 0; }
int C_4JProfile::SetOldProfileVersionCallback(int(*Func)(void *, unsigned char *, const unsigned short, const int), void *lpParam) { return 0; }
void C_4JProfile::SetProfileReadErrorCallback(void (*Func)(void*),
void* lpParam) {}
int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
const int iPad),
void* lpParam) {
return 0;
}
int C_4JProfile::SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*,
const unsigned short,
const int),
void* lpParam) {
return 0;
}
static C_4JProfile::PROFILESETTINGS s_defaultSettings = {};
C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(int iPad) { return &s_defaultSettings; }
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged, bool bOverride5MinuteLimitOnProfileWrites) {}
C_4JProfile::PROFILESETTINGS* C_4JProfile::GetDashboardProfileSettings(
int iPad) {
return &s_defaultSettings;
}
void C_4JProfile::WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged,
bool bOverride5MinuteLimitOnProfileWrites) {}
void C_4JProfile::ForceQueuedProfileWrites(int iPad) {}
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) { return s_profileData[iQuadrant]; }
void* C_4JProfile::GetGameDefinedProfileData(int iQuadrant) {
return s_profileData[iQuadrant];
}
void C_4JProfile::ResetProfileProcessState() {}
void C_4JProfile::Tick(void) {}
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected,
CXuiStringTable *pStringTable, int iTitleStr, int iTextStr, int iAcceptStr, char *pszThemeName, unsigned int uiThemeSize) {}
void C_4JProfile::RegisterAward(int iAwardNumber, int iGamerconfigID,
eAwardType eType, bool bLeaderboardAffected,
CXuiStringTable* pStringTable, int iTitleStr,
int iTextStr, int iAcceptStr,
char* pszThemeName, unsigned int uiThemeSize) {}
int C_4JProfile::GetAwardId(int iAwardNumber) { return 0; }
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) { return eAwardType_Achievement; }
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) { return false; }
eAwardType C_4JProfile::GetAwardType(int iAwardNumber) {
return eAwardType_Achievement;
}
bool C_4JProfile::CanBeAwarded(int iQuadrant, int iAwardNumber) {
return false;
}
void C_4JProfile::Award(int iQuadrant, int iAwardNumber, bool bForce) {}
bool C_4JProfile::IsAwardsFlagSet(int iQuadrant, int iAward) { return false; }
void C_4JProfile::RichPresenceInit(int iPresenceCount, int iContextCount) {}
void C_4JProfile::RegisterRichPresenceContext(int iGameConfigContextID) {}
void C_4JProfile::SetRichPresenceContextValue(int iPad, int iContextID, int iVal) {}
void C_4JProfile::SetCurrentGameActivity(int iPad, int iNewPresence, bool bSetOthersToIdle) {}
void C_4JProfile::DisplayFullVersionPurchase(bool bRequired, int iQuadrant, int iUpsellParam) {}
void C_4JProfile::SetUpsellCallback(void(*Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData), void *lpParam) {}
void C_4JProfile::SetRichPresenceContextValue(int iPad, int iContextID,
int iVal) {}
void C_4JProfile::SetCurrentGameActivity(int iPad, int iNewPresence,
bool bSetOthersToIdle) {}
void C_4JProfile::DisplayFullVersionPurchase(bool bRequired, int iQuadrant,
int iUpsellParam) {}
void C_4JProfile::SetUpsellCallback(void (*Func)(void* lpParam,
eUpsellType type,
eUpsellResponse response,
int iUserData),
void* lpParam) {}
void C_4JProfile::SetDebugFullOverride(bool bVal) {}

View file

@ -2,129 +2,156 @@
#include <cstdint>
enum eAwardType
{
eAwardType_Achievement = 0,
eAwardType_GamerPic,
eAwardType_Theme,
eAwardType_AvatarItem,
enum eAwardType {
eAwardType_Achievement = 0,
eAwardType_GamerPic,
eAwardType_Theme,
eAwardType_AvatarItem,
};
enum eUpsellType
{
eUpsellType_Custom = 0, // This is the default, and means that the upsell dialog was initiated in the app code
eUpsellType_Achievement,
eUpsellType_GamerPic,
eUpsellType_Theme,
eUpsellType_AvatarItem,
enum eUpsellType {
eUpsellType_Custom = 0, // This is the default, and means that the upsell
// dialog was initiated in the app code
eUpsellType_Achievement,
eUpsellType_GamerPic,
eUpsellType_Theme,
eUpsellType_AvatarItem,
};
enum eUpsellResponse
{
eUpsellResponse_Declined,
eUpsellResponse_Accepted_NoPurchase,
eUpsellResponse_Accepted_Purchase,
enum eUpsellResponse {
eUpsellResponse_Declined,
eUpsellResponse_Accepted_NoPurchase,
eUpsellResponse_Accepted_Purchase,
};
class C_4JProfile
{
class C_4JProfile {
public:
struct PROFILESETTINGS
{
int iYAxisInversion;
int iControllerSensitivity;
int iVibration;
bool bSwapSticks;
};
struct PROFILESETTINGS {
int iYAxisInversion;
int iControllerSensitivity;
int iVibration;
bool bSwapSticks;
};
// 4 players have game defined data, puiGameDefinedDataChangedBitmask needs
// to be checked by the game side to see if there's an update needed - it'll
// have the bits set for players to be updated
void Initialise(DWORD dwTitleID, DWORD dwOfferID,
unsigned short usProfileVersion, UINT uiProfileValuesC,
UINT uiProfileSettingsC, DWORD* pdwProfileSettingsA,
int iGameDefinedDataSizeX4,
unsigned int* puiGameDefinedDataChangedBitmask);
void SetTrialTextStringTable(CXuiStringTable* pStringTable, int iAccept,
int iReject);
void SetTrialAwardText(eAwardType AwardType, int iTitle,
int iText); // achievement popup in the trial game
int GetLockedProfile();
void SetLockedProfile(int iProf);
bool IsSignedIn(int iQuadrant);
bool IsSignedInLive(int iProf);
bool IsGuest(int iQuadrant);
UINT RequestSignInUI(bool bFromInvite, bool bLocalGame,
bool bNoGuestsAllowed, bool bMultiplayerSignIn,
bool bAddUser,
int (*Func)(void*, const bool, const int iPad),
void* lpParam, int iQuadrant = XUSER_INDEX_ANY);
UINT DisplayOfflineProfile(int (*Func)(void*, const bool, const int iPad),
void* lpParam, int iQuadrant = XUSER_INDEX_ANY);
UINT RequestConvertOfflineToGuestUI(int (*Func)(void*, const bool,
const int iPad),
void* lpParam,
int iQuadrant = XUSER_INDEX_ANY);
void SetPrimaryPlayerChanged(bool bVal);
bool QuerySigninStatus(void);
void GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid);
bool AreXUIDSEqual(PlayerUID xuid1, PlayerUID xuid2);
bool XUIDIsGuest(PlayerUID xuid);
bool AllowedToPlayMultiplayer(int iProf);
bool GetChatAndContentRestrictions(int iPad, bool* pbChatRestricted,
bool* pbContentRestricted, int* piAge);
void StartTrialGame(); // disables saves and leaderboard, and change state
// to readyforgame from pregame
void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
bool* allAllowed, bool* friendsAllowed);
bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly,
PPlayerUID pXuids, unsigned int xuidCount);
void ShowProfileCard(int iPad, PlayerUID targetUid);
bool GetProfileAvatar(int iPad,
int (*Func)(void* lpParam,
std::uint8_t* thumbnailData,
unsigned int thumbnailBytes),
void* lpParam);
void CancelProfileAvatarRequest();
// 4 players have game defined data, puiGameDefinedDataChangedBitmask needs to be checked by the game side to see if there's an update needed - it'll have the bits set for players to be updated
void Initialise( DWORD dwTitleID,
DWORD dwOfferID,
unsigned short usProfileVersion,
UINT uiProfileValuesC,
UINT uiProfileSettingsC,
DWORD *pdwProfileSettingsA,
int iGameDefinedDataSizeX4,
unsigned int *puiGameDefinedDataChangedBitmask);
void SetTrialTextStringTable(CXuiStringTable *pStringTable,int iAccept,int iReject);
void SetTrialAwardText(eAwardType AwardType,int iTitle,int iText); // achievement popup in the trial game
int GetLockedProfile();
void SetLockedProfile(int iProf);
bool IsSignedIn(int iQuadrant);
bool IsSignedInLive(int iProf);
bool IsGuest(int iQuadrant);
UINT RequestSignInUI(bool bFromInvite,bool bLocalGame,bool bNoGuestsAllowed,bool bMultiplayerSignIn,bool bAddUser, int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY);
UINT DisplayOfflineProfile(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY);
UINT RequestConvertOfflineToGuestUI(int( *Func)(void *,const bool, const int iPad),void *lpParam,int iQuadrant=XUSER_INDEX_ANY);
void SetPrimaryPlayerChanged(bool bVal);
bool QuerySigninStatus(void);
void GetXUID(int iPad, PlayerUID *pXuid,bool bOnlineXuid);
bool AreXUIDSEqual(PlayerUID xuid1,PlayerUID xuid2);
bool XUIDIsGuest(PlayerUID xuid);
bool AllowedToPlayMultiplayer(int iProf);
bool GetChatAndContentRestrictions(int iPad,bool *pbChatRestricted,bool *pbContentRestricted,int *piAge);
void StartTrialGame(); // disables saves and leaderboard, and change state to readyforgame from pregame
void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, bool *allAllowed, bool *friendsAllowed);
bool CanViewPlayerCreatedContent(int iPad, bool thisQuadrantOnly, PPlayerUID pXuids, unsigned int xuidCount);
void ShowProfileCard(int iPad, PlayerUID targetUid);
bool GetProfileAvatar(int iPad,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *lpParam);
void CancelProfileAvatarRequest();
// SYS
int GetPrimaryPad();
void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad);
std::wstring GetDisplayName(int iPad);
bool IsFullVersion();
void SetSignInChangeCallback(void (*Func)(void*, bool, unsigned int),
void* lpParam);
void SetNotificationsCallback(void (*Func)(void*, std::uint32_t,
unsigned int),
void* lpParam);
bool RegionIsNorthAmerica(void);
bool LocaleIsUSorCanada(void);
HRESULT GetLiveConnectionStatus();
bool IsSystemUIDisplayed();
void SetProfileReadErrorCallback(void (*Func)(void*), void* lpParam);
// SYS
int GetPrimaryPad();
void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad);
std::wstring GetDisplayName(int iPad);
bool IsFullVersion();
void SetSignInChangeCallback(void ( *Func)(void *, bool, unsigned int),void *lpParam);
void SetNotificationsCallback(void ( *Func)(void *, std::uint32_t, unsigned int),void *lpParam);
bool RegionIsNorthAmerica(void);
bool LocaleIsUSorCanada(void);
HRESULT GetLiveConnectionStatus();
bool IsSystemUIDisplayed();
void SetProfileReadErrorCallback(void ( *Func)(void *), void *lpParam);
// PROFILE DATA
int SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
const int iPad),
void* lpParam);
int SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*,
const unsigned short,
const int),
void* lpParam);
PROFILESETTINGS* GetDashboardProfileSettings(int iPad);
void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged = false,
bool bOverride5MinuteLimitOnProfileWrites = false);
void ForceQueuedProfileWrites(int iPad = XUSER_INDEX_ANY);
void* GetGameDefinedProfileData(int iQuadrant);
void ResetProfileProcessState(); // after a sign out from the primary
// player, call this
void Tick(void);
// ACHIEVEMENTS & AWARDS
// PROFILE DATA
int SetDefaultOptionsCallback(int( *Func)(void *,PROFILESETTINGS *, const int iPad),void *lpParam);
int SetOldProfileVersionCallback(int( *Func)(void *,unsigned char *, const unsigned short,const int),void *lpParam);
PROFILESETTINGS * GetDashboardProfileSettings(int iPad);
void WriteToProfile(int iQuadrant, bool bGameDefinedDataChanged=false, bool bOverride5MinuteLimitOnProfileWrites=false);
void ForceQueuedProfileWrites(int iPad=XUSER_INDEX_ANY);
void *GetGameDefinedProfileData(int iQuadrant);
void ResetProfileProcessState(); // after a sign out from the primary player, call this
void Tick( void );
void RegisterAward(int iAwardNumber, int iGamerconfigID, eAwardType eType,
bool bLeaderboardAffected = false,
CXuiStringTable* pStringTable = NULL, int iTitleStr = -1,
int iTextStr = -1, int iAcceptStr = -1,
char* pszThemeName = NULL,
unsigned int uiThemeSize = 0L);
int GetAwardId(int iAwardNumber);
eAwardType GetAwardType(int iAwardNumber);
bool CanBeAwarded(int iQuadrant, int iAwardNumber);
void Award(int iQuadrant, int iAwardNumber, bool bForce = false);
bool IsAwardsFlagSet(int iQuadrant, int iAward);
// ACHIEVEMENTS & AWARDS
// RICH PRESENCE
void RegisterAward(int iAwardNumber,int iGamerconfigID, eAwardType eType, bool bLeaderboardAffected=false,
CXuiStringTable*pStringTable=NULL, int iTitleStr=-1, int iTextStr=-1, int iAcceptStr=-1, char *pszThemeName=NULL, unsigned int uiThemeSize=0L);
int GetAwardId(int iAwardNumber);
eAwardType GetAwardType(int iAwardNumber);
bool CanBeAwarded(int iQuadrant, int iAwardNumber);
void Award(int iQuadrant, int iAwardNumber, bool bForce=false);
bool IsAwardsFlagSet(int iQuadrant, int iAward);
void RichPresenceInit(int iPresenceCount, int iContextCount);
void RegisterRichPresenceContext(int iGameConfigContextID);
void SetRichPresenceContextValue(int iPad, int iContextID, int iVal);
void SetCurrentGameActivity(int iPad, int iNewPresence,
bool bSetOthersToIdle = false);
// RICH PRESENCE
void RichPresenceInit(int iPresenceCount, int iContextCount);
void RegisterRichPresenceContext(int iGameConfigContextID);
void SetRichPresenceContextValue(int iPad,int iContextID, int iVal);
void SetCurrentGameActivity(int iPad,int iNewPresence, bool bSetOthersToIdle=false);
// PURCHASE
void DisplayFullVersionPurchase(bool bRequired, int iQuadrant, int iUpsellParam = -1);
void SetUpsellCallback(void ( *Func)(void *lpParam, eUpsellType type, eUpsellResponse response, int iUserData),void *lpParam);
// Debug
void SetDebugFullOverride(bool bVal); // To override the license version (trail/full). Only in debug/release, not ContentPackage
// PURCHASE
void DisplayFullVersionPurchase(bool bRequired, int iQuadrant,
int iUpsellParam = -1);
void SetUpsellCallback(void (*Func)(void* lpParam, eUpsellType type,
eUpsellResponse response,
int iUserData),
void* lpParam);
// Debug
void SetDebugFullOverride(
bool bVal); // To override the license version (trail/full). Only in
// debug/release, not ContentPackage
};
// Singleton
extern C_4JProfile ProfileManager;

View file

@ -1,11 +1,10 @@
#ifndef _4J_PROFILE_STADAFX_H
#define _4J_PROFILE_STADAFX_H
#ifdef __linux__
#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h"
#endif
#include "../Minecraft.World/Platform/x64headers/extraX64.h"
#endif //_4J_PROFILE_STADAFX_H
#endif //_4J_PROFILE_STADAFX_H

File diff suppressed because it is too large Load diff

View file

@ -6,218 +6,230 @@
#include <cstdint>
class ImageFileBuffer
{
class ImageFileBuffer {
public:
enum EImageType
{
e_typePNG,
e_typeJPG
};
enum EImageType { e_typePNG, e_typeJPG };
EImageType m_type;
void* m_pBuffer;
int m_bufferSize;
EImageType m_type;
void* m_pBuffer;
int m_bufferSize;
int GetType() { return m_type; }
void *GetBufferPointer() { return m_pBuffer; }
int GetBufferSize() { return m_bufferSize; }
void Release() { free(m_pBuffer); m_pBuffer = NULL; }
bool Allocated() { return m_pBuffer != NULL; }
int GetType() { return m_type; }
void* GetBufferPointer() { return m_pBuffer; }
int GetBufferSize() { return m_bufferSize; }
void Release() {
free(m_pBuffer);
m_pBuffer = NULL;
}
bool Allocated() { return m_pBuffer != NULL; }
};
typedef struct
{
int Width;
int Height;
}D3DXIMAGE_INFO;
typedef struct {
int Width;
int Height;
} D3DXIMAGE_INFO;
typedef struct _XSOCIAL_PREVIEWIMAGE {
BYTE *pBytes;
BYTE* pBytes;
DWORD Pitch;
DWORD Width;
DWORD Height;
// D3DFORMAT Format;
// D3DFORMAT Format;
} XSOCIAL_PREVIEWIMAGE, *PXSOCIAL_PREVIEWIMAGE;
class C4JRender
{
class C4JRender {
public:
void Tick();
void UpdateGamma(unsigned short usGamma);
void Tick();
void UpdateGamma(unsigned short usGamma);
// Matrix stack
void MatrixMode(int type);
void MatrixSetIdentity();
void MatrixTranslate(float x,float y,float z);
void MatrixRotate(float angle, float x, float y, float z);
void MatrixScale(float x, float y, float z);
void MatrixPerspective(float fovy, float aspect, float zNear, float zFar);
void MatrixOrthogonal(float left,float right,float bottom,float top,float zNear,float zFar);
void MatrixPop();
void MatrixPush();
void MatrixMult(float *mat);
const float *MatrixGet(int type);
void Set_matrixDirty();
// Matrix stack
void MatrixMode(int type);
void MatrixSetIdentity();
void MatrixTranslate(float x, float y, float z);
void MatrixRotate(float angle, float x, float y, float z);
void MatrixScale(float x, float y, float z);
void MatrixPerspective(float fovy, float aspect, float zNear, float zFar);
void MatrixOrthogonal(float left, float right, float bottom, float top,
float zNear, float zFar);
void MatrixPop();
void MatrixPush();
void MatrixMult(float* mat);
const float* MatrixGet(int type);
void Set_matrixDirty();
// Core
void Initialise();
void InitialiseContext();
// Call before Initialise() to override window size and/or fullscreen mode.
// If not called, the primary monitor's native resolution is used.
void SetWindowSize(int w, int h);
void SetFullscreen(bool fs);
void StartFrame();
void DoScreenGrabOnNextPresent();
void Present();
void Clear(int flags);
void SetClearColour(const float colourRGBA[4]);
bool IsWidescreen();
bool IsHiDef();
void GetFramebufferSize(int &width, int &height);
void CaptureThumbnail(ImageFileBuffer *pngOut);
void CaptureScreen(ImageFileBuffer *jpgOut, XSOCIAL_PREVIEWIMAGE *previewOut);
void BeginConditionalSurvey(int identifier);
void EndConditionalSurvey();
void BeginConditionalRendering(int identifier);
void EndConditionalRendering();
// Core
void Initialise();
void InitialiseContext();
// Call before Initialise() to override window size and/or fullscreen mode.
// If not called, the primary monitor's native resolution is used.
void SetWindowSize(int w, int h);
void SetFullscreen(bool fs);
void StartFrame();
void DoScreenGrabOnNextPresent();
void Present();
void Clear(int flags);
void SetClearColour(const float colourRGBA[4]);
bool IsWidescreen();
bool IsHiDef();
void GetFramebufferSize(int& width, int& height);
void CaptureThumbnail(ImageFileBuffer* pngOut);
void CaptureScreen(ImageFileBuffer* jpgOut,
XSOCIAL_PREVIEWIMAGE* previewOut);
void BeginConditionalSurvey(int identifier);
void EndConditionalSurvey();
void BeginConditionalRendering(int identifier);
void EndConditionalRendering();
// Vertex data handling
typedef enum
{
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x float, colour 4 x byte, normal 4 x byte, padding 1 DWORD
VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of VS_PS3_TS2_CS1.hlsl for description of layout
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with lighting applied,
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1 with tex gen
VERTEX_TYPE_COUNT
} eVertexType;
// Vertex data handling
typedef enum {
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, // Position 3 x float, texture 2 x
// float, colour 4 x byte, normal 4 x
// byte, padding 1 DWORD
VERTEX_TYPE_COMPRESSED, // Compressed format - see comment at top of
// VS_PS3_TS2_CS1.hlsl for description of
// layout
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_LIT, // as
// VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1
// with lighting applied,
VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1_TEXGEN, // as
// VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1
// with tex gen
VERTEX_TYPE_COUNT
} eVertexType;
// Pixel shader
typedef enum
{
PIXEL_SHADER_TYPE_STANDARD,
PIXEL_SHADER_TYPE_PROJECTION,
PIXEL_SHADER_TYPE_FORCELOD,
PIXEL_SHADER_COUNT
} ePixelShaderType;
// Pixel shader
typedef enum {
PIXEL_SHADER_TYPE_STANDARD,
PIXEL_SHADER_TYPE_PROJECTION,
PIXEL_SHADER_TYPE_FORCELOD,
PIXEL_SHADER_COUNT
} ePixelShaderType;
typedef enum
{
VIEWPORT_TYPE_FULLSCREEN,
VIEWPORT_TYPE_SPLIT_TOP,
VIEWPORT_TYPE_SPLIT_BOTTOM,
VIEWPORT_TYPE_SPLIT_LEFT,
VIEWPORT_TYPE_SPLIT_RIGHT,
VIEWPORT_TYPE_QUADRANT_TOP_LEFT,
VIEWPORT_TYPE_QUADRANT_TOP_RIGHT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT,
} eViewportType;
typedef enum {
VIEWPORT_TYPE_FULLSCREEN,
VIEWPORT_TYPE_SPLIT_TOP,
VIEWPORT_TYPE_SPLIT_BOTTOM,
VIEWPORT_TYPE_SPLIT_LEFT,
VIEWPORT_TYPE_SPLIT_RIGHT,
VIEWPORT_TYPE_QUADRANT_TOP_LEFT,
VIEWPORT_TYPE_QUADRANT_TOP_RIGHT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT,
VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT,
} eViewportType;
typedef enum
{
PRIMITIVE_TYPE_TRIANGLE_LIST,
PRIMITIVE_TYPE_TRIANGLE_STRIP,
PRIMITIVE_TYPE_TRIANGLE_FAN,
PRIMITIVE_TYPE_QUAD_LIST,
PRIMITIVE_TYPE_LINE_LIST,
PRIMITIVE_TYPE_LINE_STRIP,
PRIMITIVE_TYPE_COUNT
} ePrimitiveType;
typedef enum {
PRIMITIVE_TYPE_TRIANGLE_LIST,
PRIMITIVE_TYPE_TRIANGLE_STRIP,
PRIMITIVE_TYPE_TRIANGLE_FAN,
PRIMITIVE_TYPE_QUAD_LIST,
PRIMITIVE_TYPE_LINE_LIST,
PRIMITIVE_TYPE_LINE_STRIP,
PRIMITIVE_TYPE_COUNT
} ePrimitiveType;
void DrawVertices(ePrimitiveType PrimitiveType, int count, void *dataIn, eVertexType vType, C4JRender::ePixelShaderType psType);
void DrawVertices(ePrimitiveType PrimitiveType, int count, void* dataIn,
eVertexType vType, C4JRender::ePixelShaderType psType);
// Command buffers
void CBuffLockStaticCreations();
int CBuffCreate(int count);
void CBuffDelete(int first, int count);
void CBuffStart(int index, bool full = false);
void CBuffClear(int index);
int CBuffSize(int index);
void CBuffEnd();
bool CBuffCall(int index, bool full = true);
void CBuffTick();
void CBuffDeferredModeStart();
void CBuffDeferredModeEnd();
// Command buffers
void CBuffLockStaticCreations();
int CBuffCreate(int count);
void CBuffDelete(int first, int count);
void CBuffStart(int index, bool full = false);
void CBuffClear(int index);
int CBuffSize(int index);
void CBuffEnd();
bool CBuffCall(int index, bool full = true);
void CBuffTick();
void CBuffDeferredModeStart();
void CBuffDeferredModeEnd();
typedef enum
{
TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per component
/* Don't think these are all directly available on D3D 11 - leaving for now
TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to alpha channel, R=G=B=0
TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit component mapped to alpha channel, R=G=B=1
TEXTURE_FORMAT_RxGxBxAx, // One 8-bit component mapped to all channels
*/
MAX_TEXTURE_FORMATS
} eTextureFormat;
typedef enum {
TEXTURE_FORMAT_RxGyBzAw, // Normal 32-bit RGBA texture, 8 bits per
// component
/* Don't think these are all directly available on D3D 11 - leaving for
now TEXTURE_FORMAT_R0G0B0Ax, // One 8-bit component mapped to
alpha channel, R=G=B=0 TEXTURE_FORMAT_R1G1B1Ax, // One 8-bit
component mapped to alpha channel, R=G=B=1 TEXTURE_FORMAT_RxGxBxAx,
// One 8-bit component mapped to all channels
*/
MAX_TEXTURE_FORMATS
} eTextureFormat;
// Textures
int TextureCreate();
void TextureFree(int idx);
void TextureBind(int idx);
void TextureBindVertex(int idx, bool scaleLight = false);
void TextureSetTextureLevels(int levels);
int TextureGetTextureLevels();
void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
void TextureDataUpdate(int xoffset, int yoffset, int width, int height, void *data, int level);
void TextureSetParam(int param, int value);
void TextureDynamicUpdateStart();
void TextureDynamicUpdateEnd();
HRESULT LoadTextureData(const char *szFilename,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
HRESULT LoadTextureData(BYTE *pbData, DWORD dwBytes,D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut);
HRESULT SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut);
HRESULT SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn);
void TextureGetStats();
void *TextureGetTexture(int idx);
// Textures
int TextureCreate();
void TextureFree(int idx);
void TextureBind(int idx);
void TextureBindVertex(int idx, bool scaleLight = false);
void TextureSetTextureLevels(int levels);
int TextureGetTextureLevels();
void TextureData(int width, int height, void* data, int level,
eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw);
void TextureDataUpdate(int xoffset, int yoffset, int width, int height,
void* data, int level);
void TextureSetParam(int param, int value);
void TextureDynamicUpdateStart();
void TextureDynamicUpdateEnd();
HRESULT LoadTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo,
int** ppDataOut);
HRESULT LoadTextureData(BYTE* pbData, DWORD dwBytes,
D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut);
HRESULT SaveTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo,
int* ppDataOut);
HRESULT SaveTextureDataToMemory(void* pOutput, int outputCapacity,
int* outputLength, int width, int height,
int* ppDataIn);
void TextureGetStats();
void* TextureGetTexture(int idx);
// State control
void StateSetColour(float r, float g, float b, float a);
void StateSetDepthMask(bool enable);
void StateSetBlendEnable(bool enable);
void StateSetBlendFunc(int src, int dst);
void StateSetBlendFactor(unsigned int colour);
void StateSetAlphaFunc(int func, float param);
void StateSetDepthFunc(int func);
void StateSetFaceCull(bool enable);
void StateSetFaceCullCW(bool enable);
void StateSetLineWidth(float width);
void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha);
void StateSetDepthTestEnable(bool enable);
void StateSetAlphaTestEnable(bool enable);
void StateSetDepthSlopeAndBias(float slope, float bias);
void StateSetFogEnable(bool enable);
void StateSetFogMode(int mode);
void StateSetFogNearDistance(float dist);
void StateSetFogFarDistance(float dist);
void StateSetFogDensity(float density);
void StateSetFogColour(float red, float green, float blue);
void StateSetLightingEnable(bool enable);
void StateSetVertexTextureUV( float u, float v);
void StateSetLightColour(int light, float red, float green, float blue);
void StateSetLightAmbientColour(float red, float green, float blue);
void StateSetLightDirection(int light, float x, float y, float z);
void StateSetLightEnable(int light, bool enable);
void StateSetViewport(eViewportType viewportType);
void StateSetEnableViewportClipPlanes(bool enable);
void StateSetTexGenCol(int col, float x, float y, float z, float w, bool eyeSpace);
void StateSetStencil(int Function, uint8_t stencil_ref, uint8_t stencil_func_mask, uint8_t stencil_write_mask);
void StateSetForceLOD(int LOD);
// State control
void StateSetColour(float r, float g, float b, float a);
void StateSetDepthMask(bool enable);
void StateSetBlendEnable(bool enable);
void StateSetBlendFunc(int src, int dst);
void StateSetBlendFactor(unsigned int colour);
void StateSetAlphaFunc(int func, float param);
void StateSetDepthFunc(int func);
void StateSetFaceCull(bool enable);
void StateSetFaceCullCW(bool enable);
void StateSetLineWidth(float width);
void StateSetWriteEnable(bool red, bool green, bool blue, bool alpha);
void StateSetDepthTestEnable(bool enable);
void StateSetAlphaTestEnable(bool enable);
void StateSetDepthSlopeAndBias(float slope, float bias);
void StateSetFogEnable(bool enable);
void StateSetFogMode(int mode);
void StateSetFogNearDistance(float dist);
void StateSetFogFarDistance(float dist);
void StateSetFogDensity(float density);
void StateSetFogColour(float red, float green, float blue);
void StateSetLightingEnable(bool enable);
void StateSetVertexTextureUV(float u, float v);
void StateSetLightColour(int light, float red, float green, float blue);
void StateSetLightAmbientColour(float red, float green, float blue);
void StateSetLightDirection(int light, float x, float y, float z);
void StateSetLightEnable(int light, bool enable);
void StateSetViewport(eViewportType viewportType);
void StateSetEnableViewportClipPlanes(bool enable);
void StateSetTexGenCol(int col, float x, float y, float z, float w,
bool eyeSpace);
void StateSetStencil(int Function, uint8_t stencil_ref,
uint8_t stencil_func_mask, uint8_t stencil_write_mask);
void StateSetForceLOD(int LOD);
// Event tracking
void BeginEvent(LPCWSTR eventName);
void EndEvent();
// Event tracking
void BeginEvent(LPCWSTR eventName);
void EndEvent();
// PLM event handling
void Suspend();
bool Suspended();
void Resume();
// PLM event handling
void Suspend();
bool Suspended();
void Resume();
// Linux window management
bool ShouldClose();
void Shutdown();
// Linux window management
bool ShouldClose();
void Shutdown();
};
const int GL_MODELVIEW_MATRIX = 0x0BA6;
const int GL_PROJECTION_MATRIX = 0x0BA7;
const int GL_MODELVIEW = 0x1700;
@ -242,8 +254,8 @@ const int GL_EYE_LINEAR = 0x2400;
const int GL_OBJECT_PLANE = 0x2501;
const int GL_EYE_PLANE = 0x2502;
// These things are used by glEnable/glDisable so must be different and non-zero (zero is used by things we haven't assigned yet)
// These things are used by glEnable/glDisable so must be different and non-zero
// (zero is used by things we haven't assigned yet)
const int GL_TEXTURE_2D = 0x0DE1;
const int GL_BLEND = 0x0BE2;
const int GL_CULL_FACE = 0x0B44;
@ -286,7 +298,7 @@ const int GL_TEXTURE_WRAP_T = 0x2803;
const int GL_NEAREST = 0x2600;
const int GL_LINEAR = 0x2601;
const int GL_EXP = 0x0800;
const int GL_NEAREST_MIPMAP_LINEAR = 0x2702; // TODO - mipmapping bit of this
const int GL_NEAREST_MIPMAP_LINEAR = 0x2702; // TODO - mipmapping bit of this
const int GL_CLAMP = 0x2900;
const int GL_REPEAT = 0x2901;
@ -312,5 +324,3 @@ const int GL_TRIANGLE_STRIP = 0x0005;
// Singleton
extern C4JRender RenderManager;

File diff suppressed because it is too large Load diff

View file

@ -5,4 +5,4 @@
#include "../Minecraft.Client/Platform/Linux/Stubs/LinuxStubs.h"
#endif
#endif //_4J_RENDER_STADAFX_H
#endif //_4J_RENDER_STADAFX_H

View file

@ -12,66 +12,170 @@ C4JStorage::C4JStorage() : m_pStringTable(nullptr) {}
void C4JStorage::Tick(void) {}
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA, UINT uiOptionC, DWORD dwPad,
int(*Func)(void *, int, const C4JStorage::EMessageResult), void *lpParam, C4JStringTable *pStringTable, WCHAR *pwchFormatString, DWORD dwFocusButton) {
C4JStorage::EMessageResult C4JStorage::RequestMessageBox(
UINT uiTitle, UINT uiText, UINT* uiOptionA, UINT uiOptionC, DWORD dwPad,
int (*Func)(void*, int, const C4JStorage::EMessageResult), void* lpParam,
C4JStringTable* pStringTable, WCHAR* pwchFormatString,
DWORD dwFocusButton) {
return EMessage_ResultAccept;
}
C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() { return EMessage_Undefined; }
C4JStorage::EMessageResult C4JStorage::GetMessageBoxResult() {
return EMessage_Undefined;
}
bool C4JStorage::SetSaveDevice(int(*Func)(void *, const bool), void *lpParam, bool bForceResetOfSaveDevice) { return true; }
bool C4JStorage::SetSaveDevice(int (*Func)(void*, const bool), void* lpParam,
bool bForceResetOfSaveDevice) {
return true;
}
void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName, char *pszSavePackName, int iMinimumSaveSize, int(*Func)(void *, const ESavingMessage, int), void *lpParam, LPCSTR szGroupID) {}
void C4JStorage::Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName,
char* pszSavePackName, int iMinimumSaveSize,
int (*Func)(void*, const ESavingMessage, int),
void* lpParam, LPCSTR szGroupID) {}
void C4JStorage::ResetSaveData() {}
void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName) {}
void C4JStorage::SetDefaultSaveNameForKeyboardDisplay(
LPCWSTR pwchDefaultSaveName) {}
void C4JStorage::SetSaveTitle(LPCWSTR pwchDefaultSaveName) {}
bool C4JStorage::GetSaveUniqueNumber(INT *piVal) { if (piVal) *piVal = 0; return true; }
bool C4JStorage::GetSaveUniqueFilename(char *pszName) { if (pszName) pszName[0] = '\0'; return true; }
void C4JStorage::SetSaveUniqueFilename(char *szFilename) {}
void C4JStorage::SetState(ESaveGameControlState eControlState, int(*Func)(void *, const bool), void *lpParam) {}
bool C4JStorage::GetSaveUniqueNumber(INT* piVal) {
if (piVal) *piVal = 0;
return true;
}
bool C4JStorage::GetSaveUniqueFilename(char* pszName) {
if (pszName) pszName[0] = '\0';
return true;
}
void C4JStorage::SetSaveUniqueFilename(char* szFilename) {}
void C4JStorage::SetState(ESaveGameControlState eControlState,
int (*Func)(void*, const bool), void* lpParam) {}
void C4JStorage::SetSaveDisabled(bool bDisable) {}
bool C4JStorage::GetSaveDisabled(void) { return false; }
unsigned int C4JStorage::GetSaveSize() { return 0; }
void C4JStorage::GetSaveData(void *pvData, unsigned int *puiBytes) { if (puiBytes) *puiBytes = 0; }
PVOID C4JStorage::AllocateSaveData(unsigned int uiBytes) { return malloc(uiBytes); }
void C4JStorage::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage, DWORD dwImageBytes, PBYTE pbTextData, DWORD dwTextDataBytes) {}
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int(*Func)(void *, const bool), void *lpParam) { return ESaveGame_Idle; }
void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail, WCHAR *wchNewName, int(*Func)(void *lpParam, bool), void *lpParam) {}
void C4JStorage::GetSaveData(void* pvData, unsigned int* puiBytes) {
if (puiBytes) *puiBytes = 0;
}
PVOID C4JStorage::AllocateSaveData(unsigned int uiBytes) {
return malloc(uiBytes);
}
void C4JStorage::SetSaveImages(PBYTE pbThumbnail, DWORD dwThumbnailBytes,
PBYTE pbImage, DWORD dwImageBytes,
PBYTE pbTextData, DWORD dwTextDataBytes) {}
C4JStorage::ESaveGameState C4JStorage::SaveSaveData(int (*Func)(void*,
const bool),
void* lpParam) {
return ESaveGame_Idle;
}
void C4JStorage::CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail,
WCHAR* wchNewName,
int (*Func)(void* lpParam, bool),
void* lpParam) {}
void C4JStorage::SetSaveDeviceSelected(unsigned int uiPad, bool bSelected) {}
bool C4JStorage::GetSaveDeviceSelected(unsigned int iPad) { return true; }
C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool *pbExists) { if (pbExists) *pbExists = false; return ESaveGame_Idle; }
C4JStorage::ESaveGameState C4JStorage::DoesSaveExist(bool* pbExists) {
if (pbExists) *pbExists = false;
return ESaveGame_Idle;
}
bool C4JStorage::EnoughSpaceForAMinSaveGame() { return true; }
void C4JStorage::SetSaveMessageVPosition(float fY) {}
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(int iPad, int(*Func)(void *lpParam, SAVE_DETAILS *pSaveDetails, const bool), void *lpParam, char *pszSavePackName) { return ESaveGame_Idle; }
C4JStorage::ESaveGameState C4JStorage::GetSavesInfo(
int iPad,
int (*Func)(void* lpParam, SAVE_DETAILS* pSaveDetails, const bool),
void* lpParam, char* pszSavePackName) {
return ESaveGame_Idle;
}
PSAVE_DETAILS C4JStorage::ReturnSavesInfo() { return nullptr; }
void C4JStorage::ClearSavesInfo() {}
C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, std::uint8_t *thumbnailData, unsigned int thumbnailBytes), void *lpParam) { return ESaveGame_Idle; }
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA &xContentData) { memset(&xContentData, 0, sizeof(xContentData)); }
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes) { if (ppbImageData) *ppbImageData = nullptr; if (pdwImageBytes) *pdwImageBytes = 0; }
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, const bool, const bool), void *lpParam) { return ESaveGame_Idle; }
C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo, int(*Func)(void *lpParam, const bool), void *lpParam) { return ESaveGame_Idle; }
void C4JStorage::RegisterMarketplaceCountsCallback(int(*Func)(void *lpParam, C4JStorage::DLC_TMS_DETAILS *, int), void *lpParam) {}
void C4JStorage::SetDLCPackageRoot(char *pszDLCRoot) {}
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(int iPad, int(*Func)(void *, int, std::uint32_t, int), void *lpParam, DWORD dwOfferTypesBitmask) { return EDLC_NoOffers; }
C4JStorage::ESaveGameState C4JStorage::LoadSaveDataThumbnail(
PSAVE_INFO pSaveInfo,
int (*Func)(void* lpParam, std::uint8_t* thumbnailData,
unsigned int thumbnailBytes),
void* lpParam) {
return ESaveGame_Idle;
}
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile,
XCONTENT_DATA& xContentData) {
memset(&xContentData, 0, sizeof(xContentData));
}
void C4JStorage::GetSaveCacheFileInfo(DWORD dwFile, PBYTE* ppbImageData,
DWORD* pdwImageBytes) {
if (ppbImageData) *ppbImageData = nullptr;
if (pdwImageBytes) *pdwImageBytes = 0;
}
C4JStorage::ESaveGameState C4JStorage::LoadSaveData(
PSAVE_INFO pSaveInfo, int (*Func)(void* lpParam, const bool, const bool),
void* lpParam) {
return ESaveGame_Idle;
}
C4JStorage::ESaveGameState C4JStorage::DeleteSaveData(PSAVE_INFO pSaveInfo,
int (*Func)(void* lpParam,
const bool),
void* lpParam) {
return ESaveGame_Idle;
}
void C4JStorage::RegisterMarketplaceCountsCallback(
int (*Func)(void* lpParam, C4JStorage::DLC_TMS_DETAILS*, int),
void* lpParam) {}
void C4JStorage::SetDLCPackageRoot(char* pszDLCRoot) {}
C4JStorage::EDLCStatus C4JStorage::GetDLCOffers(
int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam,
DWORD dwOfferTypesBitmask) {
return EDLC_NoOffers;
}
DWORD C4JStorage::CancelGetDLCOffers() { return 0; }
void C4JStorage::ClearDLCOffers() {}
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(DWORD dw) { return s_dummyOffer; }
XMARKETPLACE_CONTENTOFFER_INFO& C4JStorage::GetOffer(DWORD dw) {
return s_dummyOffer;
}
int C4JStorage::GetOfferCount() { return 0; }
DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA, int(*Func)(void *, int, int), void *lpParam, bool bTrial) { return 0; }
DWORD C4JStorage::InstallOffer(int iOfferIDC, __uint64* ullOfferIDA,
int (*Func)(void*, int, int), void* lpParam,
bool bTrial) {
return 0;
}
DWORD C4JStorage::GetAvailableDLCCount(int iPad) { return 0; }
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad, int(*Func)(void *, int, int), void *lpParam) { return EDLC_NoInstalledDLC; }
C4JStorage::EDLCStatus C4JStorage::GetInstalledDLC(int iPad,
int (*Func)(void*, int, int),
void* lpParam) {
return EDLC_NoInstalledDLC;
}
XCONTENT_DATA& C4JStorage::GetDLC(DWORD dw) { return s_dummyContentData; }
std::uint32_t C4JStorage::MountInstalledDLC(int iPad, std::uint32_t dwDLC, int(*Func)(void *, int, std::uint32_t, std::uint32_t), void *lpParam, LPCSTR szMountDrive) { return 0; }
std::uint32_t C4JStorage::MountInstalledDLC(
int iPad, std::uint32_t dwDLC,
int (*Func)(void*, int, std::uint32_t, std::uint32_t), void* lpParam,
LPCSTR szMountDrive) {
return 0;
}
DWORD C4JStorage::UnmountInstalledDLC(LPCSTR szMountDrive) { return 0; }
void C4JStorage::GetMountedDLCFileList(const char *szMountDrive, std::vector<std::string> &fileList) { fileList.clear(); }
void C4JStorage::GetMountedDLCFileList(const char* szMountDrive,
std::vector<std::string>& fileList) {
fileList.clear();
}
std::string C4JStorage::GetMountedPath(std::string szMount) { return ""; }
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, C4JStorage::eTMS_FileType eFileType,
WCHAR *pwchFilename, BYTE **ppBuffer, DWORD *pdwBufferSize, int(*Func)(void *, WCHAR *, int, bool, int), void *lpParam, int iAction) { return ETMSStatus_Fail; }
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename, BYTE *pBuffer, DWORD dwBufferSize) { return false; }
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, WCHAR *pwchFilename) { return false; }
void C4JStorage::StoreTMSPathName(WCHAR *pwchName) {}
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(int iPad, C4JStorage::eGlobalStorage eStorageFacility, C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename, int(*Func)(void *, int, int, PTMSPP_FILEDATA, LPCSTR), void *lpParam, int iUserData) { return ETMSStatus_Fail; }
unsigned int C4JStorage::CRC(unsigned char *buf, int len) {
C4JStorage::ETMSStatus C4JStorage::ReadTMSFile(
int iQuadrant, eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FileType eFileType, WCHAR* pwchFilename, BYTE** ppBuffer,
DWORD* pdwBufferSize, int (*Func)(void*, WCHAR*, int, bool, int),
void* lpParam, int iAction) {
return ETMSStatus_Fail;
}
bool C4JStorage::WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
WCHAR* pwchFilename, BYTE* pBuffer,
DWORD dwBufferSize) {
return false;
}
bool C4JStorage::DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
WCHAR* pwchFilename) {
return false;
}
void C4JStorage::StoreTMSPathName(WCHAR* pwchName) {}
C4JStorage::ETMSStatus C4JStorage::TMSPP_ReadFile(
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename,
int (*Func)(void*, int, int, PTMSPP_FILEDATA, LPCSTR), void* lpParam,
int iUserData) {
return ETMSStatus_Fail;
}
unsigned int C4JStorage::CRC(unsigned char* buf, int len) {
unsigned int crc = 0xFFFFFFFF;
for (int i = 0; i < len; i++) {
crc ^= buf[i];
@ -82,11 +186,26 @@ unsigned int C4JStorage::CRC(unsigned char *buf, int len) {
return ~crc;
}
int C4JStorage::AddSubfile(int regionIndex) { (void)regionIndex; return 0; }
int C4JStorage::AddSubfile(int regionIndex) {
(void)regionIndex;
return 0;
}
unsigned int C4JStorage::GetSubfileCount() { return 0; }
void C4JStorage::GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size) { (void)i; if(regionIndex) *regionIndex=0; if(data) *data=0; if(size) *size=0; }
void C4JStorage::GetSubfileDetails(unsigned int i, int* regionIndex,
void** data, unsigned int* size) {
(void)i;
if (regionIndex) *regionIndex = 0;
if (data) *data = 0;
if (size) *size = 0;
}
void C4JStorage::ResetSubfiles() {}
void C4JStorage::UpdateSubfile(int index, void* data, unsigned int size) { (void)index; (void)data; (void)size; }
void C4JStorage::SaveSubfiles(int (*Func)(void*, const bool), void* param) { if(Func) Func(param, true); }
void C4JStorage::UpdateSubfile(int index, void* data, unsigned int size) {
(void)index;
(void)data;
(void)size;
}
void C4JStorage::SaveSubfiles(int (*Func)(void*, const bool), void* param) {
if (Func) Func(param, true);
}
C4JStorage::ESaveGameState C4JStorage::GetSaveState() { return ESaveGame_Idle; }
void C4JStorage::ContinueIncompleteOperation() {}

View file

@ -1,354 +1,380 @@
#pragma once
#include <cstdint>
#include <vector>
//#include <xtms.h>
// #include <xtms.h>
class C4JStringTable;
#define MAX_DISPLAYNAME_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
#define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
#define MAX_SAVEFILENAME_LENGTH 32 // CELL_SAVEDATA_DIRNAME_SIZE
#define MAX_DISPLAYNAME_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
#define MAX_DETAILS_LENGTH 128 // CELL_SAVEDATA_SYSP_SUBTITLE_SIZE on PS3
#define MAX_SAVEFILENAME_LENGTH 32 // CELL_SAVEDATA_DIRNAME_SIZE
typedef struct
{
time_t modifiedTime;
unsigned int dataSize;
unsigned int thumbnailSize;
}
CONTAINER_METADATA;
typedef struct {
time_t modifiedTime;
unsigned int dataSize;
unsigned int thumbnailSize;
} CONTAINER_METADATA;
typedef struct
{
char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH];
char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH];
CONTAINER_METADATA metaData;
PBYTE thumbnailData;
}
SAVE_INFO,*PSAVE_INFO;
typedef struct {
char UTF8SaveFilename[MAX_SAVEFILENAME_LENGTH];
char UTF8SaveTitle[MAX_DISPLAYNAME_LENGTH];
CONTAINER_METADATA metaData;
PBYTE thumbnailData;
} SAVE_INFO, *PSAVE_INFO;
typedef struct
{
int iSaveC;
PSAVE_INFO SaveInfoA;
}
SAVE_DETAILS,*PSAVE_DETAILS;
typedef struct {
int iSaveC;
PSAVE_INFO SaveInfoA;
} SAVE_DETAILS, *PSAVE_DETAILS;
typedef std::vector <PXMARKETPLACE_CONTENTOFFER_INFO> OfferDataArray;
typedef std::vector <PXCONTENT_DATA> XContentDataArray;
//typedef std::vector <PSAVE_DETAILS> SaveDetailsArray;
typedef std::vector<PXMARKETPLACE_CONTENTOFFER_INFO> OfferDataArray;
typedef std::vector<PXCONTENT_DATA> XContentDataArray;
// typedef std::vector <PSAVE_DETAILS> SaveDetailsArray;
// Current version of the dlc data creator
#define CURRENT_DLC_VERSION_NUM 3
class C4JStorage
{
class C4JStorage {
public:
// Structs defined in the DLC_Creator, but added here to be used in the app
typedef struct
{
unsigned int uiFileSize;
DWORD dwType;
DWORD dwWchCount; // count of WCHAR in next array
WCHAR wchFile[1];
}
DLC_FILE_DETAILS, *PDLC_FILE_DETAILS;
// Structs defined in the DLC_Creator, but added here to be used in the app
typedef struct {
unsigned int uiFileSize;
DWORD dwType;
DWORD dwWchCount; // count of WCHAR in next array
WCHAR wchFile[1];
} DLC_FILE_DETAILS, *PDLC_FILE_DETAILS;
typedef struct
{
DWORD dwType;
DWORD dwWchCount; // count of WCHAR in next array;
WCHAR wchData[1]; // will be an array of size dwBytes
}
DLC_FILE_PARAM, *PDLC_FILE_PARAM;
// End of DLC_Creator structs
typedef struct {
DWORD dwType;
DWORD dwWchCount; // count of WCHAR in next array;
WCHAR wchData[1]; // will be an array of size dwBytes
} DLC_FILE_PARAM, *PDLC_FILE_PARAM;
// End of DLC_Creator structs
typedef struct
{
WCHAR wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH];
CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH];
DWORD dwImageOffset;
DWORD dwImageBytes;
}
CACHEINFOSTRUCT;
typedef struct {
WCHAR wchDisplayName[XCONTENT_MAX_DISPLAYNAME_LENGTH];
CHAR szFileName[XCONTENT_MAX_FILENAME_LENGTH];
DWORD dwImageOffset;
DWORD dwImageBytes;
} CACHEINFOSTRUCT;
// structure to hold DLC info in TMS
typedef struct
{
DWORD dwVersion;
DWORD dwNewOffers;
DWORD dwTotalOffers;
DWORD dwInstalledTotalOffers;
BYTE bPadding[1024-sizeof(DWORD)*4]; // future expansion
}
DLC_TMS_DETAILS;
// structure to hold DLC info in TMS
typedef struct {
DWORD dwVersion;
DWORD dwNewOffers;
DWORD dwTotalOffers;
DWORD dwInstalledTotalOffers;
BYTE bPadding[1024 - sizeof(DWORD) * 4]; // future expansion
} DLC_TMS_DETAILS;
enum eGTS_FileTypes
{
eGTS_Type_Skin=0,
eGTS_Type_Cape,
eGTS_Type_MAX
};
enum eGTS_FileTypes { eGTS_Type_Skin = 0, eGTS_Type_Cape, eGTS_Type_MAX };
enum eGlobalStorage
{
//eGlobalStorage_GameClip=0,
eGlobalStorage_Title=0,
eGlobalStorage_TitleUser,
eGlobalStorage_Max
};
enum eGlobalStorage {
// eGlobalStorage_GameClip=0,
eGlobalStorage_Title = 0,
eGlobalStorage_TitleUser,
eGlobalStorage_Max
};
enum EMessageResult
{
EMessage_Undefined=0,
EMessage_Busy,
EMessage_Pending,
EMessage_Cancelled,
EMessage_ResultAccept,
EMessage_ResultDecline,
EMessage_ResultThirdOption,
EMessage_ResultFourthOption
};
enum EMessageResult {
EMessage_Undefined = 0,
EMessage_Busy,
EMessage_Pending,
EMessage_Cancelled,
EMessage_ResultAccept,
EMessage_ResultDecline,
EMessage_ResultThirdOption,
EMessage_ResultFourthOption
};
enum ESaveGameControlState
{
ESaveGameControl_Idle=0,
ESaveGameControl_Save,
ESaveGameControl_InternalRequestingDevice,
ESaveGameControl_InternalGetSaveName,
ESaveGameControl_InternalSaving,
ESaveGameControl_CopySave,
ESaveGameControl_CopyingSave,
};
enum ESaveGameControlState {
ESaveGameControl_Idle = 0,
ESaveGameControl_Save,
ESaveGameControl_InternalRequestingDevice,
ESaveGameControl_InternalGetSaveName,
ESaveGameControl_InternalSaving,
ESaveGameControl_CopySave,
ESaveGameControl_CopyingSave,
};
enum ESaveGameState
{
ESaveGame_Idle=0,
ESaveGame_Save,
ESaveGame_InternalRequestingDevice,
ESaveGame_InternalGetSaveName,
ESaveGame_InternalSaving,
ESaveGame_CopySave,
ESaveGame_CopyingSave,
ESaveGame_Load,
ESaveGame_GetSavesInfo,
ESaveGame_Rename,
ESaveGame_Delete,
enum ESaveGameState {
ESaveGame_Idle = 0,
ESaveGame_Save,
ESaveGame_InternalRequestingDevice,
ESaveGame_InternalGetSaveName,
ESaveGame_InternalSaving,
ESaveGame_CopySave,
ESaveGame_CopyingSave,
ESaveGame_Load,
ESaveGame_GetSavesInfo,
ESaveGame_Rename,
ESaveGame_Delete,
ESaveGame_GetSaveThumbnail // Not used as an actual state in the PS4, but the game expects this to be returned to indicate success when getting a thumbnail
ESaveGame_GetSaveThumbnail // Not used as an actual state in the PS4,
// but the game expects this to be returned
// to indicate success when getting a
// thumbnail
};
enum ELoadGameStatus
{
ELoadGame_Idle=0,
ELoadGame_InProgress,
ELoadGame_NoSaves,
ELoadGame_ChangedDevice,
ELoadGame_DeviceRemoved
};
};
enum ELoadGameStatus {
ELoadGame_Idle = 0,
ELoadGame_InProgress,
ELoadGame_NoSaves,
ELoadGame_ChangedDevice,
ELoadGame_DeviceRemoved
};
enum EDeleteGameStatus
{
EDeleteGame_Idle=0,
EDeleteGame_InProgress,
};
enum EDeleteGameStatus {
EDeleteGame_Idle = 0,
EDeleteGame_InProgress,
};
enum ESGIStatus {
ESGIStatus_Error = 0,
ESGIStatus_Idle,
ESGIStatus_ReadInProgress,
ESGIStatus_NoSaves,
};
enum ESGIStatus
{
ESGIStatus_Error=0,
ESGIStatus_Idle,
ESGIStatus_ReadInProgress,
ESGIStatus_NoSaves,
};
enum EDLCStatus {
EDLC_Error = 0,
EDLC_Idle,
EDLC_NoOffers,
EDLC_AlreadyEnumeratedAllOffers,
EDLC_NoInstalledDLC,
EDLC_Pending,
EDLC_LoadInProgress,
EDLC_Loaded,
EDLC_ChangedDevice
};
enum EDLCStatus
{
EDLC_Error=0,
EDLC_Idle,
EDLC_NoOffers,
EDLC_AlreadyEnumeratedAllOffers,
EDLC_NoInstalledDLC,
EDLC_Pending,
EDLC_LoadInProgress,
EDLC_Loaded,
EDLC_ChangedDevice
};
enum ESavingMessage {
ESavingMessage_None = 0,
ESavingMessage_Short,
ESavingMessage_Long
};
enum ESavingMessage
{
ESavingMessage_None=0,
ESavingMessage_Short,
ESavingMessage_Long
};
enum ETMSStatus {
ETMSStatus_Idle = 0,
ETMSStatus_Fail,
ETMSStatus_Fail_ReadInProgress,
ETMSStatus_Fail_WriteInProgress,
ETMSStatus_Pending,
};
enum ETMSStatus
{
ETMSStatus_Idle=0,
ETMSStatus_Fail,
ETMSStatus_Fail_ReadInProgress,
ETMSStatus_Fail_WriteInProgress,
ETMSStatus_Pending,
};
enum eTMS_FileType {
eTMS_FileType_Normal = 0,
eTMS_FileType_Graphic,
};
enum eTMS_FileType
{
eTMS_FileType_Normal=0,
eTMS_FileType_Graphic,
};
enum eTMS_FILETYPEVAL {
TMS_FILETYPE_BINARY,
TMS_FILETYPE_CONFIG,
TMS_FILETYPE_JSON,
TMS_FILETYPE_MAX
};
enum eTMS_UGCTYPE { TMS_UGCTYPE_NONE, TMS_UGCTYPE_IMAGE, TMS_UGCTYPE_MAX };
enum eTMS_FILETYPEVAL
{
TMS_FILETYPE_BINARY,
TMS_FILETYPE_CONFIG,
TMS_FILETYPE_JSON,
TMS_FILETYPE_MAX
};
enum eTMS_UGCTYPE
{
TMS_UGCTYPE_NONE,
TMS_UGCTYPE_IMAGE,
TMS_UGCTYPE_MAX
};
typedef struct {
CHAR szFilename[256];
int iFileSize;
eTMS_FILETYPEVAL eFileTypeVal;
} TMSPP_FILE_DETAILS, *PTMSPP_FILE_DETAILS;
typedef struct {
int iCount;
PTMSPP_FILE_DETAILS FileDetailsA;
} TMSPP_FILE_LIST, *PTMSPP_FILE_LIST;
typedef struct
{
CHAR szFilename[256];
int iFileSize;
eTMS_FILETYPEVAL eFileTypeVal;
}
TMSPP_FILE_DETAILS, *PTMSPP_FILE_DETAILS;
typedef struct {
DWORD dwSize;
PBYTE pbData;
} TMSPP_FILEDATA, *PTMSPP_FILEDATA;
typedef struct
{
int iCount;
PTMSPP_FILE_DETAILS FileDetailsA;
}
TMSPP_FILE_LIST, *PTMSPP_FILE_LIST;
C4JStorage();
typedef struct
{
DWORD dwSize;
PBYTE pbData;
}
TMSPP_FILEDATA, *PTMSPP_FILEDATA;
void Tick(void);
// Messages
C4JStorage::EMessageResult RequestMessageBox(
UINT uiTitle, UINT uiText, UINT* uiOptionA, UINT uiOptionC,
DWORD dwPad = XUSER_INDEX_ANY,
int (*Func)(void*, int, const C4JStorage::EMessageResult) = NULL,
void* lpParam = NULL, C4JStringTable* pStringTable = NULL,
WCHAR* pwchFormatString = NULL, DWORD dwFocusButton = 0);
C4JStorage();
C4JStorage::EMessageResult GetMessageBoxResult();
void Tick(void);
// save device
bool SetSaveDevice(int (*Func)(void*, const bool), void* lpParam,
bool bForceResetOfSaveDevice = false);
// Messages
C4JStorage::EMessageResult RequestMessageBox(UINT uiTitle, UINT uiText, UINT *uiOptionA,UINT uiOptionC, DWORD dwPad=XUSER_INDEX_ANY,
int( *Func)(void *,int,const C4JStorage::EMessageResult)=NULL,void *lpParam=NULL, C4JStringTable *pStringTable=NULL, WCHAR *pwchFormatString=NULL,DWORD dwFocusButton=0);
// savegame
void Init(unsigned int uiSaveVersion, LPCWSTR pwchDefaultSaveName,
char* pszSavePackName, int iMinimumSaveSize,
int (*Func)(void*, const ESavingMessage, int), void* lpParam,
LPCSTR szGroupID);
void ResetSaveData(); // Call before a new save to clear out stored save
// file name
void SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName);
void SetSaveTitle(LPCWSTR pwchDefaultSaveName);
bool GetSaveUniqueNumber(INT* piVal);
bool GetSaveUniqueFilename(char* pszName);
void SetSaveUniqueFilename(char* szFilename);
void SetState(ESaveGameControlState eControlState,
int (*Func)(void*, const bool), void* lpParam);
void SetSaveDisabled(bool bDisable);
bool GetSaveDisabled(void);
unsigned int GetSaveSize();
void GetSaveData(void* pvData, unsigned int* puiBytes);
PVOID AllocateSaveData(unsigned int uiBytes);
void SetSaveImages(
PBYTE pbThumbnail, DWORD dwThumbnailBytes, PBYTE pbImage,
DWORD dwImageBytes, PBYTE pbTextData,
DWORD dwTextDataBytes); // Sets the thumbnail & image for the save,
// optionally setting the metadata in the png
C4JStorage::ESaveGameState SaveSaveData(int (*Func)(void*, const bool),
void* lpParam);
void CopySaveDataToNewSave(PBYTE pbThumbnail, DWORD cbThumbnail,
WCHAR* wchNewName,
int (*Func)(void* lpParam, bool), void* lpParam);
void SetSaveDeviceSelected(unsigned int uiPad, bool bSelected);
bool GetSaveDeviceSelected(unsigned int iPad);
C4JStorage::ESaveGameState DoesSaveExist(bool* pbExists);
bool EnoughSpaceForAMinSaveGame();
void SetSaveMessageVPosition(
float fY); // The 'Saving' message will display at a default position
// unless changed
// Get the info for the saves
C4JStorage::ESaveGameState GetSavesInfo(
int iPad,
int (*Func)(void* lpParam, SAVE_DETAILS* pSaveDetails, const bool),
void* lpParam, char* pszSavePackName);
PSAVE_DETAILS ReturnSavesInfo();
void ClearSavesInfo(); // Clears results
C4JStorage::ESaveGameState LoadSaveDataThumbnail(
PSAVE_INFO pSaveInfo,
int (*Func)(void* lpParam, std::uint8_t* thumbnailData,
unsigned int thumbnailBytes),
void* lpParam); // Get the thumbnail for an individual save referenced
// by pSaveInfo
C4JStorage::EMessageResult GetMessageBoxResult();
void GetSaveCacheFileInfo(DWORD dwFile, XCONTENT_DATA& xContentData);
void GetSaveCacheFileInfo(DWORD dwFile, PBYTE* ppbImageData,
DWORD* pdwImageBytes);
// save device
bool SetSaveDevice(int( *Func)(void *,const bool),void *lpParam, bool bForceResetOfSaveDevice=false);
// Load the save. Need to call GetSaveData once the callback is called
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,
int (*Func)(void* lpParam,
const bool, const bool),
void* lpParam);
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,
int (*Func)(void* lpParam,
const bool),
void* lpParam);
// savegame
void Init(unsigned int uiSaveVersion,LPCWSTR pwchDefaultSaveName,char *pszSavePackName,int iMinimumSaveSize,int( *Func)(void *, const ESavingMessage, int),void *lpParam,LPCSTR szGroupID);
void ResetSaveData(); // Call before a new save to clear out stored save file name
void SetDefaultSaveNameForKeyboardDisplay(LPCWSTR pwchDefaultSaveName);
void SetSaveTitle(LPCWSTR pwchDefaultSaveName);
bool GetSaveUniqueNumber(INT *piVal);
bool GetSaveUniqueFilename(char *pszName);
void SetSaveUniqueFilename(char *szFilename);
void SetState(ESaveGameControlState eControlState,int( *Func)(void *,const bool),void *lpParam);
void SetSaveDisabled(bool bDisable);
bool GetSaveDisabled(void);
unsigned int GetSaveSize();
void GetSaveData(void *pvData,unsigned int *puiBytes);
PVOID AllocateSaveData(unsigned int uiBytes);
void SetSaveImages( PBYTE pbThumbnail,DWORD dwThumbnailBytes,PBYTE pbImage,DWORD dwImageBytes, PBYTE pbTextData ,DWORD dwTextDataBytes); // Sets the thumbnail & image for the save, optionally setting the metadata in the png
C4JStorage::ESaveGameState SaveSaveData(int( *Func)(void * ,const bool),void *lpParam);
void CopySaveDataToNewSave(PBYTE pbThumbnail,DWORD cbThumbnail,WCHAR *wchNewName,int ( *Func)(void *lpParam, bool), void *lpParam);
void SetSaveDeviceSelected(unsigned int uiPad,bool bSelected);
bool GetSaveDeviceSelected(unsigned int iPad);
C4JStorage::ESaveGameState DoesSaveExist(bool *pbExists);
bool EnoughSpaceForAMinSaveGame();
// DLC
void RegisterMarketplaceCountsCallback(
int (*Func)(void* lpParam, C4JStorage::DLC_TMS_DETAILS*, int),
void* lpParam);
void SetDLCPackageRoot(char* pszDLCRoot);
C4JStorage::EDLCStatus GetDLCOffers(
int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam,
DWORD dwOfferTypesBitmask = XMARKETPLACE_OFFERING_TYPE_CONTENT);
DWORD CancelGetDLCOffers();
void ClearDLCOffers();
XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(DWORD dw);
int GetOfferCount();
DWORD InstallOffer(int iOfferIDC, __uint64* ullOfferIDA,
int (*Func)(void*, int, int), void* lpParam,
bool bTrial = false);
DWORD GetAvailableDLCCount(int iPad);
void SetSaveMessageVPosition(float fY); // The 'Saving' message will display at a default position unless changed
// Get the info for the saves
C4JStorage::ESaveGameState GetSavesInfo(int iPad,int ( *Func)(void *lpParam,SAVE_DETAILS *pSaveDetails,const bool),void *lpParam,char *pszSavePackName);
PSAVE_DETAILS ReturnSavesInfo();
void ClearSavesInfo(); // Clears results
C4JStorage::ESaveGameState LoadSaveDataThumbnail(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,std::uint8_t *thumbnailData,unsigned int thumbnailBytes), void *lpParam); // Get the thumbnail for an individual save referenced by pSaveInfo
C4JStorage::EDLCStatus GetInstalledDLC(int iPad,
int (*Func)(void*, int, int),
void* lpParam);
XCONTENT_DATA& GetDLC(DWORD dw);
std::uint32_t MountInstalledDLC(int iPad, std::uint32_t dwDLC,
int (*Func)(void*, int, std::uint32_t,
std::uint32_t),
void* lpParam, LPCSTR szMountDrive = NULL);
DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL);
void GetMountedDLCFileList(const char* szMountDrive,
std::vector<std::string>& fileList);
std::string GetMountedPath(std::string szMount);
void GetSaveCacheFileInfo(DWORD dwFile,XCONTENT_DATA &xContentData);
void GetSaveCacheFileInfo(DWORD dwFile, PBYTE *ppbImageData, DWORD *pdwImageBytes);
// Global title storage
C4JStorage::ETMSStatus ReadTMSFile(
int iQuadrant, eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FileType eFileType, WCHAR* pwchFilename,
BYTE** ppBuffer, DWORD* pdwBufferSize,
int (*Func)(void*, WCHAR*, int, bool, int) = NULL, void* lpParam = NULL,
int iAction = 0);
bool WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
WCHAR* pwchFilename, BYTE* pBuffer, DWORD dwBufferSize);
bool DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility,
WCHAR* pwchFilename);
void StoreTMSPathName(WCHAR* pwchName = NULL);
// Load the save. Need to call GetSaveData once the callback is called
C4JStorage::ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,const bool, const bool), void *lpParam);
C4JStorage::ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo,int( *Func)(void *lpParam,const bool), void *lpParam);
// DLC
void RegisterMarketplaceCountsCallback(int ( *Func)(void *lpParam, C4JStorage::DLC_TMS_DETAILS *, int), void *lpParam );
void SetDLCPackageRoot(char *pszDLCRoot);
C4JStorage::EDLCStatus GetDLCOffers(int iPad,int( *Func)(void *, int, std::uint32_t, int),void *lpParam, DWORD dwOfferTypesBitmask=XMARKETPLACE_OFFERING_TYPE_CONTENT);
DWORD CancelGetDLCOffers();
void ClearDLCOffers();
XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(DWORD dw);
int GetOfferCount();
DWORD InstallOffer(int iOfferIDC, __uint64 *ullOfferIDA,int( *Func)(void *, int, int),void *lpParam, bool bTrial=false);
DWORD GetAvailableDLCCount( int iPad);
C4JStorage::EDLCStatus GetInstalledDLC(int iPad,int( *Func)(void *, int, int),void *lpParam);
XCONTENT_DATA& GetDLC(DWORD dw);
std::uint32_t MountInstalledDLC(int iPad,std::uint32_t dwDLC,int( *Func)(void *, int, std::uint32_t, std::uint32_t),void *lpParam,LPCSTR szMountDrive=NULL);
DWORD UnmountInstalledDLC(LPCSTR szMountDrive = NULL);
void GetMountedDLCFileList(const char* szMountDrive, std::vector<std::string>& fileList);
std::string GetMountedPath(std::string szMount);
// Global title storage
C4JStorage::ETMSStatus ReadTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType,
WCHAR *pwchFilename,BYTE **ppBuffer,DWORD *pdwBufferSize,int( *Func)(void *, WCHAR *,int, bool, int)=NULL,void *lpParam=NULL, int iAction=0);
bool WriteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename,BYTE *pBuffer,DWORD dwBufferSize);
bool DeleteTMSFile(int iQuadrant,eGlobalStorage eStorageFacility,WCHAR *pwchFilename);
void StoreTMSPathName(WCHAR *pwchName=NULL);
// TMS++
// TMS++
#ifdef _XBOX
C4JStorage::ETMSStatus WriteTMSFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FileType eFileType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,TMSCLIENT_CALLBACK Func,LPVOID lpParam);
HRESULT GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam);
C4JStorage::ETMSStatus WriteTMSFile(
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FileType eFileType, CHAR* pchFilePath, CHAR* pchBuffer,
DWORD dwBufferSize, TMSCLIENT_CALLBACK Func, LPVOID lpParam);
HRESULT GetUserQuotaInfo(int iPad, TMSCLIENT_CALLBACK Func, LPVOID lpParam);
#endif
// C4JStorage::ETMSStatus TMSPP_WriteFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID lpParam=NULL, int iUserData=0);
// C4JStorage::ETMSStatus TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam, int iUserData=0);
C4JStorage::ETMSStatus TMSPP_ReadFile(int iPad,C4JStorage::eGlobalStorage eStorageFacility,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,LPCSTR szFilename,int( *Func)(void *,int,int,PTMSPP_FILEDATA, LPCSTR)=NULL,void *lpParam=NULL, int iUserData=0);
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int( *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int iUserData=0);
// C4JStorage::ETMSStatus TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int iUserData=0);
// bool TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const std::wstring &Filename);
// unsigned int CRC(unsigned char *buf, int len);
// C4JStorage::ETMSStatus TMSPP_WriteFile(int
// iPad,C4JStorage::eGlobalStorage
// eStorageFacility,C4JStorage::eTMS_FILETYPEVAL
// eFileTypeVal,C4JStorage::eTMS_UGCTYPE eUGCType,CHAR *pchFilePath,CHAR
// *pchBuffer,DWORD dwBufferSize,int( *Func)(LPVOID,int,int)=NULL,LPVOID
// lpParam=NULL, int iUserData=0); C4JStorage::ETMSStatus
// TMSPP_GetUserQuotaInfo(int iPad,TMSCLIENT_CALLBACK Func,LPVOID lpParam,
// int iUserData=0);
C4JStorage::ETMSStatus TMSPP_ReadFile(
int iPad, C4JStorage::eGlobalStorage eStorageFacility,
C4JStorage::eTMS_FILETYPEVAL eFileTypeVal, LPCSTR szFilename,
int (*Func)(void*, int, int, PTMSPP_FILEDATA, LPCSTR) = NULL,
void* lpParam = NULL, int iUserData = 0);
// C4JStorage::ETMSStatus TMSPP_ReadFileList(int
// iPad,C4JStorage::eGlobalStorage eStorageFacility,CHAR *pchFilePath,int(
// *Func)(LPVOID,int,int,PTMSPP_FILE_LIST)=NULL,LPVOID lpParam=NULL, int
// iUserData=0); C4JStorage::ETMSStatus
// TMSPP_DeleteFile(int iPad,LPCSTR szFilePath,C4JStorage::eTMS_FILETYPEVAL
// eFileTypeVal,int( *Func)(LPVOID,int,int),LPVOID lpParam=NULL, int
// iUserData=0); bool
// TMSPP_InFileList(eGlobalStorage eStorageFacility, int iPad,const
// std::wstring &Filename); unsigned int
// CRC(unsigned char *buf, int len);
// enum eXBLWS
// {
// eXBLWS_GET,
// eXBLWS_POST,
// eXBLWS_PUT,
// eXBLWS_DELETE,
// };
//bool XBLWS_Command(eXBLWS eCommand);
// enum eXBLWS
// {
// eXBLWS_GET,
// eXBLWS_POST,
// eXBLWS_PUT,
// eXBLWS_DELETE,
// };
// bool
// XBLWS_Command(eXBLWS eCommand);
unsigned int CRC(unsigned char* buf, int len);
unsigned int CRC(unsigned char *buf, int len);
int AddSubfile(int regionIndex);
unsigned int GetSubfileCount();
void GetSubfileDetails(unsigned int i, int* regionIndex, void** data,
unsigned int* size);
void ResetSubfiles();
void UpdateSubfile(int index, void* data, unsigned int size);
void SaveSubfiles(int (*Func)(void*, const bool), void* param);
ESaveGameState GetSaveState();
int AddSubfile(int regionIndex);
unsigned int GetSubfileCount();
void GetSubfileDetails(unsigned int i, int* regionIndex, void** data, unsigned int* size);
void ResetSubfiles();
void UpdateSubfile(int index, void* data, unsigned int size);
void SaveSubfiles(int (*Func)(void*, const bool), void* param);
ESaveGameState GetSaveState();
void ContinueIncompleteOperation();
void ContinueIncompleteOperation();
C4JStringTable *m_pStringTable;
C4JStringTable* m_pStringTable;
};
extern C4JStorage StorageManager;

View file

@ -7,4 +7,4 @@
#include "../Minecraft.World/Platform/x64headers/extraX64.h"
#endif //_4J_STORAGE_STADAFX_H
#endif //_4J_STORAGE_STADAFX_H

View file

@ -1,4 +1,6 @@
#include "Platform/stdafx.h"
#include "ClientConstants.h"
const std::wstring ClientConstants::VERSION_STRING = std::wstring(L"Minecraft Xbox ") + VER_FILEVERSION_STR_W;//+ SharedConstants::VERSION_STRING;
const std::wstring ClientConstants::VERSION_STRING =
std::wstring(L"Minecraft Xbox ") +
VER_FILEVERSION_STR_W; //+ SharedConstants::VERSION_STRING;

View file

@ -1,19 +1,16 @@
#pragma once
class ClientConstants {
// This file holds global constants used by the client.
// The file should be replaced at compile-time with the
// proper settings for the given compilation. For example,
// release builds should replace this file with no-cheat
// settings.
class ClientConstants
{
// This file holds global constants used by the client.
// The file should be replaced at compile-time with the
// proper settings for the given compilation. For example,
// release builds should replace this file with no-cheat
// settings.
// INTERNAL DEVELOPMENT SETTINGS
// INTERNAL DEVELOPMENT SETTINGS
public:
static const std::wstring VERSION_STRING;
static const std::wstring VERSION_STRING;
static const bool DEADMAU5_CAMERA_CHEATS = false;
static const bool IS_DEMO_VERSION = false;
static const bool DEADMAU5_CAMERA_CHEATS = false;
static const bool IS_DEMO_VERSION = false;
};

View file

@ -9,82 +9,90 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
#include "TeleportCommand.h"
EGameCommand TeleportCommand::getId()
{
return eGameCommand_Teleport;
EGameCommand TeleportCommand::getId() { return eGameCommand_Teleport; }
void TeleportCommand::execute(std::shared_ptr<CommandSender> source,
byteArray commandData) {
ByteArrayInputStream bais(commandData);
DataInputStream dis(&bais);
PlayerUID subjectID = dis.readPlayerUID();
PlayerUID destinationID = dis.readPlayerUID();
bais.reset();
PlayerList* players = MinecraftServer::getInstance()->getPlayerList();
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
std::shared_ptr<ServerPlayer> destination =
players->getPlayer(destinationID);
if (subject != NULL && destination != NULL &&
subject->level->dimension->id == destination->level->dimension->id &&
subject->isAlive()) {
subject->ride(nullptr);
subject->connection->teleport(destination->x, destination->y,
destination->z, destination->yRot,
destination->xRot);
// logAdminAction(source, "commands.tp.success", subject->getAName(),
// destination->getAName());
logAdminAction(source, ChatPacket::e_ChatCommandTeleportSuccess,
subject->getName(), eTYPE_SERVERPLAYER,
destination->getName());
if (subject == source) {
destination->sendMessage(subject->getName(),
ChatPacket::e_ChatCommandTeleportToMe);
} else {
subject->sendMessage(destination->getName(),
ChatPacket::e_ChatCommandTeleportMe);
}
}
// if (args.length >= 1) {
// MinecraftServer server = MinecraftServer.getInstance();
// ServerPlayer victim;
// if (args.length == 2 || args.length == 4) {
// victim = server.getPlayers().getPlayer(args[0]);
// if (victim == null) throw new PlayerNotFoundException();
// } else {
// victim = (ServerPlayer) convertSourceToPlayer(source);
// }
// if (args.length == 3 || args.length == 4) {
// if (victim.level != null) {
// int pos = args.length - 3;
// int maxPos = Level.MAX_LEVEL_SIZE;
// int x = convertArgToInt(source, args[pos++], -maxPos,
//maxPos); int y = convertArgToInt(source, args[pos++],
//Level.minBuildHeight, Level.maxBuildHeight); int z =
//convertArgToInt(source, args[pos++], -maxPos, maxPos);
// victim.teleportTo(x + 0.5f, y, z + 0.5f);
// logAdminAction(source, "commands.tp.coordinates",
//victim.getAName(), x, y, z);
// }
// } else if (args.length == 1 || args.length == 2) {
// ServerPlayer destination =
//server.getPlayers().getPlayer(args[args.length - 1]); if (destination ==
//null) throw new PlayerNotFoundException();
// victim.connection.teleport(destination.x, destination.y,
//destination.z, destination.yRot, destination.xRot); logAdminAction(source,
//"commands.tp.success", victim.getAName(), destination.getAName());
// }
//}
}
void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray commandData)
{
ByteArrayInputStream bais(commandData);
DataInputStream dis(&bais);
std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(
PlayerUID subject, PlayerUID destination) {
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
PlayerUID subjectID = dis.readPlayerUID();
PlayerUID destinationID = dis.readPlayerUID();
bais.reset();
dos.writePlayerUID(subject);
dos.writePlayerUID(destination);
PlayerList *players = MinecraftServer::getInstance()->getPlayerList();
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
std::shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() )
{
subject->ride(nullptr);
subject->connection->teleport(destination->x, destination->y, destination->z, destination->yRot, destination->xRot);
//logAdminAction(source, "commands.tp.success", subject->getAName(), destination->getAName());
logAdminAction(source, ChatPacket::e_ChatCommandTeleportSuccess, subject->getName(), eTYPE_SERVERPLAYER, destination->getName());
if(subject == source)
{
destination->sendMessage(subject->getName(), ChatPacket::e_ChatCommandTeleportToMe);
}
else
{
subject->sendMessage(destination->getName(), ChatPacket::e_ChatCommandTeleportMe);
}
}
//if (args.length >= 1) {
// MinecraftServer server = MinecraftServer.getInstance();
// ServerPlayer victim;
// if (args.length == 2 || args.length == 4) {
// victim = server.getPlayers().getPlayer(args[0]);
// if (victim == null) throw new PlayerNotFoundException();
// } else {
// victim = (ServerPlayer) convertSourceToPlayer(source);
// }
// if (args.length == 3 || args.length == 4) {
// if (victim.level != null) {
// int pos = args.length - 3;
// int maxPos = Level.MAX_LEVEL_SIZE;
// int x = convertArgToInt(source, args[pos++], -maxPos, maxPos);
// int y = convertArgToInt(source, args[pos++], Level.minBuildHeight, Level.maxBuildHeight);
// int z = convertArgToInt(source, args[pos++], -maxPos, maxPos);
// victim.teleportTo(x + 0.5f, y, z + 0.5f);
// logAdminAction(source, "commands.tp.coordinates", victim.getAName(), x, y, z);
// }
// } else if (args.length == 1 || args.length == 2) {
// ServerPlayer destination = server.getPlayers().getPlayer(args[args.length - 1]);
// if (destination == null) throw new PlayerNotFoundException();
// victim.connection.teleport(destination.x, destination.y, destination.z, destination.yRot, destination.xRot);
// logAdminAction(source, "commands.tp.success", victim.getAName(), destination.getAName());
// }
//}
}
std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(PlayerUID subject, PlayerUID destination)
{
ByteArrayOutputStream baos;
DataOutputStream dos(&baos);
dos.writePlayerUID(subject);
dos.writePlayerUID(destination);
return std::shared_ptr<GameCommandPacket>( new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray() ));
return std::shared_ptr<GameCommandPacket>(
new GameCommandPacket(eGameCommand_Teleport, baos.toByteArray()));
}

View file

@ -2,11 +2,12 @@
#include "../../Minecraft.World/Commands/Command.h"
class TeleportCommand : public Command
{
class TeleportCommand : public Command {
public:
virtual EGameCommand getId();
virtual void execute(std::shared_ptr<CommandSender> source, byteArray commandData);
virtual EGameCommand getId();
virtual void execute(std::shared_ptr<CommandSender> source,
byteArray commandData);
static std::shared_ptr<GameCommandPacket> preparePacket(PlayerUID subject, PlayerUID destination);
static std::shared_ptr<GameCommandPacket> preparePacket(
PlayerUID subject, PlayerUID destination);
};

View file

@ -10,121 +10,91 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
CreativeMode::CreativeMode(Minecraft *minecraft) : GameMode(minecraft)
{
destroyDelay = 0;
instaBuild = true;
CreativeMode::CreativeMode(Minecraft* minecraft) : GameMode(minecraft) {
destroyDelay = 0;
instaBuild = true;
}
void CreativeMode::init()
{
// initPlayer();
void CreativeMode::init() {
// initPlayer();
}
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player)
{
// please check ServerPlayerGameMode.java if you change these
player->abilities.mayfly = true;
player->abilities.instabuild = true;
player->abilities.invulnerable = true;
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player) {
// please check ServerPlayerGameMode.java if you change these
player->abilities.mayfly = true;
player->abilities.instabuild = true;
player->abilities.invulnerable = true;
}
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player)
{
player->abilities.mayfly = false;
player->abilities.flying = false;
player->abilities.instabuild = false;
player->abilities.invulnerable = false;
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player) {
player->abilities.mayfly = false;
player->abilities.flying = false;
player->abilities.instabuild = false;
player->abilities.invulnerable = false;
}
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player)
{
enableCreativeForPlayer(player);
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player) {
enableCreativeForPlayer(player);
for (int i = 0; i < 9; i++)
{
if (player->inventory->items[i] == NULL)
{
player->inventory->items[i] = std::shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) );
}
else
{
// 4J-PB - this line is commented out in 1.0.1
//player->inventory->items[i]->count = 1;
for (int i = 0; i < 9; i++) {
if (player->inventory->items[i] == NULL) {
player->inventory->items[i] = std::shared_ptr<ItemInstance>(
new ItemInstance(User::allowedTiles[i]));
} else {
// 4J-PB - this line is commented out in 1.0.1
// player->inventory->items[i]->count = 1;
}
}
}
void CreativeMode::creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face)
{
if(!minecraft->level->extinguishFire(minecraft->player, x, y, z, face))
{
gameMode->destroyBlock(x, y, z, face);
}
void CreativeMode::creativeDestroyBlock(Minecraft* minecraft,
GameMode* gameMode, int x, int y, int z,
int face) {
if (!minecraft->level->extinguishFire(minecraft->player, x, y, z, face)) {
gameMode->destroyBlock(x, y, z, face);
}
}
bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
{
int t = level->getTile(x, y, z);
if (t > 0)
{
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
}
if (item == NULL) return false;
int aux = item->getAuxValue();
int count = item->count;
bool success = item->useOn(player, level, x, y, z, face);
item->setAuxValue(aux);
item->count = count;
return success;
bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face, bool bTestUseOnOnly,
bool* pbUsedItem) {
int t = level->getTile(x, y, z);
if (t > 0) {
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
}
if (item == NULL) return false;
int aux = item->getAuxValue();
int count = item->count;
bool success = item->useOn(player, level, x, y, z, face);
item->setAuxValue(aux);
item->count = count;
return success;
}
void CreativeMode::startDestroyBlock(int x, int y, int z, int face)
{
creativeDestroyBlock(minecraft, this, x, y, z, face);
destroyDelay = 5;
void CreativeMode::startDestroyBlock(int x, int y, int z, int face) {
creativeDestroyBlock(minecraft, this, x, y, z, face);
destroyDelay = 5;
}
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face)
{
destroyDelay--;
if (destroyDelay <= 0)
{
destroyDelay = 5;
creativeDestroyBlock(minecraft, this, x, y, z, face);
}
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face) {
destroyDelay--;
if (destroyDelay <= 0) {
destroyDelay = 5;
creativeDestroyBlock(minecraft, this, x, y, z, face);
}
}
void CreativeMode::stopDestroyBlock()
{
}
void CreativeMode::stopDestroyBlock() {}
bool CreativeMode::canHurtPlayer()
{
return false;
}
bool CreativeMode::canHurtPlayer() { return false; }
void CreativeMode::initLevel(Level *level)
{
GameMode::initLevel(level);
}
void CreativeMode::initLevel(Level* level) { GameMode::initLevel(level); }
float CreativeMode::getPickRange()
{
return 5.0f;
}
float CreativeMode::getPickRange() { return 5.0f; }
bool CreativeMode::hasMissTime()
{
return false;
}
bool CreativeMode::hasMissTime() { return false; }
bool CreativeMode::hasInfiniteItems()
{
return true;
}
bool CreativeMode::hasInfiniteItems() { return true; }
bool CreativeMode::hasFarPickRange()
{
return true;
}
bool CreativeMode::hasFarPickRange() { return true; }

View file

@ -1,26 +1,29 @@
#pragma once
#include "GameMode.h"
class CreativeMode : public GameMode
{
class CreativeMode : public GameMode {
private:
int destroyDelay;
int destroyDelay;
public:
CreativeMode(Minecraft *minecraft);
virtual void init();
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
virtual void adjustPlayer(std::shared_ptr<Player> player);
static void creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face);
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL);
virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(int x, int y, int z, int face);
virtual void stopDestroyBlock();
virtual bool canHurtPlayer();
virtual void initLevel(Level *level);
virtual float getPickRange();
virtual bool hasMissTime();
virtual bool hasInfiniteItems();
virtual bool hasFarPickRange();
CreativeMode(Minecraft* minecraft);
virtual void init();
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
virtual void adjustPlayer(std::shared_ptr<Player> player);
static void creativeDestroyBlock(Minecraft* minecraft, GameMode* gameMode,
int x, int y, int z, int face);
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face, bool bTestUseOnOnly = false,
bool* pbUsedItem = NULL);
virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(int x, int y, int z, int face);
virtual void stopDestroyBlock();
virtual bool canHurtPlayer();
virtual void initLevel(Level* level);
virtual float getPickRange();
virtual bool hasMissTime();
virtual bool hasInfiniteItems();
virtual bool hasFarPickRange();
};

View file

@ -2,111 +2,107 @@
#include "DemoMode.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
DemoMode::DemoMode(Minecraft *minecraft) : SurvivalMode(minecraft)
{
demoHasEnded = false;
DemoMode::DemoMode(Minecraft* minecraft) : SurvivalMode(minecraft) {
demoHasEnded = false;
demoEndedReminder = 0;
}
void DemoMode::tick()
{
void DemoMode::tick() {
SurvivalMode::tick();
/* 4J - TODO - seems unlikely we need this demo mode anyway
__int64 time = minecraft->level->getTime();
__int64 day = (time / Level::TICKS_PER_DAY) + 1;
/* 4J - TODO - seems unlikely we need this demo mode anyway
__int64 time = minecraft->level->getTime();
__int64 day = (time / Level::TICKS_PER_DAY) + 1;
demoHasEnded = (time > (500 + Level::TICKS_PER_DAY * DEMO_DAYS));
if (demoHasEnded)
{
demoEndedReminder++;
}
demoHasEnded = (time > (500 + Level::TICKS_PER_DAY * DEMO_DAYS));
if (demoHasEnded)
{
demoEndedReminder++;
}
if ((time % Level::TICKS_PER_DAY) == 500)
{
if (day <= (DEMO_DAYS + 1))
{
minecraft->gui->displayClientMessage(L"demo.day." + _toString<__int64>(day));
if ((time % Level::TICKS_PER_DAY) == 500)
{
if (day <= (DEMO_DAYS + 1))
{
minecraft->gui->displayClientMessage(L"demo.day." +
_toString<__int64>(day));
}
}
}
else if (day == 1)
{
Options *options = minecraft->options;
std::wstring message;
else if (day == 1)
{
Options *options = minecraft->options;
std::wstring message;
if (time == 100) {
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
message = language.getElement("demo.help.movement");
message = String.format(message, Keyboard.getKeyName(options.keyUp.key), Keyboard.getKeyName(options.keyLeft.key), Keyboard.getKeyName(options.keyDown.key),
Keyboard.getKeyName(options.keyRight.key));
} else if (time == 175) {
message = language.getElement("demo.help.jump");
message = String.format(message, Keyboard.getKeyName(options.keyJump.key));
} else if (time == 250) {
message = language.getElement("demo.help.inventory");
message = String.format(message, Keyboard.getKeyName(options.keyBuild.key));
if (time == 100) {
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
message = language.getElement("demo.help.movement");
message = String.format(message,
Keyboard.getKeyName(options.keyUp.key),
Keyboard.getKeyName(options.keyLeft.key),
Keyboard.getKeyName(options.keyDown.key),
Keyboard.getKeyName(options.keyRight.key));
} else if (time == 175) {
message = language.getElement("demo.help.jump");
message = String.format(message,
Keyboard.getKeyName(options.keyJump.key)); } else if (time == 250) {
message = language.getElement("demo.help.inventory");
message = String.format(message,
Keyboard.getKeyName(options.keyBuild.key));
}
if (message != null) {
minecraft.gui.addMessage(message);
}
} else if (day == DEMO_DAYS) {
if ((time % Level.TICKS_PER_DAY) == 22000) {
minecraft.gui.displayClientMessage("demo.day.warning");
}
}
if (message != null) {
minecraft.gui.addMessage(message);
}
} else if (day == DEMO_DAYS) {
if ((time % Level.TICKS_PER_DAY) == 22000) {
minecraft.gui.displayClientMessage("demo.day.warning");
}
}
*/
*/
}
void DemoMode::outputDemoReminder()
{
/* 4J - TODO
if (demoEndedReminder > 100) {
minecraft.gui.displayClientMessage("demo.reminder");
demoEndedReminder = 0;
}
*/
void DemoMode::outputDemoReminder() {
/* 4J - TODO
if (demoEndedReminder > 100) {
minecraft.gui.displayClientMessage("demo.reminder");
demoEndedReminder = 0;
}
*/
}
void DemoMode::startDestroyBlock(int x, int y, int z, int face)
{
if (demoHasEnded)
{
void DemoMode::startDestroyBlock(int x, int y, int z, int face) {
if (demoHasEnded) {
outputDemoReminder();
return;
}
SurvivalMode::startDestroyBlock(x, y, z, face);
}
void DemoMode::continueDestroyBlock(int x, int y, int z, int face)
{
if (demoHasEnded)
{
void DemoMode::continueDestroyBlock(int x, int y, int z, int face) {
if (demoHasEnded) {
return;
}
SurvivalMode::continueDestroyBlock(x, y, z, face);
}
bool DemoMode::destroyBlock(int x, int y, int z, int face)
{
if (demoHasEnded)
{
bool DemoMode::destroyBlock(int x, int y, int z, int face) {
if (demoHasEnded) {
return false;
}
return SurvivalMode::destroyBlock(x, y, z, face);
}
bool DemoMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item)
{
if (demoHasEnded)
{
bool DemoMode::useItem(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item) {
if (demoHasEnded) {
outputDemoReminder();
return false;
}
return SurvivalMode::useItem(player, level, item);
}
bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face)
{
bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face) {
if (demoHasEnded) {
outputDemoReminder();
return false;
@ -114,10 +110,9 @@ bool DemoMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shar
return SurvivalMode::useItemOn(player, level, item, x, y, z, face);
}
void DemoMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{
if (demoHasEnded)
{
void DemoMode::attack(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity) {
if (demoHasEnded) {
outputDemoReminder();
return;
}

View file

@ -1,27 +1,32 @@
#pragma once
#include "SurvivalMode.h"
class DemoMode : public SurvivalMode
{
class DemoMode : public SurvivalMode {
private:
static const int DEMO_DAYS = 5;
static const int DEMO_DAYS = 5;
bool demoHasEnded;
int demoEndedReminder;
public:
DemoMode(Minecraft *minecraft);
DemoMode(Minecraft* minecraft);
virtual void tick();
private:
void outputDemoReminder();
public:
using GameMode::useItem;
using SurvivalMode::useItemOn;
virtual void startDestroyBlock(int x, int y, int z, int face);
private:
void outputDemoReminder();
public:
using GameMode::useItem;
using SurvivalMode::useItemOn;
virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(int x, int y, int z, int face);
virtual bool destroyBlock(int x, int y, int z, int face);
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item);
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face);
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual bool useItem(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item);
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face);
virtual void attack(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity);
};

View file

@ -1,6 +1,4 @@
#include "../Platform/stdafx.h"
#include "DemoUser.h"
DemoUser::DemoUser() : User(L"DemoUser", L"n/a")
{
}
DemoUser::DemoUser() : User(L"DemoUser", L"n/a") {}

View file

@ -1,8 +1,7 @@
#pragma once
#include "../Player/User.h"
class DemoUser : public User
{
class DemoUser : public User {
public:
DemoUser();
DemoUser();
};

View file

@ -11,60 +11,55 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
GameMode::GameMode(Minecraft *minecraft)
{
instaBuild = false; // 4J - added
this->minecraft = minecraft;
GameMode::GameMode(Minecraft* minecraft) {
instaBuild = false; // 4J - added
this->minecraft = minecraft;
}
void GameMode::initLevel(Level *level)
{
}
void GameMode::initLevel(Level* level) {}
bool GameMode::destroyBlock(int x, int y, int z, int face)
{
Level *level = minecraft->level;
Tile *oldTile = Tile::tiles[level->getTile(x, y, z)];
if (oldTile == NULL) return false;
bool GameMode::destroyBlock(int x, int y, int z, int face) {
Level* level = minecraft->level;
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
if (oldTile == NULL) return false;
// 4J - Let the rendering side of thing know we are about to destroy the tile, so we can synchronise collision with async render data upates.
minecraft->levelRenderer->destroyedTileManager->destroyingTileAt(level, x, y, z);
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
// 4J - Let the rendering side of thing know we are about to destroy the
// tile, so we can synchronise collision with async render data upates.
minecraft->levelRenderer->destroyedTileManager->destroyingTileAt(level, x,
y, z);
level->levelEvent(
LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z,
oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
int data = level->getData(x, y, z);
// 4J - before we remove the tile, recalc the heightmap - setTile depends on this being valid to be able to do
// a quick update of skylighting when the block is removed, and there are cases with falling tiles where this can get out of sync
level->getChunkAt(x,z)->recalcHeightmapOnly();
// 4J - before we remove the tile, recalc the heightmap - setTile depends on
// this being valid to be able to do a quick update of skylighting when the
// block is removed, and there are cases with falling tiles where this can
// get out of sync
level->getChunkAt(x, z)->recalcHeightmapOnly();
bool changed = level->setTile(x, y, z, 0);
if (oldTile != NULL && changed)
{
if (oldTile != NULL && changed) {
oldTile->destroy(level, x, y, z, data);
}
return changed;
}
void GameMode::render(float a)
{
void GameMode::render(float a) {}
bool GameMode::useItem(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, bool bTestUseOnly) {
return false;
}
bool GameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
{
return false;
}
void GameMode::initPlayer(std::shared_ptr<Player> player) {}
void GameMode::initPlayer(std::shared_ptr<Player> player)
{
}
void GameMode::tick() {}
void GameMode::tick()
{
}
void GameMode::adjustPlayer(std::shared_ptr<Player> player) {}
void GameMode::adjustPlayer(std::shared_ptr<Player> player)
{
}
//bool GameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly)
// bool GameMode::useItemOn(std::shared_ptr<Player> player, Level *level,
// std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool
// bTestUseOnOnly)
//{
// // 4J-PB - Adding a test only version to allow tooltips to be displayed
// int t = level->getTile(x, y, z);
@ -74,9 +69,10 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
// {
// switch(t)
// {
// case Tile::recordPlayer_Id:
// case Tile::recordPlayer_Id:
// case Tile::bed_Id: // special case for a bed
// if (Tile::tiles[t]->TestUse(level, x, y, z, player ))
// if (Tile::tiles[t]->TestUse(level, x, y, z,
//player ))
// {
// return true;
// }
@ -91,94 +87,73 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
// break;
// }
// }
// else
// else
// {
// if (Tile::tiles[t]->use(level, x, y, z, player )) return true;
// if (Tile::tiles[t]->use(level, x, y, z, player )) return
//true;
// }
// }
//
// if (item == NULL) return false;
// return item->useOn(player, level, x, y, z, face, bTestUseOnOnly);
//}
//
// if (item == NULL) return false;
// return item->useOn(player, level, x, y, z, face, bTestUseOnOnly);
// }
std::shared_ptr<Player> GameMode::createPlayer(Level *level)
{
return std::shared_ptr<Player>( new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id) );
std::shared_ptr<Player> GameMode::createPlayer(Level* level) {
return std::shared_ptr<Player>(new LocalPlayer(
minecraft, level, minecraft->user, level->dimension->id));
}
bool GameMode::interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{
return player->interact(entity);
bool GameMode::interact(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity) {
return player->interact(entity);
}
void GameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
{
player->attack(entity);
void GameMode::attack(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity) {
player->attack(entity);
}
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
{
return nullptr;
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(
int containerId, int slotNum, int buttonNum, bool quickKeyHeld,
std::shared_ptr<Player> player) {
return nullptr;
}
void GameMode::handleCloseInventory(int containerId, std::shared_ptr<Player> player)
{
void GameMode::handleCloseInventory(int containerId,
std::shared_ptr<Player> player) {
player->containerMenu->removed(player);
delete player->containerMenu;
delete player->containerMenu;
player->containerMenu = player->inventoryMenu;
}
void GameMode::handleInventoryButtonClick(int containerId, int buttonId)
{
void GameMode::handleInventoryButtonClick(int containerId, int buttonId) {}
bool GameMode::isCutScene() { return false; }
void GameMode::releaseUsingItem(std::shared_ptr<Player> player) {
player->releaseUsingItem();
}
bool GameMode::isCutScene()
{
return false;
}
bool GameMode::hasExperience() { return false; }
void GameMode::releaseUsingItem(std::shared_ptr<Player> player)
{
player->releaseUsingItem();
}
bool GameMode::hasMissTime() { return true; }
bool GameMode::hasExperience()
{
return false;
}
bool GameMode::hasInfiniteItems() { return false; }
bool GameMode::hasMissTime()
{
return true;
}
bool GameMode::hasFarPickRange() { return false; }
bool GameMode::hasInfiniteItems()
{
return false;
}
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked,
int i) {}
bool GameMode::hasFarPickRange()
{
return false;
}
void GameMode::handleCreativeModeItemDrop(
std::shared_ptr<ItemInstance> clicked) {}
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i)
{
}
void GameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
{
}
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
{
return true;
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player) {
return true;
}
// 4J-PB
void GameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
{
player->SetDebugOptions(uiVal);
void GameMode::handleDebugOptions(unsigned int uiVal,
std::shared_ptr<Player> player) {
player->SetDebugOptions(uiVal);
}

View file

@ -8,17 +8,17 @@ class Entity;
class Tutorial;
class GameMode
{
class GameMode {
protected:
Minecraft *minecraft;
Minecraft* minecraft;
public:
bool instaBuild;
bool instaBuild;
GameMode(Minecraft *minecraft);
virtual ~GameMode() {}
GameMode(Minecraft* minecraft);
virtual ~GameMode() {}
virtual void initLevel(Level *level) ;
virtual void initLevel(Level* level);
virtual void startDestroyBlock(int x, int y, int z, int face) = 0;
virtual bool destroyBlock(int x, int y, int z, int face);
virtual void continueDestroyBlock(int x, int y, int z, int face) = 0;
@ -29,31 +29,44 @@ public:
virtual void tick();
virtual bool canHurtPlayer() = 0;
virtual void adjustPlayer(std::shared_ptr<Player> player);
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem = NULL) = 0;
virtual bool useItem(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item,
bool bTestUseOnly = false);
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face, bool bTestUseOnOnly = false,
bool* pbUsedItem = NULL) = 0;
virtual std::shared_ptr<Player> createPlayer(Level *level);
virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player);
virtual void handleCloseInventory(int containerId, std::shared_ptr<Player> player);
virtual void handleInventoryButtonClick(int containerId, int buttonId);
virtual std::shared_ptr<Player> createPlayer(Level* level);
virtual bool interact(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity);
virtual void attack(std::shared_ptr<Player> player,
std::shared_ptr<Entity> entity);
virtual std::shared_ptr<ItemInstance> handleInventoryMouseClick(
int containerId, int slotNum, int buttonNum, bool quickKeyHeld,
std::shared_ptr<Player> player);
virtual void handleCloseInventory(int containerId,
std::shared_ptr<Player> player);
virtual void handleInventoryButtonClick(int containerId, int buttonId);
virtual bool isCutScene();
virtual void releaseUsingItem(std::shared_ptr<Player> player);
virtual bool hasExperience();
virtual bool hasMissTime();
virtual bool hasInfiniteItems();
virtual bool hasFarPickRange();
virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i);
virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
virtual bool isCutScene();
virtual void releaseUsingItem(std::shared_ptr<Player> player);
virtual bool hasExperience();
virtual bool hasMissTime();
virtual bool hasInfiniteItems();
virtual bool hasFarPickRange();
virtual void handleCreativeModeItemAdd(
std::shared_ptr<ItemInstance> clicked, int i);
virtual void handleCreativeModeItemDrop(
std::shared_ptr<ItemInstance> clicked);
// 4J Stu - Added so we can send packets for this in the network game
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
// 4J Stu - Added so we can send packets for this in the network game
virtual bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
virtual void handleDebugOptions(unsigned int uiVal,
std::shared_ptr<Player> player);
// 4J Stu - Added for tutorial checks
virtual bool isInputAllowed(int mapping) { return true; }
virtual bool isTutorial() { return false; }
virtual Tutorial *getTutorial() { return NULL; }
// 4J Stu - Added for tutorial checks
virtual bool isInputAllowed(int mapping) { return true; }
virtual bool isTutorial() { return false; }
virtual Tutorial* getTutorial() { return NULL; }
};

View file

@ -14,100 +14,90 @@
#include "../../Minecraft.World/IO/Streams/DataOutputStream.h"
#include "../../Minecraft.World/Util/StringHelpers.h"
// 4J - the Option sub-class used to be an java enumerated type, trying to emulate that functionality here
const Options::Option Options::Option::options[17] =
{
Options::Option(L"options.music", true, false),
Options::Option(L"options.sound", true, false),
Options::Option(L"options.invertMouse", false, true),
Options::Option(L"options.sensitivity", true, false),
Options::Option(L"options.renderDistance", false, false),
Options::Option(L"options.viewBobbing", false, true),
Options::Option(L"options.anaglyph", false, true),
Options::Option(L"options.advancedOpengl", false, true),
Options::Option(L"options.framerateLimit", false, false),
Options::Option(L"options.difficulty", false, false),
Options::Option(L"options.graphics", false, false),
Options::Option(L"options.ao", false, true),
Options::Option(L"options.guiScale", false, false),
Options::Option(L"options.fov", true, false),
Options::Option(L"options.gamma", true, false),
Options::Option(L"options.renderClouds",false, true),
Options::Option(L"options.particles", false, false),
// 4J - the Option sub-class used to be an java enumerated type, trying to
// emulate that functionality here
const Options::Option Options::Option::options[17] = {
Options::Option(L"options.music", true, false),
Options::Option(L"options.sound", true, false),
Options::Option(L"options.invertMouse", false, true),
Options::Option(L"options.sensitivity", true, false),
Options::Option(L"options.renderDistance", false, false),
Options::Option(L"options.viewBobbing", false, true),
Options::Option(L"options.anaglyph", false, true),
Options::Option(L"options.advancedOpengl", false, true),
Options::Option(L"options.framerateLimit", false, false),
Options::Option(L"options.difficulty", false, false),
Options::Option(L"options.graphics", false, false),
Options::Option(L"options.ao", false, true),
Options::Option(L"options.guiScale", false, false),
Options::Option(L"options.fov", true, false),
Options::Option(L"options.gamma", true, false),
Options::Option(L"options.renderClouds", false, true),
Options::Option(L"options.particles", false, false),
};
const Options::Option *Options::Option::MUSIC = &Options::Option::options[0];
const Options::Option *Options::Option::SOUND = &Options::Option::options[1];
const Options::Option *Options::Option::INVERT_MOUSE = &Options::Option::options[2];
const Options::Option *Options::Option::SENSITIVITY = &Options::Option::options[3];
const Options::Option *Options::Option::RENDER_DISTANCE = &Options::Option::options[4];
const Options::Option *Options::Option::VIEW_BOBBING = &Options::Option::options[5];
const Options::Option *Options::Option::ANAGLYPH = &Options::Option::options[6];
const Options::Option *Options::Option::ADVANCED_OPENGL = &Options::Option::options[7];
const Options::Option *Options::Option::FRAMERATE_LIMIT = &Options::Option::options[8];
const Options::Option *Options::Option::DIFFICULTY = &Options::Option::options[9];
const Options::Option *Options::Option::GRAPHICS = &Options::Option::options[10];
const Options::Option *Options::Option::AMBIENT_OCCLUSION = &Options::Option::options[11];
const Options::Option *Options::Option::GUI_SCALE = &Options::Option::options[12];
const Options::Option *Options::Option::FOV = &Options::Option::options[13];
const Options::Option *Options::Option::GAMMA = &Options::Option::options[14];
const Options::Option *Options::Option::RENDER_CLOUDS = &Options::Option::options[15];
const Options::Option *Options::Option::PARTICLES = &Options::Option::options[16];
const Options::Option* Options::Option::MUSIC = &Options::Option::options[0];
const Options::Option* Options::Option::SOUND = &Options::Option::options[1];
const Options::Option* Options::Option::INVERT_MOUSE =
&Options::Option::options[2];
const Options::Option* Options::Option::SENSITIVITY =
&Options::Option::options[3];
const Options::Option* Options::Option::RENDER_DISTANCE =
&Options::Option::options[4];
const Options::Option* Options::Option::VIEW_BOBBING =
&Options::Option::options[5];
const Options::Option* Options::Option::ANAGLYPH = &Options::Option::options[6];
const Options::Option* Options::Option::ADVANCED_OPENGL =
&Options::Option::options[7];
const Options::Option* Options::Option::FRAMERATE_LIMIT =
&Options::Option::options[8];
const Options::Option* Options::Option::DIFFICULTY =
&Options::Option::options[9];
const Options::Option* Options::Option::GRAPHICS =
&Options::Option::options[10];
const Options::Option* Options::Option::AMBIENT_OCCLUSION =
&Options::Option::options[11];
const Options::Option* Options::Option::GUI_SCALE =
&Options::Option::options[12];
const Options::Option* Options::Option::FOV = &Options::Option::options[13];
const Options::Option* Options::Option::GAMMA = &Options::Option::options[14];
const Options::Option* Options::Option::RENDER_CLOUDS =
&Options::Option::options[15];
const Options::Option* Options::Option::PARTICLES =
&Options::Option::options[16];
const Options::Option* Options::Option::getItem(int id) { return &options[id]; }
const Options::Option *Options::Option::getItem(int id)
{
return &options[id];
}
Options::Option::Option(const std::wstring& captionId, bool hasProgress,
bool isBoolean)
: _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId) {}
Options::Option::Option(const std::wstring& captionId, bool hasProgress, bool isBoolean) : _isProgress(hasProgress), _isBoolean(isBoolean), captionId(captionId)
{
}
bool Options::Option::isProgress() const { return _isProgress; }
bool Options::Option::isProgress() const
{
return _isProgress;
}
bool Options::Option::isBoolean() const { return _isBoolean; }
bool Options::Option::isBoolean() const
{
return _isBoolean;
}
int Options::Option::getId() const { return (int)(this - options); }
int Options::Option::getId() const
{
return (int)(this-options);
}
std::wstring Options::Option::getCaptionId() const { return captionId; }
std::wstring Options::Option::getCaptionId() const
{
return captionId;
}
const std::wstring Options::RENDER_DISTANCE_NAMES[] = {
L"options.renderDistance.far", L"options.renderDistance.normal",
L"options.renderDistance.short", L"options.renderDistance.tiny"};
const std::wstring Options::DIFFICULTY_NAMES[] = {
L"options.difficulty.peaceful", L"options.difficulty.easy",
L"options.difficulty.normal", L"options.difficulty.hard"};
const std::wstring Options::GUI_SCALE[] = {
L"options.guiScale.auto", L"options.guiScale.small",
L"options.guiScale.normal", L"options.guiScale.large"};
const std::wstring Options::FRAMERATE_LIMITS[] = {
L"performance.max", L"performance.balanced", L"performance.powersaver"};
const std::wstring Options::RENDER_DISTANCE_NAMES[] =
{
L"options.renderDistance.far", L"options.renderDistance.normal", L"options.renderDistance.short", L"options.renderDistance.tiny"
};
const std::wstring Options::DIFFICULTY_NAMES[] =
{
L"options.difficulty.peaceful", L"options.difficulty.easy", L"options.difficulty.normal", L"options.difficulty.hard"
};
const std::wstring Options::GUI_SCALE[] =
{
L"options.guiScale.auto", L"options.guiScale.small", L"options.guiScale.normal", L"options.guiScale.large"
};
const std::wstring Options::FRAMERATE_LIMITS[] =
{
L"performance.max", L"performance.balanced", L"performance.powersaver"
};
const std::wstring Options::PARTICLES[] = {
L"options.particles.all", L"options.particles.decreased", L"options.particles.minimal"
};
const std::wstring Options::PARTICLES[] = {L"options.particles.all",
L"options.particles.decreased",
L"options.particles.minimal"};
// 4J added
void Options::init()
{
void Options::init() {
music = 1;
sound = 1;
sensitivity = 0.5f;
@ -116,16 +106,16 @@ void Options::init()
bobView = true;
anaglyph3d = false;
advancedOpengl = false;
//4JCRAFT V-Sync / VSync
#ifdef ENABLE_VSYNC
// 4JCRAFT V-Sync / VSync
#ifdef ENABLE_VSYNC
framerateLimit = 2;
#else
#else
framerateLimit = 3;
#endif
#endif
fancyGraphics = true;
ambientOcclusion = true;
renderClouds = true;
renderClouds = true;
skin = L"Default";
keyUp = new KeyMapping(L"key.forward", Keyboard::KEY_W);
@ -137,395 +127,348 @@ void Options::init()
keyDrop = new KeyMapping(L"key.drop", Keyboard::KEY_Q);
keyChat = new KeyMapping(L"key.chat", Keyboard::KEY_T);
keySneak = new KeyMapping(L"key.sneak", Keyboard::KEY_LSHIFT);
keyAttack = new KeyMapping(L"key.attack", -100 + 0);
keyAttack = new KeyMapping(L"key.attack", -100 + 0);
keyUse = new KeyMapping(L"key.use", -100 + 1);
keyPlayerList = new KeyMapping(L"key.playerlist", Keyboard::KEY_TAB);
keyPickItem = new KeyMapping(L"key.pickItem", -100 + 2);
keyToggleFog = new KeyMapping(L"key.fog", Keyboard::KEY_F);
keyMappings[0] = keyAttack;
keyMappings[1] = keyUse;
keyMappings[0] = keyAttack;
keyMappings[1] = keyUse;
keyMappings[2] = keyUp;
keyMappings[3] = keyLeft;
keyMappings[4] = keyDown;
keyMappings[5] = keyRight;
keyMappings[6] = keyJump;
keyMappings[7] = keySneak;
keyMappings[8] = keyDrop;
keyMappings[9] = keyBuild;
keyMappings[10] = keyChat;
keyMappings[11] = keyPlayerList;
keyMappings[12] = keyPickItem;
keyMappings[13] = keyToggleFog;
keyMappings[3] = keyLeft;
keyMappings[4] = keyDown;
keyMappings[5] = keyRight;
keyMappings[6] = keyJump;
keyMappings[7] = keySneak;
keyMappings[8] = keyDrop;
keyMappings[9] = keyBuild;
keyMappings[10] = keyChat;
keyMappings[11] = keyPlayerList;
keyMappings[12] = keyPickItem;
keyMappings[13] = keyToggleFog;
minecraft = NULL;
//optionsFile = NULL;
minecraft = NULL;
// optionsFile = NULL;
difficulty = 2;
hideGui = false;
thirdPersonView = false;
renderDebug = false;
lastMpIp = L"";
difficulty = 2;
hideGui = false;
thirdPersonView = false;
renderDebug = false;
lastMpIp = L"";
isFlying = false;
smoothCamera = false;
fixedCamera = false;
flySpeed = 1;
cameraSpeed = 1;
guiScale = 0;
particles = 0;
fov = 0;
gamma = 0;
isFlying = false;
smoothCamera = false;
fixedCamera = false;
flySpeed = 1;
cameraSpeed = 1;
guiScale = 0;
particles = 0;
fov = 0;
gamma = 0;
}
Options::Options(Minecraft *minecraft, File workingDirectory)
{
init();
this->minecraft = minecraft;
optionsFile = File(workingDirectory, L"options.txt");
Options::Options(Minecraft* minecraft, File workingDirectory) {
init();
this->minecraft = minecraft;
optionsFile = File(workingDirectory, L"options.txt");
}
Options::Options()
{
init();
}
Options::Options() { init(); }
std::wstring Options::getKeyDescription(int i)
{
Language *language = Language::getInstance();
std::wstring Options::getKeyDescription(int i) {
Language* language = Language::getInstance();
return language->getElement(keyMappings[i]->name);
}
std::wstring Options::getKeyMessage(int i)
{
int key = keyMappings[i]->key;
if (key < 0) {
return I18n::get(L"key.mouseButton", key + 101);
} else {
return Keyboard::getKeyName(keyMappings[i]->key);
}
std::wstring Options::getKeyMessage(int i) {
int key = keyMappings[i]->key;
if (key < 0) {
return I18n::get(L"key.mouseButton", key + 101);
} else {
return Keyboard::getKeyName(keyMappings[i]->key);
}
}
void Options::setKey(int i, int key)
{
void Options::setKey(int i, int key) {
keyMappings[i]->key = key;
save();
}
void Options::set(const Options::Option *item, float fVal)
{
if (item == Option::MUSIC)
{
void Options::set(const Options::Option* item, float fVal) {
if (item == Option::MUSIC) {
music = fVal;
#ifdef _XBOX
minecraft->soundEngine->updateMusicVolume(fVal*2.0f);
minecraft->soundEngine->updateMusicVolume(fVal * 2.0f);
#else
minecraft->soundEngine->updateMusicVolume(fVal);
minecraft->soundEngine->updateMusicVolume(fVal);
#endif
}
if (item == Option::SOUND)
{
if (item == Option::SOUND) {
sound = fVal;
#ifdef _XBOX
minecraft->soundEngine->updateSoundEffectVolume(fVal*2.0f);
minecraft->soundEngine->updateSoundEffectVolume(fVal * 2.0f);
#else
minecraft->soundEngine->updateSoundEffectVolume(fVal);
minecraft->soundEngine->updateSoundEffectVolume(fVal);
#endif
}
if (item == Option::SENSITIVITY)
{
if (item == Option::SENSITIVITY) {
sensitivity = fVal;
}
if (item == Option::FOV)
{
fov = fVal;
}
if (item == Option::GAMMA)
{
gamma = fVal;
}
if (item == Option::FOV) {
fov = fVal;
}
if (item == Option::GAMMA) {
gamma = fVal;
}
}
void Options::toggle(const Options::Option *option, int dir)
{
void Options::toggle(const Options::Option* option, int dir) {
if (option == Option::INVERT_MOUSE) invertYMouse = !invertYMouse;
if (option == Option::RENDER_DISTANCE) viewDistance = (viewDistance + dir) & 3;
if (option == Option::RENDER_DISTANCE)
viewDistance = (viewDistance + dir) & 3;
if (option == Option::GUI_SCALE) guiScale = (guiScale + dir) & 3;
if (option == Option::PARTICLES) particles = (particles + dir) % 3;
if (option == Option::PARTICLES) particles = (particles + dir) % 3;
// 4J-PB - changing
//if (option == Option::VIEW_BOBBING) bobView = !bobView;
if (option == Option::VIEW_BOBBING) ((dir==0)?bobView=false: bobView=true);
if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds;
if (option == Option::ADVANCED_OPENGL)
{
// 4J-PB - changing
// if (option == Option::VIEW_BOBBING) bobView = !bobView;
if (option == Option::VIEW_BOBBING)
((dir == 0) ? bobView = false : bobView = true);
if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds;
if (option == Option::ADVANCED_OPENGL) {
advancedOpengl = !advancedOpengl;
minecraft->levelRenderer->allChanged();
}
if (option == Option::ANAGLYPH)
{
if (option == Option::ANAGLYPH) {
anaglyph3d = !anaglyph3d;
minecraft->textures->reloadAll();
}
if (option == Option::FRAMERATE_LIMIT) framerateLimit = (framerateLimit + dir + 3) % 3;
if (option == Option::FRAMERATE_LIMIT)
framerateLimit = (framerateLimit + dir + 3) % 3;
// 4J-PB - Change for Xbox
//if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3;
if (option == Option::DIFFICULTY) difficulty = (dir) & 3;
// 4J-PB - Change for Xbox
// if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3;
if (option == Option::DIFFICULTY) difficulty = (dir) & 3;
app.DebugPrintf("Option::DIFFICULTY = %d",difficulty);
app.DebugPrintf("Option::DIFFICULTY = %d", difficulty);
if (option == Option::GRAPHICS)
{
if (option == Option::GRAPHICS) {
fancyGraphics = !fancyGraphics;
minecraft->levelRenderer->allChanged();
}
if (option == Option::AMBIENT_OCCLUSION)
{
if (option == Option::AMBIENT_OCCLUSION) {
ambientOcclusion = !ambientOcclusion;
minecraft->levelRenderer->allChanged();
}
// 4J-PB - don't do the file save on the xbox
// 4J-PB - don't do the file save on the xbox
// save();
}
float Options::getProgressValue(const Options::Option *item)
{
if (item == Option::FOV) return fov;
if (item == Option::GAMMA) return gamma;
float Options::getProgressValue(const Options::Option* item) {
if (item == Option::FOV) return fov;
if (item == Option::GAMMA) return gamma;
if (item == Option::MUSIC) return music;
if (item == Option::SOUND) return sound;
if (item == Option::SENSITIVITY) return sensitivity;
return 0;
}
bool Options::getBooleanValue(const Options::Option *item)
{
// 4J - was a switch statement which we can't do with our Option:: pointer types
if( item == Option::INVERT_MOUSE) return invertYMouse;
if( item == Option::VIEW_BOBBING) return bobView;
if( item == Option::ANAGLYPH) return anaglyph3d;
if( item == Option::ADVANCED_OPENGL) return advancedOpengl;
if( item == Option::AMBIENT_OCCLUSION) return ambientOcclusion;
if( item == Option::RENDER_CLOUDS) return renderClouds;
return false;
bool Options::getBooleanValue(const Options::Option* item) {
// 4J - was a switch statement which we can't do with our Option:: pointer
// types
if (item == Option::INVERT_MOUSE) return invertYMouse;
if (item == Option::VIEW_BOBBING) return bobView;
if (item == Option::ANAGLYPH) return anaglyph3d;
if (item == Option::ADVANCED_OPENGL) return advancedOpengl;
if (item == Option::AMBIENT_OCCLUSION) return ambientOcclusion;
if (item == Option::RENDER_CLOUDS) return renderClouds;
return false;
}
std::wstring Options::getMessage(const Options::Option *item)
{
// 4J TODO, should these std::wstrings append rather than add?
std::wstring Options::getMessage(const Options::Option* item) {
// 4J TODO, should these std::wstrings append rather than add?
Language *language = Language::getInstance();
Language* language = Language::getInstance();
std::wstring caption = language->getElement(item->getCaptionId()) + L": ";
if (item->isProgress())
{
if (item->isProgress()) {
float progressValue = getProgressValue(item);
if (item == Option::SENSITIVITY)
{
if (progressValue == 0)
{
return caption + language->getElement(L"options.sensitivity.min");
if (item == Option::SENSITIVITY) {
if (progressValue == 0) {
return caption +
language->getElement(L"options.sensitivity.min");
}
if (progressValue == 1)
{
return caption + language->getElement(L"options.sensitivity.max");
if (progressValue == 1) {
return caption +
language->getElement(L"options.sensitivity.max");
}
return caption + _toString<int>((int) (progressValue * 200)) + L"%";
} else if (item == Option::FOV)
{
if (progressValue == 0)
{
return caption + language->getElement(L"options.fov.min");
}
if (progressValue == 1)
{
return caption + language->getElement(L"options.fov.max");
}
return caption + _toString<int>((int) (70 + progressValue * 40));
} else if (item == Option::GAMMA)
{
if (progressValue == 0)
{
return caption + language->getElement(L"options.gamma.min");
}
if (progressValue == 1)
{
return caption + language->getElement(L"options.gamma.max");
}
return caption + L"+" + _toString<int>((int) (progressValue * 100)) + L"%";
}
else
{
if (progressValue == 0)
{
return caption + _toString<int>((int)(progressValue * 200)) + L"%";
} else if (item == Option::FOV) {
if (progressValue == 0) {
return caption + language->getElement(L"options.fov.min");
}
if (progressValue == 1) {
return caption + language->getElement(L"options.fov.max");
}
return caption + _toString<int>((int)(70 + progressValue * 40));
} else if (item == Option::GAMMA) {
if (progressValue == 0) {
return caption + language->getElement(L"options.gamma.min");
}
if (progressValue == 1) {
return caption + language->getElement(L"options.gamma.max");
}
return caption + L"+" + _toString<int>((int)(progressValue * 100)) +
L"%";
} else {
if (progressValue == 0) {
return caption + language->getElement(L"options.off");
}
return caption + _toString<int>((int) (progressValue * 100)) + L"%";
return caption + _toString<int>((int)(progressValue * 100)) + L"%";
}
} else if (item->isBoolean())
{
} else if (item->isBoolean()) {
bool booleanValue = getBooleanValue(item);
if (booleanValue)
{
if (booleanValue) {
return caption + language->getElement(L"options.on");
}
return caption + language->getElement(L"options.off");
}
else if (item == Option::RENDER_DISTANCE)
{
return caption + language->getElement(RENDER_DISTANCE_NAMES[viewDistance]);
}
else if (item == Option::DIFFICULTY)
{
} else if (item == Option::RENDER_DISTANCE) {
return caption +
language->getElement(RENDER_DISTANCE_NAMES[viewDistance]);
} else if (item == Option::DIFFICULTY) {
return caption + language->getElement(DIFFICULTY_NAMES[difficulty]);
}
else if (item == Option::GUI_SCALE)
{
} else if (item == Option::GUI_SCALE) {
return caption + language->getElement(GUI_SCALE[guiScale]);
}
else if (item == Option::PARTICLES)
{
return caption + language->getElement(PARTICLES[particles]);
}
else if (item == Option::FRAMERATE_LIMIT)
{
} else if (item == Option::PARTICLES) {
return caption + language->getElement(PARTICLES[particles]);
} else if (item == Option::FRAMERATE_LIMIT) {
return caption + I18n::get(FRAMERATE_LIMITS[framerateLimit]);
}
else if (item == Option::GRAPHICS)
{
if (fancyGraphics)
{
} else if (item == Option::GRAPHICS) {
if (fancyGraphics) {
return caption + language->getElement(L"options.graphics.fancy");
}
return caption + language->getElement(L"options.graphics.fast");
}
return caption;
}
void Options::load()
{
// 4J - removed try/catch
// try {
if (!optionsFile.exists()) return;
// 4J - was new BufferedReader(new FileReader(optionsFile));
BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) );
std::wstring line = L"";
while ((line = br->readLine()) != L"") // 4J - was check against NULL - do we need to distinguish between empty lines and a fail here?
{
// 4J - removed try/catch
// try {
std::wstring cmds[2];
int splitpos = (int)line.find(L":");
if( splitpos == std::wstring::npos )
{
cmds[0] = line;
cmds[1] = L"";
}
else
{
cmds[0] = line.substr(0,splitpos);
cmds[1] = line.substr(splitpos,line.length()-splitpos);
}
void Options::load() {
// 4J - removed try/catch
// try {
if (!optionsFile.exists()) return;
// 4J - was new BufferedReader(new FileReader(optionsFile));
BufferedReader* br = new BufferedReader(
new InputStreamReader(new FileInputStream(optionsFile)));
if (cmds[0] == L"music") music = readFloat(cmds[1]);
if (cmds[0] == L"sound") sound = readFloat(cmds[1]);
if (cmds[0] == L"mouseSensitivity") sensitivity = readFloat(cmds[1]);
if (cmds[0] == L"fov") fov = readFloat(cmds[1]);
if (cmds[0] == L"gamma") gamma = readFloat(cmds[1]);
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1]==L"true";
if (cmds[0] == L"viewDistance") viewDistance = _fromString<int>(cmds[1]);
if (cmds[0] == L"guiScale") guiScale =_fromString<int>(cmds[1]);
if (cmds[0] == L"particles") particles = _fromString<int>(cmds[1]);
if (cmds[0] == L"bobView") bobView = cmds[1]==L"true";
if (cmds[0] == L"anaglyph3d") anaglyph3d = cmds[1]==L"true";
if (cmds[0] == L"advancedOpengl") advancedOpengl = cmds[1]==L"true";
if (cmds[0] == L"fpsLimit") framerateLimit = _fromString<int>(cmds[1]);
if (cmds[0] == L"difficulty") difficulty = _fromString<int>(cmds[1]);
if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1]==L"true";
if (cmds[0] == L"ao") ambientOcclusion = cmds[1]==L"true";
if (cmds[0] == L"clouds") renderClouds = cmds[1]==L"true";
if (cmds[0] == L"skin") skin = cmds[1];
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
for (int i = 0; i < keyMappings_length; i++)
{
if (cmds[0] == (L"key_" + keyMappings[i]->name))
{
keyMappings[i]->key = _fromString<int>(cmds[1]);
}
}
// } catch (Exception e) {
// System.out.println("Skipping bad option: " + line);
// }
std::wstring line = L"";
while ((line = br->readLine()) !=
L"") // 4J - was check against NULL - do we need to distinguish
// between empty lines and a fail here?
{
// 4J - removed try/catch
// try {
std::wstring cmds[2];
int splitpos = (int)line.find(L":");
if (splitpos == std::wstring::npos) {
cmds[0] = line;
cmds[1] = L"";
} else {
cmds[0] = line.substr(0, splitpos);
cmds[1] = line.substr(splitpos, line.length() - splitpos);
}
//KeyMapping.resetMapping(); // 4J Not implemented
br->close();
// } catch (Exception e) {
// System.out.println("Failed to load options");
// e.printStackTrace();
// }
if (cmds[0] == L"music") music = readFloat(cmds[1]);
if (cmds[0] == L"sound") sound = readFloat(cmds[1]);
if (cmds[0] == L"mouseSensitivity") sensitivity = readFloat(cmds[1]);
if (cmds[0] == L"fov") fov = readFloat(cmds[1]);
if (cmds[0] == L"gamma") gamma = readFloat(cmds[1]);
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1] == L"true";
if (cmds[0] == L"viewDistance")
viewDistance = _fromString<int>(cmds[1]);
if (cmds[0] == L"guiScale") guiScale = _fromString<int>(cmds[1]);
if (cmds[0] == L"particles") particles = _fromString<int>(cmds[1]);
if (cmds[0] == L"bobView") bobView = cmds[1] == L"true";
if (cmds[0] == L"anaglyph3d") anaglyph3d = cmds[1] == L"true";
if (cmds[0] == L"advancedOpengl") advancedOpengl = cmds[1] == L"true";
if (cmds[0] == L"fpsLimit") framerateLimit = _fromString<int>(cmds[1]);
if (cmds[0] == L"difficulty") difficulty = _fromString<int>(cmds[1]);
if (cmds[0] == L"fancyGraphics") fancyGraphics = cmds[1] == L"true";
if (cmds[0] == L"ao") ambientOcclusion = cmds[1] == L"true";
if (cmds[0] == L"clouds") renderClouds = cmds[1] == L"true";
if (cmds[0] == L"skin") skin = cmds[1];
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
for (int i = 0; i < keyMappings_length; i++) {
if (cmds[0] == (L"key_" + keyMappings[i]->name)) {
keyMappings[i]->key = _fromString<int>(cmds[1]);
}
}
// } catch (Exception e) {
// System.out.println("Skipping bad option: " + line);
// }
}
// KeyMapping.resetMapping(); // 4J Not implemented
br->close();
// } catch (Exception e) {
// System.out.println("Failed to load options");
// e.printStackTrace();
// }
}
float Options::readFloat(std::wstring string)
{
float Options::readFloat(std::wstring string) {
if (string == L"true") return 1;
if (string == L"false") return 0;
return _fromString<float>(string);
}
void Options::save()
{
// 4J - try/catch removed
// try {
void Options::save() {
// 4J - try/catch removed
// try {
// 4J - original used a PrintWriter & FileWriter, but seems a bit much implementing these just to do this
FileOutputStream fos = FileOutputStream(optionsFile);
DataOutputStream dos = DataOutputStream(&fos);
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
// 4J - original used a PrintWriter & FileWriter, but seems a bit much
// implementing these just to do this
FileOutputStream fos = FileOutputStream(optionsFile);
DataOutputStream dos = DataOutputStream(&fos);
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
dos.writeChars(L"invertYMouse:" + std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
dos.writeChars(L"fov:" + _toString<float>(fov));
dos.writeChars(L"gamma:" + _toString<float>(gamma));
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
dos.writeChars(L"particles:" + _toString<int>(particles));
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
dos.writeChars(L"anaglyph3d:" + std::wstring(anaglyph3d ? L"true" : L"false"));
dos.writeChars(L"advancedOpengl:" + std::wstring(advancedOpengl ? L"true" : L"false"));
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
dos.writeChars(L"fancyGraphics:" + std::wstring(fancyGraphics ? L"true" : L"false"));
dos.writeChars(L"ao:" + std::wstring(ambientOcclusion ? L"true" : L"false"));
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
dos.writeChars(L"skin:" + skin);
dos.writeChars(L"lastServer:" + lastMpIp);
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
dos.writeChars(L"sound:" + _toString<float>(sound) + L"\n");
dos.writeChars(L"invertYMouse:" +
std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
dos.writeChars(L"fov:" + _toString<float>(fov));
dos.writeChars(L"gamma:" + _toString<float>(gamma));
dos.writeChars(L"viewDistance:" + _toString<int>(viewDistance));
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
dos.writeChars(L"particles:" + _toString<int>(particles));
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
dos.writeChars(L"anaglyph3d:" +
std::wstring(anaglyph3d ? L"true" : L"false"));
dos.writeChars(L"advancedOpengl:" +
std::wstring(advancedOpengl ? L"true" : L"false"));
dos.writeChars(L"fpsLimit:" + _toString<int>(framerateLimit));
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
dos.writeChars(L"fancyGraphics:" +
std::wstring(fancyGraphics ? L"true" : L"false"));
dos.writeChars(L"ao:" +
std::wstring(ambientOcclusion ? L"true" : L"false"));
dos.writeChars(L"clouds:" + _toString<bool>(renderClouds));
dos.writeChars(L"skin:" + skin);
dos.writeChars(L"lastServer:" + lastMpIp);
for (int i = 0; i < keyMappings_length; i++)
{
dos.writeChars(L"key_" + keyMappings[i]->name + L":" + _toString<int>(keyMappings[i]->key));
}
dos.close();
// } catch (Exception e) {
// System.out.println("Failed to save options");
// e.printStackTrace();
// }
for (int i = 0; i < keyMappings_length; i++) {
dos.writeChars(L"key_" + keyMappings[i]->name + L":" +
_toString<int>(keyMappings[i]->key));
}
dos.close();
// } catch (Exception e) {
// System.out.println("Failed to save options");
// e.printStackTrace();
// }
}
bool Options::isCloudsOn()
{
return viewDistance < 2 && renderClouds;
}
bool Options::isCloudsOn() { return viewDistance < 2 && renderClouds; }

View file

@ -4,60 +4,58 @@ class Minecraft;
class KeyMapping;
#include "../../Minecraft.World/IO/Files/File.h"
class Options
{
class Options {
public:
static const int AO_OFF = 0;
static const int AO_MIN = 1;
static const int AO_MAX = 2;
static const int AO_OFF = 0;
static const int AO_MIN = 1;
static const int AO_MAX = 2;
// 4J - this used to be an enum
class Option
{
public:
static const Option options[17];
static const Option *MUSIC;
static const Option *SOUND;
static const Option *INVERT_MOUSE;
static const Option *SENSITIVITY;
static const Option *RENDER_DISTANCE;
static const Option *VIEW_BOBBING;
static const Option *ANAGLYPH;
static const Option *ADVANCED_OPENGL;
static const Option *FRAMERATE_LIMIT;
static const Option *DIFFICULTY;
static const Option *GRAPHICS;
static const Option *AMBIENT_OCCLUSION;
static const Option *GUI_SCALE;
static const Option *FOV;
static const Option *GAMMA;
static const Option *RENDER_CLOUDS;
static const Option *PARTICLES;
// 4J - this used to be an enum
class Option {
public:
static const Option options[17];
static const Option* MUSIC;
static const Option* SOUND;
static const Option* INVERT_MOUSE;
static const Option* SENSITIVITY;
static const Option* RENDER_DISTANCE;
static const Option* VIEW_BOBBING;
static const Option* ANAGLYPH;
static const Option* ADVANCED_OPENGL;
static const Option* FRAMERATE_LIMIT;
static const Option* DIFFICULTY;
static const Option* GRAPHICS;
static const Option* AMBIENT_OCCLUSION;
static const Option* GUI_SCALE;
static const Option* FOV;
static const Option* GAMMA;
static const Option* RENDER_CLOUDS;
static const Option* PARTICLES;
private:
const bool _isProgress;
private:
const bool _isProgress;
const bool _isBoolean;
const std::wstring captionId;
public:
static const Option *getItem(int id);
public:
static const Option* getItem(int id);
Option(const std::wstring& captionId, bool hasProgress, bool isBoolean);
bool isProgress() const;
bool isBoolean() const;
int getId() const;
std::wstring getCaptionId() const;
bool isProgress() const;
bool isBoolean() const;
int getId() const;
std::wstring getCaptionId() const;
};
private:
static const std::wstring RENDER_DISTANCE_NAMES[];
static const std::wstring RENDER_DISTANCE_NAMES[];
static const std::wstring DIFFICULTY_NAMES[];
static const std::wstring GUI_SCALE[];
static const std::wstring FRAMERATE_LIMITS[];
static const std::wstring PARTICLES[];
static const std::wstring PARTICLES[];
public:
float music;
float music;
float sound;
float sensitivity;
bool invertYMouse;
@ -68,34 +66,35 @@ public:
int framerateLimit;
bool fancyGraphics;
bool ambientOcclusion;
bool renderClouds;
bool renderClouds;
std::wstring skin;
KeyMapping *keyUp;
KeyMapping *keyLeft;
KeyMapping *keyDown;
KeyMapping *keyRight;
KeyMapping *keyJump;
KeyMapping *keyBuild;
KeyMapping *keyDrop;
KeyMapping *keyChat;
KeyMapping *keySneak;
KeyMapping *keyAttack;
KeyMapping *keyUse;
KeyMapping *keyPlayerList;
KeyMapping *keyPickItem;
KeyMapping *keyToggleFog;
KeyMapping* keyUp;
KeyMapping* keyLeft;
KeyMapping* keyDown;
KeyMapping* keyRight;
KeyMapping* keyJump;
KeyMapping* keyBuild;
KeyMapping* keyDrop;
KeyMapping* keyChat;
KeyMapping* keySneak;
KeyMapping* keyAttack;
KeyMapping* keyUse;
KeyMapping* keyPlayerList;
KeyMapping* keyPickItem;
KeyMapping* keyToggleFog;
static const int keyMappings_length = 14;
KeyMapping *keyMappings[keyMappings_length];
static const int keyMappings_length = 14;
KeyMapping* keyMappings[keyMappings_length];
protected:
Minecraft *minecraft;
Minecraft* minecraft;
private:
File optionsFile;
File optionsFile;
public:
int difficulty;
int difficulty;
bool hideGui;
bool thirdPersonView;
bool renderDebug;
@ -107,26 +106,28 @@ public:
float flySpeed;
float cameraSpeed;
int guiScale;
int particles; // 0 is all, 1 is decreased and 2 is minimal
float fov;
float gamma;
int particles; // 0 is all, 1 is decreased and 2 is minimal
float fov;
float gamma;
void init(); // 4J added
Options(Minecraft *minecraft, File workingDirectory);
void init(); // 4J added
Options(Minecraft* minecraft, File workingDirectory);
Options();
std::wstring getKeyDescription(int i);
std::wstring getKeyMessage(int i);
void setKey(int i, int key);
void set(const Options::Option *item, float value);
void toggle(const Options::Option *option, int dir);
float getProgressValue(const Options::Option *item);
bool getBooleanValue(const Options::Option *item);
std::wstring getMessage(const Options::Option *item);
void set(const Options::Option* item, float value);
void toggle(const Options::Option* option, int dir);
float getProgressValue(const Options::Option* item);
bool getBooleanValue(const Options::Option* item);
std::wstring getMessage(const Options::Option* item);
void load();
private:
float readFloat(std::wstring string);
public:
void save();
bool isCloudsOn();
private:
float readFloat(std::wstring string);
public:
void save();
bool isCloudsOn();
};

View file

@ -3,53 +3,41 @@
#include "../../Minecraft.World/Util/StringHelpers.h"
// 4J - TODO - serialise/deserialise from file
Settings::Settings(File *file)
{
Settings::Settings(File* file) {}
void Settings::generateNewProperties() {}
void Settings::saveProperties() {}
std::wstring Settings::getString(const std::wstring& key,
const std::wstring& defaultValue) {
if (properties.find(key) == properties.end()) {
properties[key] = defaultValue;
saveProperties();
}
return properties[key];
}
void Settings::generateNewProperties()
{
int Settings::getInt(const std::wstring& key, int defaultValue) {
if (properties.find(key) == properties.end()) {
properties[key] = _toString<int>(defaultValue);
saveProperties();
}
return _fromString<int>(properties[key]);
}
void Settings::saveProperties()
{
bool Settings::getBoolean(const std::wstring& key, bool defaultValue) {
if (properties.find(key) == properties.end()) {
properties[key] = _toString<bool>(defaultValue);
saveProperties();
}
MemSect(35);
bool retval = _fromString<bool>(properties[key]);
MemSect(0);
return retval;
}
std::wstring Settings::getString(const std::wstring& key, const std::wstring& defaultValue)
{
if(properties.find(key) == properties.end())
{
properties[key] = defaultValue;
saveProperties();
}
return properties[key];
}
int Settings::getInt(const std::wstring& key, int defaultValue)
{
if(properties.find(key) == properties.end())
{
properties[key] = _toString<int>(defaultValue);
saveProperties();
}
return _fromString<int>(properties[key]);
}
bool Settings::getBoolean(const std::wstring& key, bool defaultValue)
{
if(properties.find(key) == properties.end())
{
properties[key] = _toString<bool>(defaultValue);
saveProperties();
}
MemSect(35);
bool retval = _fromString<bool>(properties[key]);
MemSect(0);
return retval;
}
void Settings::setBooleanAndSave(const std::wstring& key, bool value)
{
properties[key] = _toString<bool>(value);
saveProperties();
void Settings::setBooleanAndSave(const std::wstring& key, bool value) {
properties[key] = _toString<bool>(value);
saveProperties();
}

View file

@ -1,20 +1,21 @@
#pragma once
class File;
class Settings
{
// public static Logger logger = Logger.getLogger("Minecraft");
// private Properties properties = new Properties();
class Settings {
// public static Logger logger = Logger.getLogger("Minecraft");
// private Properties properties = new Properties();
private:
std::unordered_map<std::wstring,std::wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
//File *file;
std::unordered_map<std::wstring, std::wstring>
properties; // 4J - TODO was Properties type, will need to implement
// something we can serialise/deserialise too
// File *file;
public:
Settings(File *file);
Settings(File* file);
void generateNewProperties();
void saveProperties();
std::wstring getString(const std::wstring& key, const std::wstring& defaultValue);
std::wstring getString(const std::wstring& key,
const std::wstring& defaultValue);
int getInt(const std::wstring& key, int defaultValue);
bool getBoolean(const std::wstring& key, bool defaultValue);
void setBooleanAndSave(const std::wstring& key, bool value);

File diff suppressed because it is too large Load diff

View file

@ -5,100 +5,96 @@ class Achievement;
class StatsSyncher;
class User;
class StatsCounter
{
class StatsCounter {
private:
enum eDifficulty {
eDifficulty_Peaceful = 0,
eDifficulty_Easy,
eDifficulty_Normal,
eDifficulty_Hard,
eDifficulty_Max
};
enum eDifficulty
{
eDifficulty_Peaceful=0,
eDifficulty_Easy,
eDifficulty_Normal,
eDifficulty_Hard,
eDifficulty_Max
};
struct StatContainer {
unsigned int stats[eDifficulty_Max];
struct StatContainer
{
unsigned int stats[eDifficulty_Max];
StatContainer() {
stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] =
stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0;
}
};
StatContainer()
{
stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] = stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0;
}
};
typedef std::unordered_map<Stat*, StatContainer> StatsMap;
typedef std::unordered_map<Stat*, StatContainer> StatsMap;
//static const int STAT_DATA_OFFSET = 32;
static const int LARGE_STATS_COUNT = 8;
static Stat** LARGE_STATS[LARGE_STATS_COUNT];
static const int SAVE_DELAY = 30*60;
static const int FLUSH_DELAY = 30*60*5;
// static const int STAT_DATA_OFFSET = 32;
static const int LARGE_STATS_COUNT = 8;
static Stat** LARGE_STATS[LARGE_STATS_COUNT];
static const int SAVE_DELAY = 30 * 60;
static const int FLUSH_DELAY = 30 * 60 * 5;
typedef enum {
LEADERBOARD_KILLS_PEACEFUL = 0x00000001,
LEADERBOARD_KILLS_EASY = 0x00000002,
LEADERBOARD_KILLS_NORMAL = 0x00000004,
LEADERBOARD_KILLS_HARD = 0x00000008,
LEADERBOARD_MININGBLOCKS_PEACEFUL = 0x00000010,
LEADERBOARD_MININGBLOCKS_EASY = 0x00000020,
LEADERBOARD_MININGBLOCKS_NORMAL = 0x00000040,
LEADERBOARD_MININGBLOCKS_HARD = 0x00000080,
LEADERBOARD_MININGORE_PEACEFUL = 0x00000100,
LEADERBOARD_MININGORE_EASY = 0x00000200,
LEADERBOARD_MININGORE_NORMAL = 0x00000400,
LEADERBOARD_MININGORE_HARD = 0x00000800,
LEADERBOARD_FARMING_PEACEFUL = 0x00001000,
LEADERBOARD_FARMING_EASY = 0x00002000,
LEADERBOARD_FARMING_NORMAL = 0x00004000,
LEADERBOARD_FARMING_HARD = 0x00008000,
LEADERBOARD_TRAVELLING_PEACEFUL = 0x00010000,
LEADERBOARD_TRAVELLING_EASY = 0x00020000,
LEADERBOARD_TRAVELLING_NORMAL = 0x00040000,
LEADERBOARD_TRAVELLING_HARD = 0x00080000,
LEADERBOARD_NETHER_PEACEFUL = 0x00100000,
LEADERBOARD_NETHER_EASY = 0x00200000,
LEADERBOARD_NETHER_NORMAL = 0x00400000,
LEADERBOARD_NETHER_HARD = 0x00800000,
LEADERBOARD_TRAVELLING_TOTAL = 0x01000000
} LEADERBOARD_FLAG;
typedef enum {
LEADERBOARD_KILLS_PEACEFUL = 0x00000001,
LEADERBOARD_KILLS_EASY = 0x00000002,
LEADERBOARD_KILLS_NORMAL = 0x00000004,
LEADERBOARD_KILLS_HARD = 0x00000008,
LEADERBOARD_MININGBLOCKS_PEACEFUL = 0x00000010,
LEADERBOARD_MININGBLOCKS_EASY = 0x00000020,
LEADERBOARD_MININGBLOCKS_NORMAL = 0x00000040,
LEADERBOARD_MININGBLOCKS_HARD = 0x00000080,
LEADERBOARD_MININGORE_PEACEFUL = 0x00000100,
LEADERBOARD_MININGORE_EASY = 0x00000200,
LEADERBOARD_MININGORE_NORMAL = 0x00000400,
LEADERBOARD_MININGORE_HARD = 0x00000800,
LEADERBOARD_FARMING_PEACEFUL = 0x00001000,
LEADERBOARD_FARMING_EASY = 0x00002000,
LEADERBOARD_FARMING_NORMAL = 0x00004000,
LEADERBOARD_FARMING_HARD = 0x00008000,
LEADERBOARD_TRAVELLING_PEACEFUL = 0x00010000,
LEADERBOARD_TRAVELLING_EASY = 0x00020000,
LEADERBOARD_TRAVELLING_NORMAL = 0x00040000,
LEADERBOARD_TRAVELLING_HARD = 0x00080000,
LEADERBOARD_NETHER_PEACEFUL = 0x00100000,
LEADERBOARD_NETHER_EASY = 0x00200000,
LEADERBOARD_NETHER_NORMAL = 0x00400000,
LEADERBOARD_NETHER_HARD = 0x00800000,
LEADERBOARD_TRAVELLING_TOTAL = 0x01000000
} LEADERBOARD_FLAG;
StatsMap stats;
StatsMap stats;
bool requiresSave;
int saveCounter;
int saveCounter;
int modifiedBoards;
static std::unordered_map<Stat*, int> statBoards;
int flushCounter;
int modifiedBoards;
static std::unordered_map<Stat*, int> statBoards;
int flushCounter;
public:
StatsCounter();
void award(Stat *stat, unsigned int difficulty, unsigned int count);
bool hasTaken(Achievement *ach);
bool canTake(Achievement *ach);
unsigned int getValue(Stat *stat, unsigned int difficulty);
unsigned int getTotalValue(Stat *stat);
StatsCounter();
void award(Stat* stat, unsigned int difficulty, unsigned int count);
bool hasTaken(Achievement* ach);
bool canTake(Achievement* ach);
unsigned int getValue(Stat* stat, unsigned int difficulty);
unsigned int getTotalValue(Stat* stat);
void tick(int player);
void parse(void* data);
void clear();
void save(int player, bool force=false);
void flushLeaderboards();
void saveLeaderboards();
static void setupStatBoards();
void parse(void* data);
void clear();
void save(int player, bool force = false);
void flushLeaderboards();
void saveLeaderboards();
static void setupStatBoards();
#ifdef _DEBUG
void WipeLeaderboards();
void WipeLeaderboards();
#endif
private:
bool isLargeStat(Stat* stat);
void dumpStatsToTTY();
bool isLargeStat(Stat* stat);
void dumpStatsToTTY();
#ifdef _XBOX
static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id, unsigned int value);
static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value);
static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id,
unsigned int value);
static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value);
#endif
void writeStats();
void writeStats();
};

View file

@ -5,42 +5,46 @@ class User;
class File;
class Stat;
class StatsSyncher
{
class StatsSyncher {
private:
static const int SAVE_INTERVAL = 20 * 5;
static const int SAVE_INTERVAL = 20 * 5;
static const int SEND_INTERVAL = 20 * 60;
volatile bool busy;
volatile std::unordered_map<Stat *, int> *serverStats;
volatile std::unordered_map<Stat *, int> *failedSentStats;
volatile std::unordered_map<Stat*, int>* serverStats;
volatile std::unordered_map<Stat*, int>* failedSentStats;
StatsCounter *statsCounter;
StatsCounter* statsCounter;
File *unsentFile, *lastServerFile;
File *unsentFileTmp, *lastServerFileTmp;
File *unsentFileOld, *lastServerFileOld;
User *user;
User* user;
int noSaveIn, noSendIn;
public:
StatsSyncher(User *user, StatsCounter *statsCounter, File *dir);
StatsSyncher(User* user, StatsCounter* statsCounter, File* dir);
private:
void attemptRename(File *dir, const std::wstring& name, File *to);
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file, File *tmp, File *old);
std::unordered_map<Stat *, int> *loadStatsFromDisk(File *file);
void doSend(std::unordered_map<Stat *, int> *stats);
void doSave(std::unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
void attemptRename(File* dir, const std::wstring& name, File* to);
std::unordered_map<Stat*, int>* loadStatsFromDisk(File* file, File* tmp,
File* old);
std::unordered_map<Stat*, int>* loadStatsFromDisk(File* file);
void doSend(std::unordered_map<Stat*, int>* stats);
void doSave(std::unordered_map<Stat*, int>* stats, File* file, File* tmp,
File* old);
protected:
std::unordered_map<Stat *, int> *doGetStats();
std::unordered_map<Stat*, int>* doGetStats();
public:
void getStatsFromServer();
void saveUnsent(std::unordered_map<Stat *, int> *stats);
void sendUnsent(std::unordered_map<Stat *, int> *stats, std::unordered_map<Stat *, int> *fullStats);
void forceSendUnsent(std::unordered_map<Stat *, int> *stats);
void forceSaveUnsent(std::unordered_map<Stat *, int> *stats);
void getStatsFromServer();
void saveUnsent(std::unordered_map<Stat*, int>* stats);
void sendUnsent(std::unordered_map<Stat*, int>* stats,
std::unordered_map<Stat*, int>* fullStats);
void forceSendUnsent(std::unordered_map<Stat*, int>* stats);
void forceSaveUnsent(std::unordered_map<Stat*, int>* stats);
bool maySave();
bool maySend();
void tick();

View file

@ -11,10 +11,9 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
#include "../ClientConstants.h"
SurvivalMode::SurvivalMode(Minecraft *minecraft) : GameMode(minecraft)
{
// 4J - added initialisers
xDestroyBlock = -1;
SurvivalMode::SurvivalMode(Minecraft* minecraft) : GameMode(minecraft) {
// 4J - added initialisers
xDestroyBlock = -1;
yDestroyBlock = -1;
zDestroyBlock = -1;
destroyProgress = 0;
@ -22,122 +21,103 @@ SurvivalMode::SurvivalMode(Minecraft *minecraft) : GameMode(minecraft)
destroyTicks = 0;
destroyDelay = 0;
if (ClientConstants::IS_DEMO_VERSION)
{
if( dynamic_cast<DemoMode *>(this) == NULL )
{
assert(false);
// throw new IllegalStateException("Invalid game mode"); // 4J - removed
if (ClientConstants::IS_DEMO_VERSION) {
if (dynamic_cast<DemoMode*>(this) == NULL) {
assert(false);
// throw new IllegalStateException("Invalid game mode");
// // 4J - removed
}
}
}
// 4J Stu - Added this ctor so we can exit the tutorial and replace it with a standard
// survival mode
SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
{
xDestroyBlock = copy->xDestroyBlock;
yDestroyBlock = copy->yDestroyBlock;
zDestroyBlock = copy->zDestroyBlock;
destroyProgress = copy->destroyProgress;
oDestroyProgress = copy->oDestroyProgress;
destroyTicks = copy->destroyTicks;
// 4J Stu - Added this ctor so we can exit the tutorial and replace it with a
// standard survival mode
SurvivalMode::SurvivalMode(SurvivalMode* copy) : GameMode(copy->minecraft) {
xDestroyBlock = copy->xDestroyBlock;
yDestroyBlock = copy->yDestroyBlock;
zDestroyBlock = copy->zDestroyBlock;
destroyProgress = copy->destroyProgress;
oDestroyProgress = copy->oDestroyProgress;
destroyTicks = copy->destroyTicks;
destroyDelay = copy->destroyDelay;
}
void SurvivalMode::initPlayer(std::shared_ptr<Player> player)
{
player->yRot = -180;
void SurvivalMode::initPlayer(std::shared_ptr<Player> player) {
player->yRot = -180;
}
void SurvivalMode::init()
{
}
void SurvivalMode::init() {}
bool SurvivalMode::canHurtPlayer()
{
return true;
}
bool SurvivalMode::canHurtPlayer() { return true; }
bool SurvivalMode::destroyBlock(int x, int y, int z, int face)
{
bool SurvivalMode::destroyBlock(int x, int y, int z, int face) {
int t = minecraft->level->getTile(x, y, z);
int data = minecraft->level->getData(x, y, z);
bool changed = GameMode::destroyBlock(x, y, z, face);
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
if (item != NULL)
{
if (item != NULL) {
item->mineBlock(minecraft->level, t, x, y, z, minecraft->player);
if (item->count == 0)
{
if (item->count == 0) {
minecraft->player->removeSelectedItem();
}
}
if (changed && couldDestroy)
{
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y, z, data);
}
if (changed && couldDestroy) {
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y,
z, data);
}
return changed;
}
void SurvivalMode::startDestroyBlock(int x, int y, int z, int face)
{
if (!minecraft->player->mayBuild(x, y, z)) return;
void SurvivalMode::startDestroyBlock(int x, int y, int z, int face) {
if (!minecraft->player->mayBuild(x, y, z)) return;
minecraft->level->extinguishFire(minecraft->player, x, y, z, face);
int t = minecraft->level->getTile(x, y, z);
if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1)
{
if (t > 0 && destroyProgress == 0)
Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1) {
destroyBlock(x, y, z, face);
}
}
void SurvivalMode::stopDestroyBlock()
{
void SurvivalMode::stopDestroyBlock() {
destroyProgress = 0;
destroyDelay = 0;
}
void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
{
if (destroyDelay > 0)
{
void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face) {
if (destroyDelay > 0) {
destroyDelay--;
return;
}
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock)
{
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
int t = minecraft->level->getTile(x, y, z);
if (!minecraft->player->mayBuild(x, y, z)) return;
if (!minecraft->player->mayBuild(x, y, z)) return;
if (t == 0) return;
Tile *tile = Tile::tiles[t];
Tile* tile = Tile::tiles[t];
destroyProgress += tile->getDestroyProgress(minecraft->player);
if (destroyTicks % 4 == 0)
{
if (tile != NULL)
{
minecraft->soundEngine->play(tile->soundType->getStepSound(), x + 0.5f, y + 0.5f, z + 0.5f, (tile->soundType->getVolume() + 1) / 8, tile->soundType->getPitch() * 0.5f);
if (destroyTicks % 4 == 0) {
if (tile != NULL) {
minecraft->soundEngine->play(
tile->soundType->getStepSound(), x + 0.5f, y + 0.5f,
z + 0.5f, (tile->soundType->getVolume() + 1) / 8,
tile->soundType->getPitch() * 0.5f);
}
}
destroyTicks++;
if (destroyProgress >= 1)
{
if (destroyProgress >= 1) {
destroyBlock(x, y, z, face);
destroyProgress = 0;
oDestroyProgress = 0;
destroyTicks = 0;
destroyDelay = 5;
}
}
else
{
} else {
destroyProgress = 0;
oDestroyProgress = 0;
destroyTicks = 0;
@ -145,64 +125,49 @@ void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
yDestroyBlock = y;
zDestroyBlock = z;
}
}
void SurvivalMode::render(float a)
{
if (destroyProgress <= 0)
{
void SurvivalMode::render(float a) {
if (destroyProgress <= 0) {
minecraft->gui->progress = 0;
minecraft->levelRenderer->destroyProgress = 0;
}
else
{
} else {
float dp = oDestroyProgress + (destroyProgress - oDestroyProgress) * a;
minecraft->gui->progress = dp;
minecraft->levelRenderer->destroyProgress = dp;
}
}
float SurvivalMode::getPickRange()
{
return 4.0f;
float SurvivalMode::getPickRange() { return 4.0f; }
void SurvivalMode::initLevel(Level* level) { GameMode::initLevel(level); }
std::shared_ptr<Player> SurvivalMode::createPlayer(Level* level) {
std::shared_ptr<Player> player = GameMode::createPlayer(level);
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
// player.inventory.add(new ItemInstance(Tile.torch, 64));
// player.inventory.add(new ItemInstance(Item.porkChop_cooked, 4));
// player.inventory.add(new ItemInstance(Item.bow, 1));
// player.inventory.add(new ItemInstance(Item.arrow, 64));
return player;
}
void SurvivalMode::initLevel(Level *level)
{
GameMode::initLevel(level);
}
std::shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
{
std::shared_ptr<Player> player = GameMode::createPlayer(level);
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
// player.inventory.add(new ItemInstance(Tile.torch, 64));
// player.inventory.add(new ItemInstance(Item.porkChop_cooked, 4));
// player.inventory.add(new ItemInstance(Item.bow, 1));
// player.inventory.add(new ItemInstance(Item.arrow, 64));
return player;
}
void SurvivalMode::tick()
{
void SurvivalMode::tick() {
oDestroyProgress = destroyProgress;
//minecraft->soundEngine->playMusicTick();
// minecraft->soundEngine->playMusicTick();
}
bool SurvivalMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly, bool *pbUsedItem)
{
int t = level->getTile(x, y, z);
if (t > 0)
{
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
}
if (item == NULL) return false;
return item->useOn(player, level, x, y, z, face);
bool SurvivalMode::useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face, bool bTestUseOnOnly,
bool* pbUsedItem) {
int t = level->getTile(x, y, z);
if (t > 0) {
if (Tile::tiles[t]->use(level, x, y, z, player)) return true;
}
if (item == NULL) return false;
return item->useOn(player, level, x, y, z, face);
}
bool SurvivalMode::hasExperience()
{
return true;
}
bool SurvivalMode::hasExperience() { return true; }

View file

@ -1,32 +1,34 @@
#pragma once
#include "GameMode.h"
class SurvivalMode : public GameMode
{
class SurvivalMode : public GameMode {
private:
int xDestroyBlock;
int xDestroyBlock;
int yDestroyBlock;
int zDestroyBlock;
float destroyProgress;
float oDestroyProgress;
int destroyTicks; // 4J was float but doesn't seem to need to be
int destroyTicks; // 4J was float but doesn't seem to need to be
int destroyDelay;
public:
SurvivalMode(Minecraft *minecraft);
SurvivalMode(SurvivalMode *copy);
SurvivalMode(Minecraft* minecraft);
SurvivalMode(SurvivalMode* copy);
virtual void initPlayer(std::shared_ptr<Player> player);
virtual void init();
virtual bool canHurtPlayer();
virtual bool canHurtPlayer();
virtual bool destroyBlock(int x, int y, int z, int face);
virtual void startDestroyBlock(int x, int y, int z, int face);
virtual void stopDestroyBlock();
virtual void continueDestroyBlock(int x, int y, int z, int face);
virtual void render(float a);
virtual float getPickRange();
virtual void initLevel(Level *level);
virtual std::shared_ptr<Player> createPlayer(Level *level);
virtual void initLevel(Level* level);
virtual std::shared_ptr<Player> createPlayer(Level* level);
virtual void tick();
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
virtual bool hasExperience();
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
std::shared_ptr<ItemInstance> item, int x, int y,
int z, int face, bool bTestUseOnOnly = false,
bool* pbUsedItem = NULL);
virtual bool hasExperience();
};

View file

@ -1,8 +1,8 @@
#include "../Platform/stdafx.h"
#include "ConsoleInput.h"
ConsoleInput::ConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
{
this->msg = msg;
this->source = source;
ConsoleInput::ConsoleInput(const std::wstring& msg,
ConsoleInputSource* source) {
this->msg = msg;
this->source = source;
}

View file

@ -1,12 +1,10 @@
#pragma once
#include "ConsoleInputSource.h"
class ConsoleInput
{
class ConsoleInput {
public:
std::wstring msg;
ConsoleInputSource *source;
std::wstring msg;
ConsoleInputSource* source;
ConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
ConsoleInput(const std::wstring& msg, ConsoleInputSource* source);
};

View file

@ -1,10 +1,9 @@
#pragma once
class ConsoleInputSource
{
class ConsoleInputSource {
public:
virtual ~ConsoleInputSource(){}
virtual void info(const std::wstring& string) = 0;
virtual ~ConsoleInputSource() {}
virtual void info(const std::wstring& string) = 0;
virtual void warn(const std::wstring& string) = 0;
virtual std::wstring getConsoleName() = 0;
};

View file

@ -8,108 +8,123 @@
#include "../Player/LocalPlayer.h"
#include "../GameState/Options.h"
Input::Input()
{
xa = 0;
ya = 0;
wasJumping = false;
jumping = false;
sneaking = false;
sprintKey = false;
Input::Input() {
xa = 0;
ya = 0;
wasJumping = false;
jumping = false;
sneaking = false;
sprintKey = false;
lReset = false;
lReset = false;
rReset = false;
}
void Input::tick(LocalPlayer *player)
{
// 4J Stu - Assume that we only need one input class, even though the java has subclasses for keyboard/controller
// This function is based on the ControllerInput class in the Java, and will probably need changed
//OutputDebugString("INPUT: Beginning input tick\n");
void Input::tick(LocalPlayer* player) {
// 4J Stu - Assume that we only need one input class, even though the java
// has subclasses for keyboard/controller This function is based on the
// ControllerInput class in the Java, and will probably need changed
// OutputDebugString("INPUT: Beginning input tick\n");
Minecraft *pMinecraft=Minecraft::GetInstance();
int iPad=player->GetXboxPad();
Minecraft* pMinecraft = Minecraft::GetInstance();
int iPad = player->GetXboxPad();
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_RIGHT) )
xa = -InputManager.GetJoypadStick_LX(iPad);
else
xa = 0.0f;
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_FORWARD) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_BACKWARD) )
ya = InputManager.GetJoypadStick_LY(iPad);
else
ya = 0.0f;
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_LEFT) ||
pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_RIGHT))
xa = -InputManager.GetJoypadStick_LX(iPad);
else
xa = 0.0f;
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_FORWARD) ||
pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_BACKWARD))
ya = InputManager.GetJoypadStick_LY(iPad);
else
ya = 0.0f;
#ifndef _CONTENT_PACKAGE
if (app.GetFreezePlayers())
{
xa = ya = 0.0f;
player->abilities.flying = true;
}
if (app.GetFreezePlayers()) {
xa = ya = 0.0f;
player->abilities.flying = true;
}
#endif
if (!lReset)
{
if (xa*xa+ya*ya==0.0f)
{
if (!lReset) {
if (xa * xa + ya * ya == 0.0f) {
lReset = true;
}
xa = ya = 0.0f;
}
// 4J - in flying mode, don't actually toggle sneaking
if(!player->abilities.flying)
{
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE)) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
{
sneaking=!sneaking;
}
}
// 4J - in flying mode, don't actually toggle sneaking
if (!player->abilities.flying) {
if ((player->ullButtonsPressed &
(1LL << MINECRAFT_ACTION_SNEAK_TOGGLE)) &&
pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_SNEAK_TOGGLE)) {
sneaking = !sneaking;
}
}
if(sneaking)
{
xa*=0.3f;
ya*=0.3f;
}
if (sneaking) {
xa *= 0.3f;
ya *= 0.3f;
}
float turnSpeed = 50.0f;
float tx = 0.0f;
float ty = 0.0f;
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_RIGHT) )
tx = InputManager.GetJoypadStick_RX(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_UP) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_DOWN) )
ty = InputManager.GetJoypadStick_RY(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
float tx = 0.0f;
float ty = 0.0f;
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_LOOK_LEFT) ||
pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_LOOK_RIGHT))
tx = InputManager.GetJoypadStick_RX(iPad) *
(((float)app.GetGameSettings(iPad,
eGameSetting_Sensitivity_InGame)) /
100.0f); // apply sensitivity to look
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_LOOK_UP) ||
pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_LOOK_DOWN))
ty = InputManager.GetJoypadStick_RY(iPad) *
(((float)app.GetGameSettings(iPad,
eGameSetting_Sensitivity_InGame)) /
100.0f); // apply sensitivity to look
#ifndef _CONTENT_PACKAGE
if (app.GetFreezePlayers()) tx = ty = 0.0f;
if (app.GetFreezePlayers()) tx = ty = 0.0f;
#endif
// 4J: WESTY : Invert look Y if required.
if ( app.GetGameSettings(iPad,eGameSetting_ControlInvertLook) )
{
ty = -ty;
}
// 4J: WESTY : Invert look Y if required.
if (app.GetGameSettings(iPad, eGameSetting_ControlInvertLook)) {
ty = -ty;
}
if (!rReset)
{
if (tx*tx+ty*ty==0.0f)
{
if (!rReset) {
if (tx * tx + ty * ty == 0.0f) {
rReset = true;
}
tx = ty = 0.0f;
}
player->interpolateTurn(tx * abs(tx) * turnSpeed, ty * abs(ty) * turnSpeed);
//jumping = controller.isButtonPressed(0);
player->interpolateTurn(tx * abs(tx) * turnSpeed, ty * abs(ty) * turnSpeed);
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SPRINT);
jumping = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
// jumping = controller.isButtonPressed(0);
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) &&
pMinecraft->localgameModes[iPad]->isInputAllowed(
MINECRAFT_ACTION_SPRINT);
jumping =
InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) &&
pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
#ifndef _CONTENT_PACKAGE
if (app.GetFreezePlayers()) jumping = false;
if (app.GetFreezePlayers()) jumping = false;
#endif
//OutputDebugString("INPUT: End input tick\n");
// OutputDebugString("INPUT: End input tick\n");
}

View file

@ -1,24 +1,22 @@
#pragma once
class Player;
class Input
{
class Input {
public:
float xa;
float xa;
float ya;
bool wasJumping;
bool jumping;
bool sneaking;
bool sprintKey;
Input(); // 4J - added
virtual ~Input(){}
virtual void tick(LocalPlayer *player);
Input(); // 4J - added
virtual ~Input() {}
virtual void tick(LocalPlayer* player);
private:
bool lReset;
bool rReset;
};

View file

@ -1,8 +1,7 @@
#include "../Platform/stdafx.h"
#include "KeyMapping.h"
KeyMapping::KeyMapping(const std::wstring& name, int key)
{
this->name = name;
this->key = key;
KeyMapping::KeyMapping(const std::wstring& name, int key) {
this->name = name;
this->key = key;
}

View file

@ -1,10 +1,9 @@
#pragma once
// 4J Stu - Not updated to 1.8.2 as we don't use this
class KeyMapping
{
class KeyMapping {
public:
std::wstring name;
int key;
KeyMapping(const std::wstring& name, int key);
std::wstring name;
int key;
KeyMapping(const std::wstring& name, int key);
};

View file

@ -2,24 +2,17 @@
#include "DemoLevel.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.storage.h"
LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
DemoLevel::DEMO_LEVEL_SEED,
GameType::SURVIVAL,
false,
false,
false, LevelType::lvl_normal_1_1, LEVEL_MAX_WIDTH,
1.0
);
LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS =
LevelSettings(DemoLevel::DEMO_LEVEL_SEED, GameType::SURVIVAL, false, false,
false, LevelType::lvl_normal_1_1, LEVEL_MAX_WIDTH, 1.0);
DemoLevel::DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName) : Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS)
{
}
DemoLevel::DemoLevel(std::shared_ptr<LevelStorage> levelStorage,
const std::wstring& levelName)
: Level(levelStorage, levelName, &DEMO_LEVEL_SETTINGS) {}
DemoLevel::DemoLevel(Level *level, Dimension *dimension): Level(level, dimension)
{
}
DemoLevel::DemoLevel(Level* level, Dimension* dimension)
: Level(level, dimension) {}
void DemoLevel::setInitialSpawn()
{
levelData->setSpawn(DEMO_SPAWN_X, DEMO_SPAWN_Y, DEMO_SPAWN_Z);
void DemoLevel::setInitialSpawn() {
levelData->setSpawn(DEMO_SPAWN_X, DEMO_SPAWN_Y, DEMO_SPAWN_Z);
}

View file

@ -1,17 +1,20 @@
#pragma once
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
class DemoLevel : public Level
{
class DemoLevel : public Level {
private:
static const __int64 DEMO_LEVEL_SEED = 0; // 4J - TODO - was "Don't Look Back".hashCode();
static const __int64 DEMO_LEVEL_SEED =
0; // 4J - TODO - was "Don't Look Back".hashCode();
static const int DEMO_SPAWN_X = 796;
static const int DEMO_SPAWN_Y = 72;
static const int DEMO_SPAWN_Z = -731;
static LevelSettings DEMO_LEVEL_SETTINGS;
public:
DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName);
DemoLevel(Level *level, Dimension *dimension);
DemoLevel(std::shared_ptr<LevelStorage> levelStorage,
const std::wstring& levelName);
DemoLevel(Level* level, Dimension* dimension);
protected:
virtual void setInitialSpawn();
virtual void setInitialSpawn();
};

View file

@ -3,27 +3,28 @@
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
#include "../../Minecraft.World/Level/DerivedLevelData.h"
DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped)
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
{
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
if(this->savedDataStorage)
{
delete this->savedDataStorage;
this->savedDataStorage=NULL;
}
this->savedDataStorage = wrapped->savedDataStorage;
levelData = new DerivedLevelData(wrapped->getLevelData());
DerivedServerLevel::DerivedServerLevel(
MinecraftServer* server, std::shared_ptr<LevelStorage> levelStorage,
const std::wstring& levelName, int dimension, LevelSettings* levelSettings,
ServerLevel* wrapped)
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings) {
// 4J-PB - we're going to override the savedDataStorage, so we need to
// delete the current one
if (this->savedDataStorage) {
delete this->savedDataStorage;
this->savedDataStorage = NULL;
}
this->savedDataStorage = wrapped->savedDataStorage;
levelData = new DerivedLevelData(wrapped->getLevelData());
}
DerivedServerLevel::~DerivedServerLevel()
{
// we didn't allocate savedDataStorage here, so we don't want the level destructor to delete it
this->savedDataStorage=NULL;
DerivedServerLevel::~DerivedServerLevel() {
// we didn't allocate savedDataStorage here, so we don't want the level
// destructor to delete it
this->savedDataStorage = NULL;
}
void DerivedServerLevel::saveLevelData()
{
// Do nothing?
// Do nothing!
void DerivedServerLevel::saveLevelData() {
// Do nothing?
// Do nothing!
}

View file

@ -1,12 +1,14 @@
#pragma once
#include "ServerLevel.h"
class DerivedServerLevel : public ServerLevel
{
class DerivedServerLevel : public ServerLevel {
public:
DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
~DerivedServerLevel();
DerivedServerLevel(MinecraftServer* server,
std::shared_ptr<LevelStorage> levelStorage,
const std::wstring& levelName, int dimension,
LevelSettings* levelSettings, ServerLevel* wrapped);
~DerivedServerLevel();
protected:
void saveLevelData();
void saveLevelData();
};

File diff suppressed because it is too large Load diff

View file

@ -8,95 +8,111 @@
class ClientConnection;
class MultiPlayerChunkCache;
class MultiPlayerLevel : public Level
{
class MultiPlayerLevel : public Level {
private:
static const int TICKS_BEFORE_RESET = 20 * 4;
static const int TICKS_BEFORE_RESET = 20 * 4;
class ResetInfo
{
public:
class ResetInfo {
public:
int x, y, z, ticks, tile, data;
ResetInfo(int x, int y, int z, int tile, int data);
};
std::vector<ResetInfo> updatesToReset; // 4J - was linked list but vector seems more appropriate
bool m_bEnableResetChanges; // 4J Added
std::vector<ResetInfo> updatesToReset; // 4J - was linked list but vector
// seems more appropriate
bool m_bEnableResetChanges; // 4J Added
public:
void unshareChunkAt(int x, int z); // 4J - added
void shareChunkAt(int x, int z); // 4J - added
void unshareChunkAt(int x, int z); // 4J - added
void shareChunkAt(int x, int z); // 4J - added
void enableResetChanges(bool enable) { m_bEnableResetChanges = enable; } // 4J Added
void enableResetChanges(bool enable) {
m_bEnableResetChanges = enable;
} // 4J Added
private:
int unshareCheckX; // 4J - added
int unshareCheckZ; // 4J - added
int compressCheckX; // 4J - added
int compressCheckZ; // 4J - added
std::vector<ClientConnection *> connections; // 4J Stu - Made this a vector as we can have more than one local connection
MultiPlayerChunkCache *chunkCache;
Minecraft *minecraft;
int unshareCheckX; // 4J - added
int unshareCheckZ; // 4J - added
int compressCheckX; // 4J - added
int compressCheckZ; // 4J - added
std::vector<ClientConnection*>
connections; // 4J Stu - Made this a vector as we can have more than
// one local connection
MultiPlayerChunkCache* chunkCache;
Minecraft* minecraft;
public:
MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty);
virtual ~MultiPlayerLevel();
virtual void tick() ;
MultiPlayerLevel(ClientConnection* connection, LevelSettings* levelSettings,
int dimension, int difficulty);
virtual ~MultiPlayerLevel();
virtual void tick();
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1);
void clearResetRegion(int x0, int y0, int z0, int x1, int y1, int z1);
protected:
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
ChunkSource*
createChunkSource(); // 4J - was virtual, but was called from parent ctor
public:
virtual void validateSpawn();
virtual void validateSpawn();
protected:
virtual void tickTiles();
virtual void tickTiles();
public:
void setChunkVisible(int x, int z, bool visible);
private:
std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq> entitiesById; // 4J - was IntHashMap
std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2, IntKeyEq>
entitiesById; // 4J - was IntHashMap
std::unordered_set<std::shared_ptr<Entity> > forced;
std::unordered_set<std::shared_ptr<Entity> > reEntries;
public:
virtual bool addEntity(std::shared_ptr<Entity> e);
virtual bool addEntity(std::shared_ptr<Entity> e);
virtual void removeEntity(std::shared_ptr<Entity> e);
protected:
virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityRemoved(std::shared_ptr<Entity> e);
public:
void putEntity(int id, std::shared_ptr<Entity> e);
void putEntity(int id, std::shared_ptr<Entity> e);
std::shared_ptr<Entity> getEntity(int id);
std::shared_ptr<Entity> removeEntity(int id);
virtual void removeEntities(std::vector<std::shared_ptr<Entity> > *list); // 4J Added override
virtual void removeEntities(
std::vector<std::shared_ptr<Entity> >* list); // 4J Added override
virtual bool setDataNoUpdate(int x, int y, int z, int data);
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile, int data);
virtual bool setTileAndDataNoUpdate(int x, int y, int z, int tile,
int data);
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
bool doSetTileAndData(int x, int y, int z, int tile, int data);
virtual void disconnect(bool sendDisconnect = true);
void animateTick(int xt, int yt, int zt);
void animateTick(int xt, int yt, int zt);
protected:
virtual void tickWeather();
static const int ANIMATE_TICK_MAX_PARTICLES = 500;
virtual void tickWeather();
static const int ANIMATE_TICK_MAX_PARTICLES = 500;
public:
void animateTickDoWork(); // 4J added
std::unordered_set<int> chunksToAnimate; // 4J added
void animateTickDoWork(); // 4J added
std::unordered_set<int> chunksToAnimate; // 4J added
public:
void removeAllPendingEntityRemovals();
void removeAllPendingEntityRemovals();
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, float volume, float pitch);
virtual void playSound(std::shared_ptr<Entity> entity, int iSound,
float volume, float pitch);
virtual void playLocalSound(double x, double y, double z, int iSound, float volume, float pitch, float fClipSoundDist=16.0f);
virtual void playLocalSound(double x, double y, double z, int iSound,
float volume, float pitch,
float fClipSoundDist = 16.0f);
// 4J Stu - Added so we can have multiple local connections
void addClientConnection(ClientConnection *c) { connections.push_back( c ); }
void removeClientConnection(ClientConnection *c, bool sendDisconnect);
// 4J Stu - Added so we can have multiple local connections
void addClientConnection(ClientConnection* c) { connections.push_back(c); }
void removeClientConnection(ClientConnection* c, bool sendDisconnect);
void tickAllConnections();
void tickAllConnections();
void dataReceivedForChunk(int x, int z); // 4J added
void removeUnusedTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1); // 4J added
void dataReceivedForChunk(int x, int z); // 4J added
void removeUnusedTileEntitiesInRegion(int x0, int y0, int z0, int x1,
int y1, int z1); // 4J added
};

File diff suppressed because it is too large Load diff

View file

@ -7,165 +7,193 @@ class Node;
class EntityTracker;
class PlayerChunkMap;
class ServerLevel : public Level
{
class ServerLevel : public Level {
private:
static const int EMPTY_TIME_NO_TICK = SharedConstants::TICKS_PER_SECOND * 3;
static const int EMPTY_TIME_NO_TICK = SharedConstants::TICKS_PER_SECOND * 3;
MinecraftServer *server;
EntityTracker *tracker;
PlayerChunkMap *chunkMap;
MinecraftServer* server;
EntityTracker* tracker;
PlayerChunkMap* chunkMap;
CRITICAL_SECTION m_tickNextTickCS; // 4J added
std::set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet
CRITICAL_SECTION m_tickNextTickCS; // 4J added
std::set<TickNextTickData, TickNextTickDataKeyCompare>
tickNextTickList; // 4J Was TreeSet
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash,
TickNextTickDataKeyEq>
tickNextTickSet; // 4J Was HashSet
std::vector<Pos *> m_queuedSendTileUpdates; // 4J added
CRITICAL_SECTION m_csQueueSendTileUpdates;
std::vector<Pos*> m_queuedSendTileUpdates; // 4J added
CRITICAL_SECTION m_csQueueSendTileUpdates;
protected:
int saveInterval;
int saveInterval;
public:
ServerChunkCache *cache;
ServerChunkCache* cache;
bool canEditSpawn;
bool noSave;
private:
bool allPlayersSleeping;
int emptyTime;
bool m_bAtLeastOnePlayerSleeping; // 4J Added
static WeighedTreasureArray RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
std::vector<TileEventData> tileEvents[2];
int activeTileEventsList;
public:
static void staticCtor();
ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings);
~ServerLevel();
void tick();
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
void updateSleepingPlayerList();
protected:
void awakenAllPlayers();
private:
void stopWeather();
bool allPlayersSleeping;
int emptyTime;
bool m_bAtLeastOnePlayerSleeping; // 4J Added
static WeighedTreasureArray
RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
std::vector<TileEventData> tileEvents[2];
int activeTileEventsList;
public:
bool allPlayersAreSleeping();
void validateSpawn();
static void staticCtor();
ServerLevel(MinecraftServer* server,
std::shared_ptr<LevelStorage> levelStorage,
const std::wstring& levelName, int dimension,
LevelSettings* levelSettings);
~ServerLevel();
void tick();
Biome::MobSpawnerData* getRandomMobSpawnAt(MobCategory* mobCategory, int x,
int y, int z);
void updateSleepingPlayerList();
protected:
void tickTiles();
void awakenAllPlayers();
private:
void stopWeather();
public:
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay);
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
void tickEntities();
bool tickPendingTicks(bool force);
std::vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
bool allPlayersAreSleeping();
void validateSpawn();
protected:
void tickTiles();
public:
void addToTickNextTick(int x, int y, int z, int tileId, int tickDelay);
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
void tickEntities();
bool tickPendingTicks(bool force);
std::vector<TickNextTickData>* fetchTicksInChunk(LevelChunk* chunk,
bool remove);
virtual void tick(std::shared_ptr<Entity> e, bool actual);
void forceTick(std::shared_ptr<Entity> e, bool actual);
bool AllPlayersAreSleeping() { return allPlayersSleeping;} // 4J added for a message to other players
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping;}
bool AllPlayersAreSleeping() {
return allPlayersSleeping;
} // 4J added for a message to other players
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping; }
protected:
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
ChunkSource*
createChunkSource(); // 4J - was virtual, but was called from parent ctor
public:
std::vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion(
int x0, int y0, int z0, int x1, int y1, int z1);
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt,
int zt, int id);
protected:
virtual void initializeLevel(LevelSettings *settings);
virtual void setInitialSpawn(LevelSettings *settings);
void generateBonusItemsNearSpawn(); // 4J - brought forward from 1.3.2
virtual void initializeLevel(LevelSettings* settings);
virtual void setInitialSpawn(LevelSettings* settings);
void generateBonusItemsNearSpawn(); // 4J - brought forward from 1.3.2
public:
Pos *getDimensionSpecificSpawn();
Pos* getDimensionSpecificSpawn();
void Suspend(); // 4j Added for XboxOne PLM
void Suspend(); // 4j Added for XboxOne PLM
void save(bool force, ProgressListener *progressListener, bool bAutosave=false);
void saveToDisc(ProgressListener *progressListener, bool autosave); // 4J Added
void save(bool force, ProgressListener* progressListener,
bool bAutosave = false);
void saveToDisc(ProgressListener* progressListener,
bool autosave); // 4J Added
private:
void saveLevelData();
void saveLevelData();
typedef std::unordered_map<int, std::shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
typedef std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2,
IntKeyEq>
intEntityMap;
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing
// function as this uses
protected:
virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityAdded(std::shared_ptr<Entity> e);
virtual void entityRemoved(std::shared_ptr<Entity> e);
public:
std::shared_ptr<Entity> getEntity(int id);
std::shared_ptr<Entity> getEntity(int id);
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source, double x, double y, double z, float r, bool fire, bool destroyBlocks);
virtual std::shared_ptr<Explosion> explode(std::shared_ptr<Entity> source,
double x, double y, double z,
float r, bool fire,
bool destroyBlocks);
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
private:
void runTileEvents();
bool doTileEvent(TileEventData *te);
void runTileEvents();
bool doTileEvent(TileEventData* te);
public:
void closeLevelStorage();
protected:
virtual void tickWeather();
virtual void tickWeather();
public:
MinecraftServer *getServer();
EntityTracker *getTracker();
void setTimeAndAdjustTileTicks(__int64 newTime);
PlayerChunkMap *getChunkMap();
MinecraftServer* getServer();
EntityTracker* getTracker();
void setTimeAndAdjustTileTicks(__int64 newTime);
PlayerChunkMap* getChunkMap();
void queueSendTileUpdate(int x, int y, int z); // 4J Added
void queueSendTileUpdate(int x, int y, int z); // 4J Added
private:
void runQueuedSendTileUpdates();// 4J Added
void runQueuedSendTileUpdates(); // 4J Added
// 4J - added for implementation of finite limit to number of item entities, tnt and falling block entities
// 4J - added for implementation of finite limit to number of item entities,
// tnt and falling block entities
public:
static const int MAX_HANGING_ENTITIES = 400;
static const int MAX_ITEM_ENTITIES = 200;
static const int MAX_ARROW_ENTITIES = 200;
static const int MAX_EXPERIENCEORB_ENTITIES = 50;
static const int MAX_PRIMED_TNT = 20;
static const int MAX_FALLING_TILE = 20;
static const int MAX_HANGING_ENTITIES = 400;
static const int MAX_ITEM_ENTITIES = 200;
static const int MAX_ARROW_ENTITIES = 200;
static const int MAX_EXPERIENCEORB_ENTITIES = 50;
static const int MAX_PRIMED_TNT = 20;
static const int MAX_FALLING_TILE = 20;
int m_primedTntCount;
int m_fallingTileCount;
CRITICAL_SECTION m_limiterCS;
std::list<std::shared_ptr<Entity> > m_itemEntities;
std::list<std::shared_ptr<Entity> > m_hangingEntities;
std::list<std::shared_ptr<Entity> > m_arrowEntities;
std::list<std::shared_ptr<Entity> > m_experienceOrbEntities;
int m_primedTntCount;
int m_fallingTileCount;
CRITICAL_SECTION m_limiterCS;
std::list< std::shared_ptr<Entity> > m_itemEntities;
std::list< std::shared_ptr<Entity> > m_hangingEntities;
std::list< std::shared_ptr<Entity> > m_arrowEntities;
std::list< std::shared_ptr<Entity> > m_experienceOrbEntities;
virtual bool addEntity(std::shared_ptr<Entity> e);
void entityAddedExtra(std::shared_ptr<Entity> e);
void entityRemovedExtra(std::shared_ptr<Entity> e);
virtual bool addEntity(std::shared_ptr<Entity> e);
void entityAddedExtra(std::shared_ptr<Entity> e);
void entityRemovedExtra(std::shared_ptr<Entity> e);
virtual bool newPrimedTntAllowed();
virtual bool newFallingTileAllowed();
virtual bool newPrimedTntAllowed();
virtual bool newFallingTileAllowed();
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
void flagEntitiesToBeRemoved(unsigned int* flags,
bool* removedFound); // 4J added
// 4J added
static const int MAX_UPDATES = 256;
// 4J added
static const int MAX_UPDATES = 256;
// Each of these need to be duplicated for each level in the current game. As we currently only have 2 (over/nether), making this constant
static Level *m_level[3];
static int m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
static int m_updateChunkZ[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
static int m_updateChunkCount[3];
static int m_updateTileX[3][MAX_UPDATES];
static int m_updateTileY[3][MAX_UPDATES];
static int m_updateTileZ[3][MAX_UPDATES];
static int m_updateTileCount[3];
static int m_randValue[3];
// Each of these need to be duplicated for each level in the current game.
// As we currently only have 2 (over/nether), making this constant
static Level* m_level[3];
static int m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
static int m_updateChunkZ[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
static int m_updateChunkCount[3];
static int m_updateTileX[3][MAX_UPDATES];
static int m_updateTileY[3][MAX_UPDATES];
static int m_updateTileZ[3][MAX_UPDATES];
static int m_updateTileCount[3];
static int m_randValue[3];
static C4JThread::EventArray* m_updateTrigger;
static CRITICAL_SECTION m_updateCS[3];
static C4JThread* m_updateThread;
static int runUpdate(void* lpParam);
static C4JThread::EventArray* m_updateTrigger;
static CRITICAL_SECTION m_updateCS[3];
static C4JThread* m_updateThread;
static int runUpdate(void* lpParam);
};

View file

@ -11,116 +11,120 @@
#include "../../Minecraft.World/Headers/net.minecraft.network.packet.h"
#include "../../Minecraft.World/Level/LevelData.h"
ServerLevelListener::ServerLevelListener(MinecraftServer *server, ServerLevel *level)
{
this->server = server;
this->level = level;
ServerLevelListener::ServerLevelListener(MinecraftServer* server,
ServerLevel* level) {
this->server = server;
this->level = level;
}
// 4J removed -
// 4J removed -
/*
void ServerLevelListener::addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za)
void ServerLevelListener::addParticle(const std::wstring& name, double x, double
y, double z, double xa, double ya, double za)
{
}
*/
void ServerLevelListener::addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za)
{
void ServerLevelListener::addParticle(ePARTICLE_TYPE name, double x, double y,
double z, double xa, double ya,
double za) {}
void ServerLevelListener::allChanged() {}
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity) {
MemSect(10);
level->getTracker()->addEntity(entity);
MemSect(0);
}
void ServerLevelListener::allChanged()
{
}
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity)
{
MemSect(10);
level->getTracker()->addEntity(entity);
MemSect(0);
}
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
{
level->getTracker()->removeEntity(entity);
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity) {
level->getTracker()->removeEntity(entity);
}
// 4J added
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity)
{
std::shared_ptr<ServerPlayer> player = std::dynamic_pointer_cast<ServerPlayer>(entity);
player->getLevel()->getTracker()->removePlayer(entity);
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity) {
std::shared_ptr<ServerPlayer> player =
std::dynamic_pointer_cast<ServerPlayer>(entity);
player->getLevel()->getTracker()->removePlayer(entity);
}
void ServerLevelListener::playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
{
if(iSound < 0)
{
app.DebugPrintf("ServerLevelListener received request for sound less than 0, so ignoring\n");
}
else
{
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
server->getPlayers()->broadcast(x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
}
void ServerLevelListener::playSound(int iSound, double x, double y, double z,
float volume, float pitch,
float fClipSoundDist) {
if (iSound < 0) {
app.DebugPrintf(
"ServerLevelListener received request for sound less than 0, so "
"ignoring\n");
} else {
// 4J-PB - I don't want to broadcast player sounds to my local machine,
// since we're already playing these in the LevelRenderer::playSound.
// The PC version does seem to do this and the result is I can stop
// walking , and then I'll hear my footstep sound with a delay
server->getPlayers()->broadcast(
x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id,
std::shared_ptr<LevelSoundPacket>(
new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
}
}
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
{
if(iSound < 0)
{
app.DebugPrintf("ServerLevelListener received request for sound less than 0, so ignoring\n");
}
else
{
// 4J-PB - I don't want to broadcast player sounds to my local machine, since we're already playing these in the LevelRenderer::playSound.
// The PC version does seem to do this and the result is I can stop walking , and then I'll hear my footstep sound with a delay
std::shared_ptr<Player> player= std::dynamic_pointer_cast<Player>(entity);
server->getPlayers()->broadcast(player,x, y, z, volume > 1 ? 16 * volume : 16, level->dimension->id, std::shared_ptr<LevelSoundPacket>(new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
}
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity, int iSound,
double x, double y, double z, float volume,
float pitch, float fClipSoundDist) {
if (iSound < 0) {
app.DebugPrintf(
"ServerLevelListener received request for sound less than 0, so "
"ignoring\n");
} else {
// 4J-PB - I don't want to broadcast player sounds to my local machine,
// since we're already playing these in the LevelRenderer::playSound.
// The PC version does seem to do this and the result is I can stop
// walking , and then I'll hear my footstep sound with a delay
std::shared_ptr<Player> player =
std::dynamic_pointer_cast<Player>(entity);
server->getPlayers()->broadcast(
player, x, y, z, volume > 1 ? 16 * volume : 16,
level->dimension->id,
std::shared_ptr<LevelSoundPacket>(
new LevelSoundPacket(iSound, x, y, z, volume, pitch)));
}
}
void ServerLevelListener::setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level)
{
void ServerLevelListener::setTilesDirty(int x0, int y0, int z0, int x1, int y1,
int z1, Level* level) {}
void ServerLevelListener::skyColorChanged() {}
void ServerLevelListener::tileChanged(int x, int y, int z) {
level->getChunkMap()->tileChanged(x, y, z);
}
void ServerLevelListener::skyColorChanged()
{
void ServerLevelListener::tileLightChanged(int x, int y, int z) {}
void ServerLevelListener::playStreamingMusic(const std::wstring& name, int x,
int y, int z) {}
void ServerLevelListener::levelEvent(std::shared_ptr<Player> source, int type,
int x, int y, int z, int data) {
server->getPlayers()->broadcast(
source, x, y, z, 64, level->dimension->id,
std::shared_ptr<LevelEventPacket>(
new LevelEventPacket(type, x, y, z, data)));
}
void ServerLevelListener::tileChanged(int x, int y, int z)
{
level->getChunkMap()->tileChanged(x, y, z);
}
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z,
int progress) {
// for (ServerPlayer p : server->getPlayers()->players)
for (AUTO_VAR(it, server->getPlayers()->players.begin());
it != server->getPlayers()->players.end(); ++it) {
std::shared_ptr<ServerPlayer> p = *it;
if (p == NULL || p->level != level || p->entityId == id) continue;
double xd = (double)x - p->x;
double yd = (double)y - p->y;
double zd = (double)z - p->z;
void ServerLevelListener::tileLightChanged(int x, int y, int z)
{
}
void ServerLevelListener::playStreamingMusic(const std::wstring& name, int x, int y, int z)
{
}
void ServerLevelListener::levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data)
{
server->getPlayers()->broadcast(source, x, y, z, 64, level->dimension->id, std::shared_ptr<LevelEventPacket>( new LevelEventPacket(type, x, y, z, data) ) );
}
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z, int progress)
{
//for (ServerPlayer p : server->getPlayers()->players)
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
{
std::shared_ptr<ServerPlayer> p = *it;
if (p == NULL || p->level != level || p->entityId == id) continue;
double xd = (double) x - p->x;
double yd = (double) y - p->y;
double zd = (double) z - p->z;
if (xd * xd + yd * yd + zd * zd < 32 * 32)
{
p->connection->send(std::shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
}
}
if (xd * xd + yd * yd + zd * zd < 32 * 32) {
p->connection->send(std::shared_ptr<TileDestructionPacket>(
new TileDestructionPacket(id, x, y, z, progress)));
}
}
}

View file

@ -7,27 +7,37 @@ class MinecraftServer;
class ServerLevel;
// 4J - renamed class to ServerLevelListener to avoid clash with LevelListener
class ServerLevelListener : public LevelListener
{
class ServerLevelListener : public LevelListener {
private:
MinecraftServer *server;
ServerLevel *level;
MinecraftServer* server;
ServerLevel* level;
public:
ServerLevelListener(MinecraftServer *server, ServerLevel *level);
// 4J removed - virtual void addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za);
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
ServerLevelListener(MinecraftServer* server, ServerLevel* level);
// 4J removed - virtual void addParticle(const std::wstring& name, double x,
// double y, double z, double xa, double ya, double za);
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z,
double xa, double ya, double za); // 4J added
virtual void allChanged();
virtual void entityAdded(std::shared_ptr<Entity> entity);
virtual void entityRemoved(std::shared_ptr<Entity> entity);
virtual void playerRemoved(std::shared_ptr<Entity> entity); // 4J added - for when a player is removed from the level's player array, not just the entity storage
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
virtual void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
virtual void playerRemoved(
std::shared_ptr<Entity>
entity); // 4J added - for when a player is removed from the
// level's player array, not just the entity storage
virtual void playSound(int iSound, double x, double y, double z,
float volume, float pitch, float fClipSoundDist);
virtual void playSound(std::shared_ptr<Entity> entity, int iSound, double x,
double y, double z, float volume, float pitch,
float fClipSoundDist);
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1,
Level* level); // 4J - added level param
virtual void skyColorChanged();
virtual void tileChanged(int x, int y, int z);
virtual void tileLightChanged(int x, int y, int z);
virtual void playStreamingMusic(const std::wstring& name, int x, int y, int z);
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
virtual void tileLightChanged(int x, int y, int z);
virtual void playStreamingMusic(const std::wstring& name, int x, int y,
int z);
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x,
int y, int z, int data);
virtual void destroyTileProgress(int id, int x, int y, int z, int progress);
};

File diff suppressed because it is too large Load diff

View file

@ -46,299 +46,349 @@ class PsPlusUpsellWrapper;
#undef linux
#endif
class Minecraft
{
class Minecraft {
public:
static const std::wstring VERSION_STRING;
Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen);
void init();
static const std::wstring VERSION_STRING;
Minecraft(Component* mouseComponent, Canvas* parent,
MinecraftApplet* minecraftApplet, int width, int height,
bool fullscreen);
void init();
// 4J - removed
// void crash(CrashReport crash);
// public abstract void onCrash(CrashReport crash);
// 4J - removed
// void crash(CrashReport crash);
// public abstract void onCrash(CrashReport crash);
private:
static Minecraft *m_instance;
static Minecraft* m_instance;
public:
MultiPlayerGameMode *gameMode;
MultiPlayerGameMode* gameMode;
private:
bool fullscreen;
bool hasCrashed;
bool fullscreen;
bool hasCrashed;
C4JThread::EventQueue* levelTickEventQueue;
static void levelTickUpdateFunc(void* pParam);
static void levelTickThreadInitFunc();
C4JThread::EventQueue* levelTickEventQueue;
static void levelTickUpdateFunc(void* pParam);
static void levelTickThreadInitFunc();
public:
int width, height;
int width_phys, height_phys; // 4J - added
// private OpenGLCapabilities openGLCapabilities;
int width, height;
int width_phys, height_phys; // 4J - added
// private OpenGLCapabilities openGLCapabilities;
private:
Timer *timer;
bool reloadTextures;
Timer* timer;
bool reloadTextures;
public:
Level *oldLevel; // 4J Stu added to keep a handle on an old level so we can delete it
//HANDLE m_hPlayerRespawned; // 4J Added so we can wait in menus until it is done (for async in multiplayer)
Level* oldLevel; // 4J Stu added to keep a handle on an old level so we can
// delete it
// HANDLE m_hPlayerRespawned; // 4J Added so we can wait in menus until it
// is done (for async in multiplayer)
public:
MultiPlayerLevel* level;
LevelRenderer* levelRenderer;
std::shared_ptr<MultiplayerLocalPlayer> player;
MultiPlayerLevel *level;
LevelRenderer *levelRenderer;
std::shared_ptr<MultiplayerLocalPlayer> player;
MultiPlayerLevelArray levels;
MultiPlayerLevelArray levels;
std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
MultiPlayerGameMode* localgameModes[XUSER_MAX_COUNT];
int localPlayerIdx;
ItemInHandRenderer* localitemInHandRenderers[XUSER_MAX_COUNT];
// 4J-PB - so we can have debugoptions in the server
unsigned int uiDebugOptionsA[XUSER_MAX_COUNT];
std::shared_ptr<MultiplayerLocalPlayer> localplayers[XUSER_MAX_COUNT];
MultiPlayerGameMode *localgameModes[XUSER_MAX_COUNT];
int localPlayerIdx;
ItemInHandRenderer *localitemInHandRenderers[XUSER_MAX_COUNT];
// 4J-PB - so we can have debugoptions in the server
unsigned int uiDebugOptionsA[XUSER_MAX_COUNT];
// 4J Stu - Added these so that we can show a Xui scene while connecting
bool m_connectionFailed[XUSER_MAX_COUNT];
DisconnectPacket::eDisconnectReason
m_connectionFailedReason[XUSER_MAX_COUNT];
ClientConnection* m_pendingLocalConnections[XUSER_MAX_COUNT];
// 4J Stu - Added these so that we can show a Xui scene while connecting
bool m_connectionFailed[XUSER_MAX_COUNT];
DisconnectPacket::eDisconnectReason m_connectionFailedReason[XUSER_MAX_COUNT];
ClientConnection *m_pendingLocalConnections[XUSER_MAX_COUNT];
bool addLocalPlayer(
int idx); // Re-arrange the screen and start the connection
void addPendingLocalConnection(int idx, ClientConnection* connection);
void connectionDisconnected(int idx,
DisconnectPacket::eDisconnectReason reason) {
m_connectionFailed[idx] = true;
m_connectionFailedReason[idx] = reason;
}
bool addLocalPlayer(int idx); // Re-arrange the screen and start the connection
void addPendingLocalConnection(int idx, ClientConnection *connection);
void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; }
std::shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(
int idx, const std::wstring& name, int pad, int iDimension,
ClientConnection* clientConnection = NULL,
MultiPlayerLevel* levelpassedin = NULL);
void createPrimaryLocalPlayer(int iPad);
bool setLocalPlayerIdx(int idx);
int getLocalPlayerIdx();
void removeLocalPlayerIdx(int idx);
void storeExtraLocalPlayer(int idx);
void updatePlayerViewportAssignments();
int unoccupiedQuadrant; // 4J - added
std::shared_ptr<MultiplayerLocalPlayer> createExtraLocalPlayer(int idx, const std::wstring& name, int pad, int iDimension, ClientConnection *clientConnection = NULL,MultiPlayerLevel *levelpassedin=NULL);
void createPrimaryLocalPlayer(int iPad);
bool setLocalPlayerIdx(int idx);
int getLocalPlayerIdx();
void removeLocalPlayerIdx(int idx);
void storeExtraLocalPlayer(int idx);
void updatePlayerViewportAssignments();
int unoccupiedQuadrant; // 4J - added
std::shared_ptr<Mob> cameraTargetPlayer;
ParticleEngine* particleEngine;
User* user;
std::wstring serverDomain;
Canvas* parent;
bool appletMode;
std::shared_ptr<Mob> cameraTargetPlayer;
ParticleEngine *particleEngine;
User *user;
std::wstring serverDomain;
Canvas *parent;
bool appletMode;
// 4J - per player ?
volatile bool pause;
// 4J - per player ?
volatile bool pause;
Textures* textures;
Font *font, *altFont;
Screen* screen;
ProgressRenderer* progressRenderer;
GameRenderer* gameRenderer;
Textures *textures;
Font *font, *altFont;
Screen *screen;
ProgressRenderer *progressRenderer;
GameRenderer *gameRenderer;
private:
BackgroundDownloader *bgLoader;
BackgroundDownloader* bgLoader;
int ticks;
// 4J-PB - moved to per player
int ticks;
// 4J-PB - moved to per player
//int missTime;
// int missTime;
int orgWidth, orgHeight;
int orgWidth, orgHeight;
public:
AchievementPopup *achievementPopup;
public:
Gui *gui;
// 4J - move to the per player structure?
bool noRender;
AchievementPopup* achievementPopup;
public:
Gui* gui;
// 4J - move to the per player structure?
bool noRender;
HumanoidModel* humanoidModel;
HitResult* hitResult;
Options* options;
HumanoidModel *humanoidModel;
HitResult *hitResult;
Options *options;
protected:
MinecraftApplet *minecraftApplet;
public:
SoundEngine *soundEngine;
MouseHandler *mouseHandler;
public:
TexturePackRepository *skins;
File workingDirectory;
private:
LevelStorageSource *levelSource;
public:
static const int frameTimes_length = 512;
static __int64 frameTimes[frameTimes_length];
static const int tickTimes_length = 512;
static __int64 tickTimes[tickTimes_length];
static int frameTimePos;
static __int64 warezTime;
private:
int rightClickDelay;
public:
// 4J- this should really be in localplayer
StatsCounter* stats[4];
private:
std::wstring connectToIp;
int connectToPort;
MinecraftApplet* minecraftApplet;
public:
void clearConnectionFailed();
void connectTo(const std::wstring& server, int port);
private:
void renderLoadingScreen();
SoundEngine* soundEngine;
MouseHandler* mouseHandler;
public:
void blit(int x, int y, int sx, int sy, int w, int h);
TexturePackRepository* skins;
File workingDirectory;
private:
static File workDir;
LevelStorageSource* levelSource;
public:
static File getWorkingDirectory();
static File getWorkingDirectory(const std::wstring& applicationName);
public:
LevelStorageSource *getLevelSource();
void setScreen(Screen *screen);
static const int frameTimes_length = 512;
static __int64 frameTimes[frameTimes_length];
static const int tickTimes_length = 512;
static __int64 tickTimes[tickTimes_length];
static int frameTimePos;
static __int64 warezTime;
private:
void checkGlError(const std::wstring& string);
int rightClickDelay;
public:
// 4J- this should really be in localplayer
StatsCounter* stats[4];
private:
std::wstring connectToIp;
int connectToPort;
public:
void clearConnectionFailed();
void connectTo(const std::wstring& server, int port);
private:
void renderLoadingScreen();
public:
void blit(int x, int y, int sx, int sy, int w, int h);
private:
static File workDir;
public:
static File getWorkingDirectory();
static File getWorkingDirectory(const std::wstring& applicationName);
public:
LevelStorageSource* getLevelSource();
void setScreen(Screen* screen);
private:
void checkGlError(const std::wstring& string);
#ifdef __ORBIS__
PsPlusUpsellWrapper *m_pPsPlusUpsell;
PsPlusUpsellWrapper* m_pPsPlusUpsell;
#endif
public:
void destroy();
volatile bool running;
std::wstring fpsString;
void run();
// 4J-PB - split the run into 3 parts so we can run it from our xbox game loop
static Minecraft *GetInstance();
void run_middle();
void run_end();
void destroy();
volatile bool running;
std::wstring fpsString;
void run();
// 4J-PB - split the run into 3 parts so we can run it from our xbox game
// loop
static Minecraft* GetInstance();
void run_middle();
void run_end();
void emergencySave();
void emergencySave();
// 4J - removed
//bool wasDown ;
// 4J - removed
// bool wasDown ;
private:
// void checkScreenshot(); // 4J - removed
// String grabHugeScreenshot(File workDir2, int width, int height, int ssWidth, int ssHeight); // 4J - removed
// void checkScreenshot(); // 4J - removed
// String grabHugeScreenshot(File workDir2, int width, int height, int
// ssWidth, int ssHeight); // 4J - removed
// 4J - per player thing?
__int64 lastTimer;
// 4J - per player thing?
__int64 lastTimer;
void renderFpsMeter(__int64 tickTime);
public:
void stop();
// 4J removed
// bool mouseGrabbed;
// void grabMouse();
// void releaseMouse();
// 4J-PB - moved these into localplayer
//void handleMouseDown(int button, bool down);
//void handleMouseClick(int button);
void pauseGame();
// void toggleFullScreen(); // 4J - removed
private:
void resize(int width, int height);
void renderFpsMeter(__int64 tickTime);
public:
// 4J - Moved to per player
//bool isRaining ;
// 4J - Moved to per player
//__int64 lastTickTime;
void stop();
// 4J removed
// bool mouseGrabbed;
// void grabMouse();
// void releaseMouse();
// 4J-PB - moved these into localplayer
// void handleMouseDown(int button, bool down);
// void handleMouseClick(int button);
void pauseGame();
// void toggleFullScreen(); // 4J - removed
private:
// 4J- per player?
int recheckPlayerIn;
void verify();
void resize(int width, int height);
public:
// 4J - added bFirst parameter, which is true for the first active viewport in splitscreen
// 4J - added bUpdateTextures, which is true if the actual renderer textures are to be updated - this will be true for the last time this tick runs with bFirst true
void tick(bool bFirst, bool bUpdateTextures);
// 4J - Moved to per player
// bool isRaining ;
// 4J - Moved to per player
//__int64 lastTickTime;
private:
void reloadSound();
// 4J- per player?
int recheckPlayerIn;
void verify();
public:
bool isClientSide();
void selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, const std::wstring& levelName, LevelSettings *levelSettings);
//void toggleDimension(int targetDimension);
bool saveSlot(int slot, const std::wstring& name);
bool loadSlot(const std::wstring& userName, int slot);
void releaseLevel(int message);
// 4J Stu - Added the doForceStatsSave param
//void setLevel(Level *level, bool doForceStatsSave = true);
//void setLevel(Level *level, const std::wstring& message, bool doForceStatsSave = true);
void setLevel(MultiPlayerLevel *level, int message = -1, std::shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false);
// 4J-PB - added to force in the 'other' level when the main player creates the level at game load time
void forceaddLevel(MultiPlayerLevel *level);
void prepareLevel(int title); // 4J - changed to public
void fileDownloaded(const std::wstring& name, File *file);
// OpenGLCapabilities getOpenGLCapabilities(); // 4J - removed
// 4J - added bFirst parameter, which is true for the first active viewport
// in splitscreen 4J - added bUpdateTextures, which is true if the actual
// renderer textures are to be updated - this will be true for the last time
// this tick runs with bFirst true
void tick(bool bFirst, bool bUpdateTextures);
std::wstring gatherStats1();
std::wstring gatherStats2();
std::wstring gatherStats3();
std::wstring gatherStats4();
private:
void reloadSound();
void respawnPlayer(int iPad,int dimension,int newEntityId);
static void start(const std::wstring& name, const std::wstring& sid);
static void startAndConnectTo(const std::wstring& name, const std::wstring& sid, const std::wstring& url);
ClientConnection *getConnection(int iPad); // 4J Stu added iPad param
static void main();
static bool renderNames();
static bool useFancyGraphics();
static bool useAmbientOcclusion();
static bool renderDebug();
bool handleClientSideCommand(const std::wstring& chatMessage);
public:
bool isClientSide();
void selectLevel(ConsoleSaveFile* saveFile, const std::wstring& levelId,
const std::wstring& levelName,
LevelSettings* levelSettings);
// void toggleDimension(int targetDimension);
bool saveSlot(int slot, const std::wstring& name);
bool loadSlot(const std::wstring& userName, int slot);
void releaseLevel(int message);
// 4J Stu - Added the doForceStatsSave param
// void setLevel(Level *level, bool doForceStatsSave = true);
// void setLevel(Level *level, const std::wstring& message, bool
// doForceStatsSave = true);
void setLevel(MultiPlayerLevel* level, int message = -1,
std::shared_ptr<Player> forceInsertPlayer = nullptr,
bool doForceStatsSave = true,
bool bPrimaryPlayerSignedOut = false);
// 4J-PB - added to force in the 'other' level when the main player creates
// the level at game load time
void forceaddLevel(MultiPlayerLevel* level);
void prepareLevel(int title); // 4J - changed to public
void fileDownloaded(const std::wstring& name, File* file);
// OpenGLCapabilities getOpenGLCapabilities(); // 4J - removed
static int maxSupportedTextureSize();
void delayTextureReload();
static __int64 currentTimeMillis();
std::wstring gatherStats1();
std::wstring gatherStats2();
std::wstring gatherStats3();
std::wstring gatherStats4();
void respawnPlayer(int iPad, int dimension, int newEntityId);
static void start(const std::wstring& name, const std::wstring& sid);
static void startAndConnectTo(const std::wstring& name,
const std::wstring& sid,
const std::wstring& url);
ClientConnection* getConnection(int iPad); // 4J Stu added iPad param
static void main();
static bool renderNames();
static bool useFancyGraphics();
static bool useAmbientOcclusion();
static bool renderDebug();
bool handleClientSideCommand(const std::wstring& chatMessage);
static int maxSupportedTextureSize();
void delayTextureReload();
static __int64 currentTimeMillis();
#ifdef _DURANGO
static void inGameSignInCheckAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad);
static void inGameSignInCheckAllPrivilegesCallback(void* lpParam,
bool hasPrivileges,
int iPad);
#endif
static int InGame_SignInReturned(void *pParam,bool bContinue, int iPad);
// 4J-PB
Screen * getScreen();
static int InGame_SignInReturned(void* pParam, bool bContinue, int iPad);
// 4J-PB
Screen* getScreen();
// 4J Stu
void forceStatsSave(int idx);
// 4J Stu
void forceStatsSave(int idx);
CRITICAL_SECTION m_setLevelCS;
CRITICAL_SECTION m_setLevelCS;
private:
// A bit field that store whether a particular quadrant is in the full tutorial or not
std::uint8_t m_inFullTutorialBits;
// A bit field that store whether a particular quadrant is in the full
// tutorial or not
std::uint8_t m_inFullTutorialBits;
public:
bool isTutorial();
void playerStartedTutorial(int iPad);
void playerLeftTutorial(int iPad);
bool isTutorial();
void playerStartedTutorial(int iPad);
void playerLeftTutorial(int iPad);
// 4J Added
MultiPlayerLevel *getLevel(int dimension);
// 4J Added
MultiPlayerLevel* getLevel(int dimension);
void tickAllConnections();
void tickAllConnections();
Level *animateTickLevel; // 4J added
Level* animateTickLevel; // 4J added
// 4J - When a client requests a texture, it should add it to here while we are waiting for it
std::vector<std::wstring> m_pendingTextureRequests;
std::vector<std::wstring> m_pendingGeometryRequests; // additional skin box geometry
// 4J - When a client requests a texture, it should add it to here while we
// are waiting for it
std::vector<std::wstring> m_pendingTextureRequests;
std::vector<std::wstring>
m_pendingGeometryRequests; // additional skin box geometry
// 4J Added
bool addPendingClientTextureRequest(const std::wstring &textureName);
void handleClientTextureReceived(const std::wstring &textureName);
void clearPendingClientTextureRequests() { m_pendingTextureRequests.clear(); }
bool addPendingClientGeometryRequest(const std::wstring &textureName);
void handleClientGeometryReceived(const std::wstring &textureName);
void clearPendingClientGeometryRequests() { m_pendingGeometryRequests.clear(); }
// 4J Added
bool addPendingClientTextureRequest(const std::wstring& textureName);
void handleClientTextureReceived(const std::wstring& textureName);
void clearPendingClientTextureRequests() {
m_pendingTextureRequests.clear();
}
bool addPendingClientGeometryRequest(const std::wstring& textureName);
void handleClientGeometryReceived(const std::wstring& textureName);
void clearPendingClientGeometryRequests() {
m_pendingGeometryRequests.clear();
}
unsigned int getCurrentTexturePackId();
ColourTable *getColourTable();
unsigned int getCurrentTexturePackId();
ColourTable* getColourTable();
#if defined __ORBIS__
static int MustSignInReturnedPSN(void *pParam, int iPad, C4JStorage::EMessageResult result);
static int MustSignInReturnedPSN(void* pParam, int iPad,
C4JStorage::EMessageResult result);
#endif
};

File diff suppressed because it is too large Load diff

View file

@ -22,226 +22,265 @@ class CommandDispatcher;
#define MINECRAFT_SERVER_SLOW_QUEUE_DELAY 250
typedef struct _LoadSaveDataThreadParam
{
void *data;
__int64 fileSize;
const std::wstring saveName;
_LoadSaveDataThreadParam(void *data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
typedef struct _LoadSaveDataThreadParam {
void* data;
__int64 fileSize;
const std::wstring saveName;
_LoadSaveDataThreadParam(void* data, __int64 filesize,
const std::wstring& saveName)
: data(data), fileSize(filesize), saveName(saveName) {}
} LoadSaveDataThreadParam;
typedef struct _NetworkGameInitData
{
__int64 seed;
LoadSaveDataThreadParam *saveData;
std::uint32_t settings;
LevelGenerationOptions *levelGen;
std::uint32_t texturePackId;
bool findSeed;
unsigned int xzSize;
unsigned char hellScale;
ESavePlatform savePlatform;
typedef struct _NetworkGameInitData {
__int64 seed;
LoadSaveDataThreadParam* saveData;
std::uint32_t settings;
LevelGenerationOptions* levelGen;
std::uint32_t texturePackId;
bool findSeed;
unsigned int xzSize;
unsigned char hellScale;
ESavePlatform savePlatform;
_NetworkGameInitData()
{
seed = 0;
saveData = NULL;
settings = 0;
levelGen = NULL;
texturePackId = 0;
findSeed = false;
xzSize = LEVEL_LEGACY_WIDTH;
hellScale = HELL_LEVEL_LEGACY_SCALE;
savePlatform = SAVE_FILE_PLATFORM_LOCAL;
}
_NetworkGameInitData() {
seed = 0;
saveData = NULL;
settings = 0;
levelGen = NULL;
texturePackId = 0;
findSeed = false;
xzSize = LEVEL_LEGACY_WIDTH;
hellScale = HELL_LEVEL_LEGACY_SCALE;
savePlatform = SAVE_FILE_PLATFORM_LOCAL;
}
} NetworkGameInitData;
// 4J Stu - 1.0.1 updates the server to implement the ServerInterface class, but I don't think we will use any of the functions that defines so not implementing here
class MinecraftServer : public ConsoleInputSource
{
// 4J Stu - 1.0.1 updates the server to implement the ServerInterface class, but
// I don't think we will use any of the functions that defines so not
// implementing here
class MinecraftServer : public ConsoleInputSource {
public:
static const std::wstring VERSION;
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
static const std::wstring VERSION;
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
// static Logger logger = Logger.getLogger("Minecraft");
// static Logger logger = Logger.getLogger("Minecraft");
static std::unordered_map<std::wstring, int> ironTimers;
private:
static const int DEFAULT_MINECRAFT_PORT = 25565;
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
static const int DEFAULT_MINECRAFT_PORT = 25565;
static const int MS_PER_TICK = 1000 / SharedConstants::TICKS_PER_SECOND;
// 4J Stu - Added 1.0.1, Not needed
//std::wstring localIp;
//int port;
// 4J Stu - Added 1.0.1, Not needed
// std::wstring localIp;
// int port;
public:
ServerConnection *connection;
Settings *settings;
ServerConnection* connection;
Settings* settings;
ServerLevelArray levels;
private:
PlayerList *players;
PlayerList* players;
// 4J Stu - Added 1.0.1, Not needed
//long[] tickTimes = new long[TICK_STATS_SPAN];
//long[][] levelTickTimes;
// 4J Stu - Added 1.0.1, Not needed
// long[] tickTimes = new long[TICK_STATS_SPAN];
// long[][] levelTickTimes;
private:
ConsoleCommands *commands;
ConsoleCommands* commands;
bool running;
bool m_bLoaded;
bool m_bLoaded;
public:
bool stopped;
bool stopped;
int tickCount;
public:
std::wstring progressStatus;
std::wstring progressStatus;
int progress;
private:
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
CommandDispatcher *commandDispatcher;
std::vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J -
//removed
CommandDispatcher* commandDispatcher;
std::vector<ConsoleInput*>
consoleInput; // 4J - was synchronizedList - TODO - investigate
public:
bool onlineMode;
bool animals;
bool npcs;
bool npcs;
bool pvp;
bool allowFlight;
std::wstring motd;
int maxBuildHeight;
std::wstring motd;
int maxBuildHeight;
private:
// 4J Added
//int m_lastSentDifficulty;
// 4J Added
// int m_lastSentDifficulty;
public:
// 4J Stu - This value should be incremented every time the list of players with friends-only UGC settings changes
// It is sent with PreLoginPacket and compared when it comes back in the LoginPacket
std::uint32_t m_ugcPlayersVersion;
// 4J Stu - This value should be incremented every time the list of players
// with friends-only UGC settings changes It is sent with PreLoginPacket and
// compared when it comes back in the LoginPacket
std::uint32_t m_ugcPlayersVersion;
// This value is used to store the texture pack id for the currently loaded world
std::uint32_t m_texturePackId;
// This value is used to store the texture pack id for the currently loaded
// world
std::uint32_t m_texturePackId;
public:
MinecraftServer();
~MinecraftServer();
MinecraftServer();
~MinecraftServer();
private:
// 4J Added - LoadSaveDataThreadParam
bool initServer(__int64 seed, NetworkGameInitData *initData, std::uint32_t initSettings, bool findSeed);
void postProcessTerminate(ProgressRenderer *mcprogress);
bool loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
// 4J Added - LoadSaveDataThreadParam
bool initServer(__int64 seed, NetworkGameInitData* initData,
std::uint32_t initSettings, bool findSeed);
void postProcessTerminate(ProgressRenderer* mcprogress);
bool loadLevel(LevelStorageSource* storageSource, const std::wstring& name,
__int64 levelSeed, LevelType* pLevelType,
NetworkGameInitData* initData);
void setProgress(const std::wstring& status, int progress);
void endProgress();
void saveAllChunks();
void saveGameRules();
void saveGameRules();
void stopServer();
public:
void setMaxBuildHeight(int maxBuildHeight);
int getMaxBuildHeight();
PlayerList *getPlayers();
void setPlayers(PlayerList *players);
ServerConnection *getConnection();
bool isAnimals();
void setAnimals(bool animals);
bool isNpcsEnabled();
void setNpcsEnabled(bool npcs);
bool isPvpAllowed();
void setPvpAllowed(bool pvp);
bool isFlightAllowed();
void setFlightAllowed(bool allowFlight);
bool isNetherEnabled();
bool isHardcore();
CommandDispatcher *getCommandDispatcher();
void setMaxBuildHeight(int maxBuildHeight);
int getMaxBuildHeight();
PlayerList* getPlayers();
void setPlayers(PlayerList* players);
ServerConnection* getConnection();
bool isAnimals();
void setAnimals(bool animals);
bool isNpcsEnabled();
void setNpcsEnabled(bool npcs);
bool isPvpAllowed();
void setPvpAllowed(bool pvp);
bool isFlightAllowed();
void setFlightAllowed(bool allowFlight);
bool isNetherEnabled();
bool isHardcore();
CommandDispatcher* getCommandDispatcher();
public:
void halt();
void run(__int64 seed, void *lpParameter);
void halt();
void run(__int64 seed, void* lpParameter);
void broadcastStartSavingPacket();
void broadcastStopSavingPacket();
void broadcastStartSavingPacket();
void broadcastStopSavingPacket();
private:
void tick();
public:
void handleConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
void handleConsoleInputs();
// void addTickable(Tickable tickable); // 4J removed
static void main(__int64 seed, void *lpParameter);
static void HaltServer(bool bPrimaryPlayerSignedOut=false);
void tick();
File *getFile(const std::wstring& name);
public:
void handleConsoleInput(const std::wstring& msg,
ConsoleInputSource* source);
void handleConsoleInputs();
// void addTickable(Tickable tickable); // 4J removed
static void main(__int64 seed, void* lpParameter);
static void HaltServer(bool bPrimaryPlayerSignedOut = false);
File* getFile(const std::wstring& name);
void info(const std::wstring& string);
void warn(const std::wstring& string);
std::wstring getConsoleName();
ServerLevel *getLevel(int dimension);
void setLevel(int dimension, ServerLevel *level); // 4J added
static MinecraftServer *getInstance() { return server; } // 4J added
static bool serverHalted() { return s_bServerHalted; }
static bool saveOnExitAnswered() { return s_bSaveOnExitAnswered; }
static void resetFlags() { s_bServerHalted = false; s_bSaveOnExitAnswered = false; }
ServerLevel* getLevel(int dimension);
void setLevel(int dimension, ServerLevel* level); // 4J added
static MinecraftServer* getInstance() { return server; } // 4J added
static bool serverHalted() { return s_bServerHalted; }
static bool saveOnExitAnswered() { return s_bSaveOnExitAnswered; }
static void resetFlags() {
s_bServerHalted = false;
s_bSaveOnExitAnswered = false;
}
bool flagEntitiesToBeRemoved(unsigned int *flags); // 4J added
bool flagEntitiesToBeRemoved(unsigned int* flags); // 4J added
private:
//4J Added
static MinecraftServer *server;
// 4J Added
static MinecraftServer* server;
static bool setTimeOfDayAtEndOfTick;
static __int64 setTimeOfDay;
static bool setTimeAtEndOfTick;
static __int64 setTime;
static bool setTimeOfDayAtEndOfTick;
static __int64 setTimeOfDay;
static bool setTimeAtEndOfTick;
static __int64 setTime;
static bool m_bPrimaryPlayerSignedOut; // 4J-PB added to tell the stopserver not to save the game - another player may have signed in in their place, so ProfileManager.IsSignedIn isn't enough
static bool s_bServerHalted; // 4J Stu Added so that we can halt the server even before it's been created properly
static bool s_bSaveOnExitAnswered; // 4J Stu Added so that we only ask this question once when we exit
static bool
m_bPrimaryPlayerSignedOut; // 4J-PB added to tell the stopserver not to
// save the game - another player may have
// signed in in their place, so
// ProfileManager.IsSignedIn isn't enough
static bool s_bServerHalted; // 4J Stu Added so that we can halt the server
// even before it's been created properly
static bool s_bSaveOnExitAnswered; // 4J Stu Added so that we only ask this
// question once when we exit
// 4J - added so that we can have a separate thread for post processing chunks on level creation
static int runPostUpdate(void* lpParam);
C4JThread* m_postUpdateThread;
bool m_postUpdateTerminate;
class postProcessRequest
{
public:
int x, z;
ChunkSource *chunkSource;
postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {}
};
std::vector<postProcessRequest> m_postProcessRequests;
CRITICAL_SECTION m_postProcessCS;
public:
void addPostProcessRequest(ChunkSource *chunkSource, int x, int z);
// 4J - added so that we can have a separate thread for post processing
// chunks on level creation
static int runPostUpdate(void* lpParam);
C4JThread* m_postUpdateThread;
bool m_postUpdateTerminate;
class postProcessRequest {
public:
int x, z;
ChunkSource* chunkSource;
postProcessRequest(int x, int z, ChunkSource* chunkSource)
: x(x), z(z), chunkSource(chunkSource) {}
};
std::vector<postProcessRequest> m_postProcessRequests;
CRITICAL_SECTION m_postProcessCS;
public:
static PlayerList *getPlayerList() { if( server != NULL ) return server->players; else return NULL; }
static void SetTimeOfDay(__int64 time) { setTimeOfDayAtEndOfTick = true; setTimeOfDay = time; }
static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; }
C4JThread::Event* m_serverPausedEvent;
private:
// 4J Added
bool m_isServerPaused;
void addPostProcessRequest(ChunkSource* chunkSource, int x, int z);
// 4J Added - A static that stores the QNet index of the player that is next allowed to send a packet in the slow queue
static int s_slowQueuePlayerIndex;
static int s_slowQueueLastTime;
public:
static bool s_slowQueuePacketSent;
static PlayerList* getPlayerList() {
if (server != NULL)
return server->players;
else
return NULL;
}
static void SetTimeOfDay(__int64 time) {
setTimeOfDayAtEndOfTick = true;
setTimeOfDay = time;
}
static void SetTime(__int64 time) {
setTimeAtEndOfTick = true;
setTime = time;
}
bool IsServerPaused() { return m_isServerPaused; }
C4JThread::Event* m_serverPausedEvent;
private:
// 4J Added
bool m_saveOnExit;
bool m_suspending;
// 4J Added
bool m_isServerPaused;
// 4J Added - A static that stores the QNet index of the player that is next
// allowed to send a packet in the slow queue
static int s_slowQueuePlayerIndex;
static int s_slowQueueLastTime;
public:
//static int getSlowQueueIndex() { return s_slowQueuePlayerIndex; }
static bool canSendOnSlowQueue(INetworkPlayer *player);
static void cycleSlowQueueIndex();
static bool s_slowQueuePacketSent;
void setSaveOnExit(bool save) { m_saveOnExit = save; s_bSaveOnExitAnswered = true; }
void Suspend();
bool IsSuspending();
bool IsServerPaused() { return m_isServerPaused; }
// 4J Stu - A load of functions were all added in 1.0.1 in the ServerInterface, but I don't think we need any of them
private:
// 4J Added
bool m_saveOnExit;
bool m_suspending;
public:
// static int getSlowQueueIndex() { return s_slowQueuePlayerIndex; }
static bool canSendOnSlowQueue(INetworkPlayer* player);
static void cycleSlowQueueIndex();
void setSaveOnExit(bool save) {
m_saveOnExit = save;
s_bSaveOnExitAnswered = true;
}
void Suspend();
bool IsSuspending();
// 4J Stu - A load of functions were all added in 1.0.1 in the
// ServerInterface, but I don't think we need any of them
};

File diff suppressed because it is too large Load diff

View file

@ -6,81 +6,97 @@ class SavedDataStorage;
class Socket;
class MultiplayerLocalPlayer;
class ClientConnection : public PacketListener
{
class ClientConnection : public PacketListener {
private:
enum eClientConnectionConnectingState
{
eCCPreLoginSent = 0,
eCCPreLoginReceived,
eCCLoginSent,
eCCLoginReceived,
eCCConnected
};
enum eClientConnectionConnectingState {
eCCPreLoginSent = 0,
eCCPreLoginReceived,
eCCLoginSent,
eCCLoginReceived,
eCCConnected
};
private:
bool done;
Connection *connection;
bool done;
Connection* connection;
public:
std::wstring message;
bool createdOk; // 4J added
std::wstring message;
bool createdOk; // 4J added
private:
Minecraft *minecraft;
MultiPlayerLevel *level;
Minecraft* minecraft;
MultiPlayerLevel* level;
bool started;
// 4J Stu - I don't think we are interested in the PlayerInfo data, so I'm not going to use it at the moment
//Map<String, PlayerInfo> playerInfoMap = new HashMap<String, PlayerInfo>();
// 4J Stu - I don't think we are interested in the PlayerInfo data, so I'm
// not going to use it at the moment
// Map<String, PlayerInfo> playerInfoMap = new HashMap<String,
// PlayerInfo>();
public:
//List<PlayerInfo> playerInfos = new ArrayList<PlayerInfo>();
// List<PlayerInfo> playerInfos = new ArrayList<PlayerInfo>();
int maxPlayers;
int maxPlayers;
public:
bool isStarted() { return started; } // 4J Added
bool isClosed() { return done; } // 4J Added
Socket *getSocket() { return connection->getSocket(); } // 4J Added
bool isStarted() { return started; } // 4J Added
bool isClosed() { return done; } // 4J Added
Socket* getSocket() { return connection->getSocket(); } // 4J Added
private:
int m_userIndex; // 4J Added
int m_userIndex; // 4J Added
public:
SavedDataStorage *savedDataStorage;
ClientConnection(Minecraft *minecraft, const std::wstring& ip, int port);
ClientConnection(Minecraft *minecraft, Socket *socket, int iUserIndex = -1);
~ClientConnection();
SavedDataStorage* savedDataStorage;
ClientConnection(Minecraft* minecraft, const std::wstring& ip, int port);
ClientConnection(Minecraft* minecraft, Socket* socket, int iUserIndex = -1);
~ClientConnection();
void tick();
INetworkPlayer *getNetworkPlayer();
INetworkPlayer* getNetworkPlayer();
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
virtual void handleAddExperienceOrb(std::shared_ptr<AddExperienceOrbPacket> packet);
virtual void handleAddGlobalEntity(std::shared_ptr<AddGlobalEntityPacket> packet);
virtual void handleAddExperienceOrb(
std::shared_ptr<AddExperienceOrbPacket> packet);
virtual void handleAddGlobalEntity(
std::shared_ptr<AddGlobalEntityPacket> packet);
virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
virtual void handleSetEntityMotion(std::shared_ptr<SetEntityMotionPacket> packet);
virtual void handleSetEntityData(std::shared_ptr<SetEntityDataPacket> packet);
virtual void handleSetEntityMotion(
std::shared_ptr<SetEntityMotionPacket> packet);
virtual void handleSetEntityData(
std::shared_ptr<SetEntityDataPacket> packet);
virtual void handleAddPlayer(std::shared_ptr<AddPlayerPacket> packet);
virtual void handleTeleportEntity(std::shared_ptr<TeleportEntityPacket> packet);
virtual void handleTeleportEntity(
std::shared_ptr<TeleportEntityPacket> packet);
virtual void handleMoveEntity(std::shared_ptr<MoveEntityPacket> packet);
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
virtual void handleMoveEntitySmall(std::shared_ptr<MoveEntityPacketSmall> packet);
virtual void handleRemoveEntity(std::shared_ptr<RemoveEntitiesPacket> packet);
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
virtual void handleMoveEntitySmall(
std::shared_ptr<MoveEntityPacketSmall> packet);
virtual void handleRemoveEntity(
std::shared_ptr<RemoveEntitiesPacket> packet);
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
Random *random;
// 4J Added
virtual void handleChunkVisibilityArea(std::shared_ptr<ChunkVisibilityAreaPacket> packet);
Random* random;
virtual void handleChunkVisibility(std::shared_ptr<ChunkVisibilityPacket> packet);
virtual void handleChunkTilesUpdate(std::shared_ptr<ChunkTilesUpdatePacket> packet);
virtual void handleBlockRegionUpdate(std::shared_ptr<BlockRegionUpdatePacket> packet);
// 4J Added
virtual void handleChunkVisibilityArea(
std::shared_ptr<ChunkVisibilityAreaPacket> packet);
virtual void handleChunkVisibility(
std::shared_ptr<ChunkVisibilityPacket> packet);
virtual void handleChunkTilesUpdate(
std::shared_ptr<ChunkTilesUpdatePacket> packet);
virtual void handleBlockRegionUpdate(
std::shared_ptr<BlockRegionUpdatePacket> packet);
virtual void handleTileUpdate(std::shared_ptr<TileUpdatePacket> packet);
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
void* reasonObjects);
void sendAndDisconnect(std::shared_ptr<Packet> packet);
void send(std::shared_ptr<Packet> packet);
virtual void handleTakeItemEntity(std::shared_ptr<TakeItemEntityPacket> packet);
virtual void handleTakeItemEntity(
std::shared_ptr<TakeItemEntityPacket> packet);
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handleEntityActionAtPosition(std::shared_ptr<EntityActionAtPositionPacket> packet);
virtual void handleEntityActionAtPosition(
std::shared_ptr<EntityActionAtPositionPacket> packet);
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
void close();
virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
@ -88,53 +104,79 @@ public:
virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
private:
std::shared_ptr<Entity> getEntity(int entityId);
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
std::shared_ptr<Entity> getEntity(int entityId);
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
public:
virtual void handleSetHealth(std::shared_ptr<SetHealthPacket> packet);
virtual void handleSetExperience(std::shared_ptr<SetExperiencePacket> packet);
virtual void handleSetExperience(
std::shared_ptr<SetExperiencePacket> packet);
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
virtual void handleContainerOpen(std::shared_ptr<ContainerOpenPacket> packet);
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
virtual void handleContainerOpen(
std::shared_ptr<ContainerOpenPacket> packet);
virtual void handleContainerSetSlot(
std::shared_ptr<ContainerSetSlotPacket> packet);
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
virtual void handleContainerContent(std::shared_ptr<ContainerSetContentPacket> packet);
virtual void handleContainerContent(
std::shared_ptr<ContainerSetContentPacket> packet);
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
virtual void handleTileEntityData(std::shared_ptr<TileEntityDataPacket> packet);
virtual void handleContainerSetData(std::shared_ptr<ContainerSetDataPacket> packet);
virtual void handleSetEquippedItem(std::shared_ptr<SetEquippedItemPacket> packet);
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
virtual void handleTileEntityData(
std::shared_ptr<TileEntityDataPacket> packet);
virtual void handleContainerSetData(
std::shared_ptr<ContainerSetDataPacket> packet);
virtual void handleSetEquippedItem(
std::shared_ptr<SetEquippedItemPacket> packet);
virtual void handleContainerClose(
std::shared_ptr<ContainerClosePacket> packet);
virtual void handleTileEvent(std::shared_ptr<TileEventPacket> packet);
virtual void handleTileDestruction(std::shared_ptr<TileDestructionPacket> packet);
virtual bool canHandleAsyncPackets();
virtual void handleGameEvent(std::shared_ptr<GameEventPacket> gameEventPacket);
virtual void handleComplexItemData(std::shared_ptr<ComplexItemDataPacket> packet);
virtual void handleTileDestruction(
std::shared_ptr<TileDestructionPacket> packet);
virtual bool canHandleAsyncPackets();
virtual void handleGameEvent(
std::shared_ptr<GameEventPacket> gameEventPacket);
virtual void handleComplexItemData(
std::shared_ptr<ComplexItemDataPacket> packet);
virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
virtual void handleUpdateMobEffect(std::shared_ptr<UpdateMobEffectPacket> packet);
virtual void handleRemoveMobEffect(std::shared_ptr<RemoveMobEffectPacket> packet);
virtual bool isServerPacketListener();
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual Connection *getConnection();
virtual void handleUpdateMobEffect(
std::shared_ptr<UpdateMobEffectPacket> packet);
virtual void handleRemoveMobEffect(
std::shared_ptr<RemoveMobEffectPacket> packet);
virtual bool isServerPacketListener();
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerAbilities(
std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
virtual void handleCustomPayload(
std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual Connection* getConnection();
// 4J Added
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleUpdateProgress(std::shared_ptr<UpdateProgressPacket> packet);
// 4J Added
virtual void handleServerSettingsChanged(
std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(
std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleUpdateProgress(
std::shared_ptr<UpdateProgressPacket> packet);
// 4J Added
static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleUpdateGameRuleProgressPacket(std::shared_ptr<UpdateGameRuleProgressPacket> packet);
virtual void handleXZ(std::shared_ptr<XZPacket> packet);
// 4J Added
static int HostDisconnectReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
static int ExitGameAndSaveReturned(void* pParam, int iPad,
C4JStorage::EMessageResult result);
virtual void handleTextureChange(
std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(
std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleUpdateGameRuleProgressPacket(
std::shared_ptr<UpdateGameRuleProgressPacket> packet);
virtual void handleXZ(std::shared_ptr<XZPacket> packet);
void displayPrivilegeChanges(std::shared_ptr<MultiplayerLocalPlayer> player, unsigned int oldPrivileges);
void displayPrivilegeChanges(std::shared_ptr<MultiplayerLocalPlayer> player,
unsigned int oldPrivileges);
};

View file

@ -10,297 +10,287 @@
#include "../../Minecraft.World/Blocks/Tile.h"
#include "../../Minecraft.World/Level/WaterLevelChunk.h"
MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
{
XZSIZE = level->dimension->getXZSize(); // 4J Added
XZOFFSET = XZSIZE/2; // 4J Added
m_XZSize = XZSIZE;
hasData = new bool[XZSIZE * XZSIZE];
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
XZSIZE = level->dimension->getXZSize(); // 4J Added
XZOFFSET = XZSIZE / 2; // 4J Added
m_XZSize = XZSIZE;
hasData = new bool[XZSIZE * XZSIZE];
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
emptyChunk = new EmptyLevelChunk(level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0);
emptyChunk = new EmptyLevelChunk(
level, byteArray(16 * 16 * Level::maxBuildHeight), 0, 0);
// For normal world dimension, create a chunk that can be used to create the illusion of infinite water at the edge of the world
if( level->dimension->id == 0 )
{
byteArray bytes = byteArray(16 * 16 * 128);
// For normal world dimension, create a chunk that can be used to create the
// illusion of infinite water at the edge of the world
if (level->dimension->id == 0) {
byteArray bytes = byteArray(16 * 16 * 128);
// Superflat.... make grass, not water...
if(level->getLevelData()->getGenerator() == LevelType::lvl_flat)
{
for( int x = 0; x < 16; x++ )
for( int y = 0; y < 128; y++ )
for( int z = 0; z < 16; z++ )
{
unsigned char tileId = 0;
if( y == 3 ) tileId = Tile::grass_Id;
else if( y <= 2 ) tileId = Tile::dirt_Id;
// Superflat.... make grass, not water...
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
for (int x = 0; x < 16; x++)
for (int y = 0; y < 128; y++)
for (int z = 0; z < 16; z++) {
unsigned char tileId = 0;
if (y == 3)
tileId = Tile::grass_Id;
else if (y <= 2)
tileId = Tile::dirt_Id;
bytes[x << 11 | z << 7 | y] = tileId;
}
}
else
{
for( int x = 0; x < 16; x++ )
for( int y = 0; y < 128; y++ )
for( int z = 0; z < 16; z++ )
{
unsigned char tileId = 0;
if( y <= ( level->getSeaLevel() - 10 ) ) tileId = Tile::rock_Id;
else if( y < level->getSeaLevel() ) tileId = Tile::calmWater_Id;
bytes[x << 11 | z << 7 | y] = tileId;
}
} else {
for (int x = 0; x < 16; x++)
for (int y = 0; y < 128; y++)
for (int z = 0; z < 16; z++) {
unsigned char tileId = 0;
if (y <= (level->getSeaLevel() - 10))
tileId = Tile::rock_Id;
else if (y < level->getSeaLevel())
tileId = Tile::calmWater_Id;
bytes[x << 11 | z << 7 | y] = tileId;
}
}
bytes[x << 11 | z << 7 | y] = tileId;
}
}
waterChunk = new WaterLevelChunk(level, bytes, 0, 0);
waterChunk = new WaterLevelChunk(level, bytes, 0, 0);
delete[] bytes.data;
delete[] bytes.data;
if(level->getLevelData()->getGenerator() == LevelType::lvl_flat)
{
for( int x = 0; x < 16; x++ )
for( int y = 0; y < 128; y++ )
for( int z = 0; z < 16; z++ )
{
if( y >= 3 )
{
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15);
}
}
}
else
{
for( int x = 0; x < 16; x++ )
for( int y = 0; y < 128; y++ )
for( int z = 0; z < 16; z++ )
{
if( y >= ( level->getSeaLevel() - 1 ) )
{
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15);
}
else
{
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,2);
}
}
}
}
else
{
waterChunk = NULL;
}
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
for (int x = 0; x < 16; x++)
for (int y = 0; y < 128; y++)
for (int z = 0; z < 16; z++) {
if (y >= 3) {
((WaterLevelChunk*)waterChunk)
->setLevelChunkBrightness(LightLayer::Sky, x, y,
z, 15);
}
}
} else {
for (int x = 0; x < 16; x++)
for (int y = 0; y < 128; y++)
for (int z = 0; z < 16; z++) {
if (y >= (level->getSeaLevel() - 1)) {
((WaterLevelChunk*)waterChunk)
->setLevelChunkBrightness(LightLayer::Sky, x, y,
z, 15);
} else {
((WaterLevelChunk*)waterChunk)
->setLevelChunkBrightness(LightLayer::Sky, x, y,
z, 2);
}
}
}
} else {
waterChunk = NULL;
}
this->level = level;
this->level = level;
this->cache = new LevelChunk *[XZSIZE * XZSIZE];
memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk *));
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate,4000);
this->cache = new LevelChunk*[XZSIZE * XZSIZE];
memset(this->cache, 0, XZSIZE * XZSIZE * sizeof(LevelChunk*));
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate, 4000);
}
MultiPlayerChunkCache::~MultiPlayerChunkCache()
{
delete emptyChunk;
delete waterChunk;
delete cache;
delete hasData;
MultiPlayerChunkCache::~MultiPlayerChunkCache() {
delete emptyChunk;
delete waterChunk;
delete cache;
delete hasData;
AUTO_VAR(itEnd, loadedChunkList.end());
for (AUTO_VAR(it, loadedChunkList.begin()); it != itEnd; it++)
delete *it;
AUTO_VAR(itEnd, loadedChunkList.end());
for (AUTO_VAR(it, loadedChunkList.begin()); it != itEnd; it++) delete *it;
DeleteCriticalSection(&m_csLoadCreate);
DeleteCriticalSection(&m_csLoadCreate);
}
bool MultiPlayerChunkCache::hasChunk(int x, int z)
{
// This cache always claims to have chunks, although it might actually just return empty data if it doesn't have anything
return true;
bool MultiPlayerChunkCache::hasChunk(int x, int z) {
// This cache always claims to have chunks, although it might actually just
// return empty data if it doesn't have anything
return true;
}
// 4J added - find out if we actually really do have a chunk in our cache
bool MultiPlayerChunkCache::reallyHasChunk(int x, int z)
{
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level - if we aren't, then consider that we do have that chunk as we'll be able to use the water chunk there
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return true;
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return true;
int idx = ix * XZSIZE + iz;
bool MultiPlayerChunkCache::reallyHasChunk(int x, int z) {
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level - if we aren't, then consider
// that we do have that chunk as we'll be able to use the water chunk there
if ((ix < 0) || (ix >= XZSIZE)) return true;
if ((iz < 0) || (iz >= XZSIZE)) return true;
int idx = ix * XZSIZE + iz;
LevelChunk *chunk = cache[idx];
if( chunk == NULL )
{
return false;
}
return hasData[idx];
LevelChunk* chunk = cache[idx];
if (chunk == NULL) {
return false;
}
return hasData[idx];
}
void MultiPlayerChunkCache::drop(int x, int z)
{
// 4J Stu - We do want to drop any entities in the chunks, especially for the case when a player is dead as they will
// not get the RemoveEntity packet if an entity is removed.
LevelChunk *chunk = getChunk(x, z);
if (!chunk->isEmpty())
{
// Added parameter here specifies that we don't want to delete tile entities, as they won't get recreated unless they've got update packets
// The tile entities are in general only created on the client by virtue of the chunk rebuild
chunk->unload(false);
void MultiPlayerChunkCache::drop(int x, int z) {
// 4J Stu - We do want to drop any entities in the chunks, especially for
// the case when a player is dead as they will not get the RemoveEntity
// packet if an entity is removed.
LevelChunk* chunk = getChunk(x, z);
if (!chunk->isEmpty()) {
// Added parameter here specifies that we don't want to delete tile
// entities, as they won't get recreated unless they've got update
// packets The tile entities are in general only created on the client
// by virtue of the chunk rebuild
chunk->unload(false);
// 4J - We just want to clear out the entities in the chunk, but everything else should be valid
chunk->loaded = true;
// 4J - We just want to clear out the entities in the chunk, but
// everything else should be valid
chunk->loaded = true;
}
}
LevelChunk *MultiPlayerChunkCache::create(int x, int z)
{
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
int idx = ix * XZSIZE + iz;
LevelChunk *chunk = cache[idx];
LevelChunk *lastChunk = chunk;
LevelChunk* MultiPlayerChunkCache::create(int x, int z) {
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level
if ((ix < 0) || (ix >= XZSIZE))
return (waterChunk ? waterChunk : emptyChunk);
if ((iz < 0) || (iz >= XZSIZE))
return (waterChunk ? waterChunk : emptyChunk);
int idx = ix * XZSIZE + iz;
LevelChunk* chunk = cache[idx];
LevelChunk* lastChunk = chunk;
if( chunk == NULL )
{
EnterCriticalSection(&m_csLoadCreate);
if (chunk == NULL) {
EnterCriticalSection(&m_csLoadCreate);
//LevelChunk *chunk;
if( g_NetworkManager.IsHost() ) // force here to disable sharing of data
{
// 4J-JEV: We are about to use shared data, abort if the server is stopped and the data is deleted.
if (MinecraftServer::getInstance()->serverHalted()) return NULL;
// LevelChunk *chunk;
if (g_NetworkManager.IsHost()) // force here to disable sharing of data
{
// 4J-JEV: We are about to use shared data, abort if the server is
// stopped and the data is deleted.
if (MinecraftServer::getInstance()->serverHalted()) return NULL;
// If we're the host, then don't create the chunk, share data from the server's copy
// If we're the host, then don't create the chunk, share data from
// the server's copy
#ifdef _LARGE_WORLDS
LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(level->dimension->id)->cache->getChunkLoadedOrUnloaded(x,z);
LevelChunk* serverChunk =
MinecraftServer::getInstance()
->getLevel(level->dimension->id)
->cache->getChunkLoadedOrUnloaded(x, z);
#else
LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(level->dimension->id)->cache->getChunk(x,z);
LevelChunk* serverChunk = MinecraftServer::getInstance()
->getLevel(level->dimension->id)
->cache->getChunk(x, z);
#endif
chunk = new LevelChunk(level, x, z, serverChunk);
// Let renderer know that this chunk has been created - it might have made render data from the EmptyChunk if it got to a chunk before the server sent it
level->setTilesDirty( x * 16 , 0 , z * 16 , x * 16 + 15, 127, z * 16 + 15);
hasData[idx] = true;
}
else
{
// Passing an empty array into the LevelChunk ctor, which it now detects and sets up the chunk as compressed & empty
byteArray bytes;
chunk = new LevelChunk(level, x, z, serverChunk);
// Let renderer know that this chunk has been created - it might
// have made render data from the EmptyChunk if it got to a chunk
// before the server sent it
level->setTilesDirty(x * 16, 0, z * 16, x * 16 + 15, 127,
z * 16 + 15);
hasData[idx] = true;
} else {
// Passing an empty array into the LevelChunk ctor, which it now
// detects and sets up the chunk as compressed & empty
byteArray bytes;
chunk = new LevelChunk(level, bytes, x, z);
chunk = new LevelChunk(level, bytes, x, z);
// 4J - changed to use new methods for lighting
chunk->setSkyLightDataAllBright();
// Arrays::fill(chunk->skyLight->data, (uint8_t) 255);
}
chunk->loaded = true;
// 4J - changed to use new methods for lighting
chunk->setSkyLightDataAllBright();
// Arrays::fill(chunk->skyLight->data, (uint8_t)
//255);
}
LeaveCriticalSection(&m_csLoadCreate);
chunk->loaded = true;
#if ( defined _WIN64 || defined __LP64__ )
if( InterlockedCompareExchangeRelease64((LONG64 *)&cache[idx],(LONG64)chunk,(LONG64)lastChunk) == (LONG64)lastChunk )
LeaveCriticalSection(&m_csLoadCreate);
#if (defined _WIN64 || defined __LP64__)
if (InterlockedCompareExchangeRelease64(
(LONG64*)&cache[idx], (LONG64)chunk, (LONG64)lastChunk) ==
(LONG64)lastChunk)
#else
if( InterlockedCompareExchangeRelease((LONG *)&cache[idx],(LONG)chunk,(LONG)lastChunk) == (LONG)lastChunk )
#endif // _DURANGO
{
// If we're sharing with the server, we'll need to calculate our heightmap now, which isn't shared. If we aren't sharing with the server,
// then this will be calculated when the chunk data arrives.
if( g_NetworkManager.IsHost() )
{
chunk->recalcHeightmapOnly();
}
if (InterlockedCompareExchangeRelease((LONG*)&cache[idx], (LONG)chunk,
(LONG)lastChunk) ==
(LONG)lastChunk)
#endif // _DURANGO
{
// If we're sharing with the server, we'll need to calculate our
// heightmap now, which isn't shared. If we aren't sharing with the
// server, then this will be calculated when the chunk data arrives.
if (g_NetworkManager.IsHost()) {
chunk->recalcHeightmapOnly();
}
// Successfully updated the cache
EnterCriticalSection(&m_csLoadCreate);
loadedChunkList.push_back(chunk);
LeaveCriticalSection(&m_csLoadCreate);
}
else
{
// Something else must have updated the cache. Return that chunk and discard this one. This really shouldn't be happening
// in multiplayer
delete chunk;
return cache[idx];
}
// Successfully updated the cache
EnterCriticalSection(&m_csLoadCreate);
loadedChunkList.push_back(chunk);
LeaveCriticalSection(&m_csLoadCreate);
} else {
// Something else must have updated the cache. Return that chunk and
// discard this one. This really shouldn't be happening in
// multiplayer
delete chunk;
return cache[idx];
}
}
else
{
chunk->load();
}
} else {
chunk->load();
}
return chunk;
return chunk;
}
LevelChunk *MultiPlayerChunkCache::getChunk(int x, int z)
{
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
int idx = ix * XZSIZE + iz;
LevelChunk* MultiPlayerChunkCache::getChunk(int x, int z) {
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level
if ((ix < 0) || (ix >= XZSIZE))
return (waterChunk ? waterChunk : emptyChunk);
if ((iz < 0) || (iz >= XZSIZE))
return (waterChunk ? waterChunk : emptyChunk);
int idx = ix * XZSIZE + iz;
LevelChunk *chunk = cache[idx];
if( chunk == NULL )
{
return emptyChunk;
}
else
{
return chunk;
}
LevelChunk* chunk = cache[idx];
if (chunk == NULL) {
return emptyChunk;
} else {
return chunk;
}
}
bool MultiPlayerChunkCache::save(bool force, ProgressListener *progressListener)
{
return true;
bool MultiPlayerChunkCache::save(bool force,
ProgressListener* progressListener) {
return true;
}
bool MultiPlayerChunkCache::tick()
{
return false;
bool MultiPlayerChunkCache::tick() { return false; }
bool MultiPlayerChunkCache::shouldSave() { return false; }
void MultiPlayerChunkCache::postProcess(ChunkSource* parent, int x, int z) {}
std::vector<Biome::MobSpawnerData*>* MultiPlayerChunkCache::getMobsAt(
MobCategory* mobCategory, int x, int y, int z) {
return NULL;
}
bool MultiPlayerChunkCache::shouldSave()
{
return false;
TilePos* MultiPlayerChunkCache::findNearestMapFeature(
Level* level, const std::wstring& featureName, int x, int y, int z) {
return NULL;
}
void MultiPlayerChunkCache::postProcess(ChunkSource *parent, int x, int z)
{
std::wstring MultiPlayerChunkCache::gatherStats() {
EnterCriticalSection(&m_csLoadCreate);
int size = (int)loadedChunkList.size();
LeaveCriticalSection(&m_csLoadCreate);
return L"MultiplayerChunkCache: " + _toString<int>(size);
}
std::vector<Biome::MobSpawnerData *> *MultiPlayerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
{
return NULL;
}
TilePos *MultiPlayerChunkCache::findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z)
{
return NULL;
}
std::wstring MultiPlayerChunkCache::gatherStats()
{
EnterCriticalSection(&m_csLoadCreate);
int size = (int)loadedChunkList.size();
LeaveCriticalSection(&m_csLoadCreate);
return L"MultiplayerChunkCache: " + _toString<int>(size);
}
void MultiPlayerChunkCache::dataReceived(int x, int z)
{
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return;
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return;
int idx = ix * XZSIZE + iz;
hasData[idx] = true;
void MultiPlayerChunkCache::dataReceived(int x, int z) {
int ix = x + XZOFFSET;
int iz = z + XZOFFSET;
// Check we're in range of the stored level
if ((ix < 0) || (ix >= XZSIZE)) return;
if ((iz < 0) || (iz >= XZSIZE)) return;
int idx = ix * XZSIZE + iz;
hasData[idx] = true;
}

View file

@ -3,45 +3,48 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
#include "../../Minecraft.World/Level/RandomLevelSource.h"
class ServerChunkCache;
// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
class MultiPlayerChunkCache : public ChunkSource
{
friend class LevelRenderer;
// 4J - various alterations here to make this thread safe, and operate as a
// fixed sized cache
class MultiPlayerChunkCache : public ChunkSource {
friend class LevelRenderer;
private:
LevelChunk *emptyChunk;
LevelChunk *waterChunk;
LevelChunk* emptyChunk;
LevelChunk* waterChunk;
std::vector<LevelChunk *> loadedChunkList;
std::vector<LevelChunk*> loadedChunkList;
LevelChunk **cache;
// 4J - added for multithreaded support
CRITICAL_SECTION m_csLoadCreate;
// 4J - size of cache is defined by size of one side - must be even
int XZSIZE;
int XZOFFSET;
bool *hasData;
LevelChunk** cache;
// 4J - added for multithreaded support
CRITICAL_SECTION m_csLoadCreate;
// 4J - size of cache is defined by size of one side - must be even
int XZSIZE;
int XZOFFSET;
bool* hasData;
Level *level;
Level* level;
public:
MultiPlayerChunkCache(Level *level);
~MultiPlayerChunkCache();
MultiPlayerChunkCache(Level* level);
~MultiPlayerChunkCache();
virtual bool hasChunk(int x, int z);
virtual bool reallyHasChunk(int x, int z);
virtual bool reallyHasChunk(int x, int z);
virtual void drop(int x, int z);
virtual LevelChunk *create(int x, int z);
virtual LevelChunk *getChunk(int x, int z);
virtual bool save(bool force, ProgressListener *progressListener);
virtual LevelChunk* create(int x, int z);
virtual LevelChunk* getChunk(int x, int z);
virtual bool save(bool force, ProgressListener* progressListener);
virtual bool tick();
virtual bool shouldSave();
virtual void postProcess(ChunkSource *parent, int x, int z);
virtual void postProcess(ChunkSource* parent, int x, int z);
virtual std::wstring gatherStats();
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
virtual void dataReceived(int x, int z); // 4J added
virtual std::vector<Biome::MobSpawnerData*>* getMobsAt(
MobCategory* mobCategory, int x, int y, int z);
virtual TilePos* findNearestMapFeature(Level* level,
const std::wstring& featureName,
int x, int y, int z);
virtual void dataReceived(int x, int z); // 4J added
virtual LevelChunk **getCache() { return cache; } // 4J added
virtual LevelChunk** getCache() { return cache; } // 4J added
};

View file

@ -19,112 +19,108 @@
// #include "PS3/Network/NetworkPlayerSony.h"
// #endif
Random *PendingConnection::random = new Random();
Random* PendingConnection::random = new Random();
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id)
{
// 4J - added initialisers
done = false;
PendingConnection::PendingConnection(MinecraftServer* server, Socket* socket,
const std::wstring& id) {
// 4J - added initialisers
done = false;
_tick = 0;
name = L"";
acceptedLogin = nullptr;
loginKey = L"";
loginKey = L"";
this->server = server;
connection = new Connection(socket, id, this);
connection->fakeLag = FAKE_LAG;
}
PendingConnection::~PendingConnection()
{
delete connection;
}
PendingConnection::~PendingConnection() { delete connection; }
void PendingConnection::tick()
{
if (acceptedLogin != NULL)
{
void PendingConnection::tick() {
if (acceptedLogin != NULL) {
this->handleAcceptedLogin(acceptedLogin);
acceptedLogin = nullptr;
}
if (_tick++ == MAX_TICKS_BEFORE_LOGIN)
{
if (_tick++ == MAX_TICKS_BEFORE_LOGIN) {
disconnect(DisconnectPacket::eDisconnect_LoginTooLong);
}
else
{
} else {
connection->tick();
}
}
void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
{
// try { // 4J - removed try/catch
// logger.info("Disconnecting " + getName() + ": " + reason);
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
app.DebugPrintf("Pending connection disconnect: %d\n", reason );
connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
connection->sendAndQuit();
done = true;
// } catch (Exception e) {
// e.printStackTrace();
// }
void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) {
// try { // 4J - removed try/catch
// logger.info("Disconnecting " + getName() + ": " + reason);
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n",
reason, _tick);
app.DebugPrintf("Pending connection disconnect: %d\n", reason);
connection->send(
std::shared_ptr<DisconnectPacket>(new DisconnectPacket(reason)));
connection->sendAndQuit();
done = true;
// } catch (Exception e) {
// e.printStackTrace();
// }
}
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet)
{
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
{
app.DebugPrintf("Netcode version is %d not equal to %d\n", packet->m_netcodeVersion, MINECRAFT_NET_VERSION);
if (packet->m_netcodeVersion > MINECRAFT_NET_VERSION)
{
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION) {
app.DebugPrintf("Netcode version is %d not equal to %d\n",
packet->m_netcodeVersion, MINECRAFT_NET_VERSION);
if (packet->m_netcodeVersion > MINECRAFT_NET_VERSION) {
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
}
else
{
} else {
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
}
return;
}
// printf("Server: handlePreLogin\n");
name = packet->loginKey; // 4J Stu - Change from the login packet as we know better on client end during the pre-login packet
sendPreLoginResponse();
// printf("Server: handlePreLogin\n");
name =
packet->loginKey; // 4J Stu - Change from the login packet as we know
// better on client end during the pre-login packet
sendPreLoginResponse();
}
void PendingConnection::sendPreLoginResponse()
{
// 4J Stu - Calculate the players with UGC privileges set
PlayerUID *ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
std::uint8_t ugcXuidCount = 0;
std::uint8_t hostIndex = 0;
std::uint8_t ugcFriendsOnlyBits = 0;
char szUniqueMapName[14];
void PendingConnection::sendPreLoginResponse() {
// 4J Stu - Calculate the players with UGC privileges set
PlayerUID* ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
std::uint8_t ugcXuidCount = 0;
std::uint8_t hostIndex = 0;
std::uint8_t ugcFriendsOnlyBits = 0;
char szUniqueMapName[14];
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
{
std::shared_ptr<ServerPlayer> player = *it;
// If the offline Xuid is invalid but the online one is not then that's guest which we should ignore
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
// PADDY - this is failing when a local player with chat restrictions joins an online game
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
for (AUTO_VAR(it, playerList->players.begin());
it != playerList->players.end(); ++it) {
std::shared_ptr<ServerPlayer> player = *it;
// If the offline Xuid is invalid but the online one is not then that's
// guest which we should ignore If the online Xuid is invalid but the
// offline one is not then we are definitely an offline game so dont
// care about UGC
if( player != NULL && player->connection->m_offlineXUID != INVALID_XUID && player->connection->m_onlineXUID != INVALID_XUID )
{
if( player->connection->m_friendsOnlyUGC )
{
ugcFriendsOnlyBits |= (1<<ugcXuidCount);
}
// Need to use the online XUID otherwise friend checks will fail on the client
ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID;
// PADDY - this is failing when a local player with chat restrictions
// joins an online game
if( player->connection->getNetworkPlayer() != NULL && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount;
if (player != NULL &&
player->connection->m_offlineXUID != INVALID_XUID &&
player->connection->m_onlineXUID != INVALID_XUID) {
if (player->connection->m_friendsOnlyUGC) {
ugcFriendsOnlyBits |= (1 << ugcXuidCount);
}
// Need to use the online XUID otherwise friend checks will fail on
// the client
ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID;
++ugcXuidCount;
}
}
if (player->connection->getNetworkPlayer() != NULL &&
player->connection->getNetworkPlayer()->IsHost())
hostIndex = ugcXuidCount;
++ugcXuidCount;
}
}
#if 0
if (false)// server->onlineMode) // 4J - removed
@ -134,47 +130,44 @@ void PendingConnection::sendPreLoginResponse()
}
else
#endif
{
connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
{
connection->send(std::shared_ptr<PreLoginPacket>(
new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits,
server->m_ugcPlayersVersion, szUniqueMapName,
app.GetGameHostOption(eGameHostOption_All),
hostIndex, server->m_texturePackId)));
}
}
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
{
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
//name = packet->userName;
if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION)
{
app.DebugPrintf("Client version is %d not equal to %d\n", packet->clientVersion, SharedConstants::NETWORK_PROTOCOL_VERSION);
if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION)
{
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n",
packet->clientVersion);
// name = packet->userName;
if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION) {
app.DebugPrintf("Client version is %d not equal to %d\n",
packet->clientVersion,
SharedConstants::NETWORK_PROTOCOL_VERSION);
if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION) {
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
}
else
{
} else {
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
}
return;
}
//if (true)// 4J removed !server->onlineMode)
bool sentDisconnect = false;
// if (true)// 4J removed !server->onlineMode)
bool sentDisconnect = false;
if( sentDisconnect )
{
// Do nothing
}
else if( server->getPlayers()->isXuidBanned( packet->m_onlineXuid ) )
{
disconnect(DisconnectPacket::eDisconnect_Banned);
}
else
{
if (sentDisconnect) {
// Do nothing
} else if (server->getPlayers()->isXuidBanned(packet->m_onlineXuid)) {
disconnect(DisconnectPacket::eDisconnect_Banned);
} else {
handleAcceptedLogin(packet);
}
//else
{
//4J - removed
// else
{
// 4J - removed
#if 0
new Thread() {
public void run() {
@ -197,75 +190,71 @@ void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
}.start();
#endif
}
}
void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
{
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
{
// Send the pre-login packet again with the new list of players
sendPreLoginResponse();
return;
}
void PendingConnection::handleAcceptedLogin(
std::shared_ptr<LoginPacket> packet) {
if (packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion) {
// Send the pre-login packet again with the new list of players
sendPreLoginResponse();
return;
}
// Guests use the online xuid, everyone else uses the offline one
PlayerUID playerXuid = packet->m_offlineXuid;
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
// Guests use the online xuid, everyone else uses the offline one
PlayerUID playerXuid = packet->m_offlineXuid;
if (playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
std::shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
if (playerEntity != NULL)
{
std::shared_ptr<ServerPlayer> playerEntity =
server->getPlayers()->getPlayerForLogin(this, name, playerXuid,
packet->m_onlineXuid);
if (playerEntity != NULL) {
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
connection = NULL; // We've moved responsibility for this over to the new PlayerConnection, NULL so we don't delete our reference to it here in our dtor
connection = NULL; // We've moved responsibility for this over to the
// new PlayerConnection, NULL so we don't delete our
// reference to it here in our dtor
}
done = true;
}
void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects)
{
// logger.info(getName() + " lost connection");
void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
void* reasonObjects) {
// logger.info(getName() + " lost connection");
done = true;
}
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
{
//try {
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
//connection->send(new DisconnectPacket(message));
connection->send(std::shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
connection->sendAndQuit();
server->connection->removeSpamProtection(connection->getSocket());
done = true;
//} catch (Exception e) {
// e.printStackTrace();
//}
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet) {
// try {
// String message = server->motd + "§" + server->players->getPlayerCount() +
// "§" + server->players->getMaxPlayers(); connection->send(new
// DisconnectPacket(message));
connection->send(std::shared_ptr<DisconnectPacket>(
new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull)));
connection->sendAndQuit();
server->connection->removeSpamProtection(connection->getSocket());
done = true;
//} catch (Exception e) {
// e.printStackTrace();
//}
}
void PendingConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
{
// Ignore
void PendingConnection::handleKeepAlive(
std::shared_ptr<KeepAlivePacket> packet) {
// Ignore
}
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
{
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet) {
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
}
void PendingConnection::send(std::shared_ptr<Packet> packet)
{
connection->send(packet);
void PendingConnection::send(std::shared_ptr<Packet> packet) {
connection->send(packet);
}
std::wstring PendingConnection::getName()
{
return L"Unimplemented";
// if (name != null) return name + " [" + connection.getRemoteAddress().toString() + "]";
// return connection.getRemoteAddress().toString();
std::wstring PendingConnection::getName() {
return L"Unimplemented";
// if (name != null) return name + " [" +
// connection.getRemoteAddress().toString() + "]"; return
// connection.getRemoteAddress().toString();
}
bool PendingConnection::isServerPacketListener()
{
return true;
}
bool PendingConnection::isServerPacketListener() { return true; }

View file

@ -6,43 +6,47 @@ class LoginPacket;
class Connection;
class Random;
class PendingConnection : public PacketListener
{
class PendingConnection : public PacketListener {
private:
static const int FAKE_LAG = 0;
static const int MAX_TICKS_BEFORE_LOGIN = 20 * 30 * 10; // 10 minutes instead of 20 sec for Linux theres just no login yet
static const int FAKE_LAG = 0;
static const int MAX_TICKS_BEFORE_LOGIN =
20 * 30 *
10; // 10 minutes instead of 20 sec for Linux theres just no login yet
// public static Logger logger = Logger.getLogger("Minecraft");
static Random *random;
// public static Logger logger = Logger.getLogger("Minecraft");
static Random* random;
public:
Connection *connection;
Connection* connection;
public:
bool done;
bool done;
private:
MinecraftServer *server;
MinecraftServer* server;
int _tick;
std::wstring name;
std::shared_ptr<LoginPacket> acceptedLogin;
std::wstring loginKey;
public:
PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id);
~PendingConnection();
PendingConnection(MinecraftServer* server, Socket* socket,
const std::wstring& id);
~PendingConnection();
void tick();
void disconnect(DisconnectPacket::eDisconnectReason reason);
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
void* reasonObjects);
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
void send(std::shared_ptr<Packet> packet);
std::wstring getName();
virtual bool isServerPacketListener();
private:
void sendPreLoginResponse();
void sendPreLoginResponse();
};

File diff suppressed because it is too large Load diff

View file

@ -7,35 +7,34 @@ class MinecraftServer;
class Packet;
class TileEntity;
class PlayerChunkMap
{
class PlayerChunkMap {
public:
#ifdef _LARGE_WORLDS
static const int MAX_VIEW_DISTANCE = 30;
static const int MAX_VIEW_DISTANCE = 30;
#else
static const int MAX_VIEW_DISTANCE = 15;
static const int MAX_VIEW_DISTANCE = 15;
#endif
static const int MIN_VIEW_DISTANCE = 3;
static const int MAX_CHANGES_BEFORE_RESEND = 10;
static const int MIN_TICKS_BETWEEN_REGION_UPDATE = 10;
static const int MIN_VIEW_DISTANCE = 3;
static const int MAX_CHANGES_BEFORE_RESEND = 10;
static const int MIN_TICKS_BETWEEN_REGION_UPDATE = 10;
// 4J - added
class PlayerChunkAddRequest
{
public:
int x,z;
std::shared_ptr<ServerPlayer> player;
PlayerChunkAddRequest(int x, int z, std::shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
};
// 4J - added
class PlayerChunkAddRequest {
public:
int x, z;
std::shared_ptr<ServerPlayer> player;
PlayerChunkAddRequest(int x, int z,
std::shared_ptr<ServerPlayer> player)
: x(x), z(z), player(player) {}
};
class PlayerChunk
{
friend class PlayerChunkMap;
private:
PlayerChunkMap *parent; // 4J added
std::vector<std::shared_ptr<ServerPlayer> > players;
//int x, z;
class PlayerChunk {
friend class PlayerChunkMap;
private:
PlayerChunkMap* parent; // 4J added
std::vector<std::shared_ptr<ServerPlayer> > players;
// int x, z;
ChunkPos pos;
shortArray changedTiles;
@ -43,63 +42,73 @@ public:
int xChangeMin, xChangeMax;
int yChangeMin, yChangeMax;
int zChangeMin, zChangeMax;
int ticksToNextRegionUpdate; // 4J added
bool prioritised; // 4J added
int ticksToNextRegionUpdate; // 4J added
bool prioritised; // 4J added
public:
PlayerChunk(int x, int z, PlayerChunkMap *pcm);
~PlayerChunk();
public:
PlayerChunk(int x, int z, PlayerChunkMap* pcm);
~PlayerChunk();
// 4J Added sendPacket param so we can aggregate the initial send into one much smaller packet
// 4J Added sendPacket param so we can aggregate the initial send into
// one much smaller packet
void add(std::shared_ptr<ServerPlayer> player, bool sendPacket = true);
void remove(std::shared_ptr<ServerPlayer> player);
void tileChanged(int x, int y, int z);
void prioritiseTileChanges(); // 4J added
void prioritiseTileChanges(); // 4J added
void broadcast(std::shared_ptr<Packet> packet);
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
bool broadcastChanges(bool allowRegionUpdate); // 4J - added parm
private:
void broadcast(std::shared_ptr<TileEntity> te);
private:
void broadcast(std::shared_ptr<TileEntity> te);
};
public:
std::vector<std::shared_ptr<ServerPlayer> > players;
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
std::vector<std::shared_ptr<ServerPlayer> > players;
void flagEntitiesToBeRemoved(unsigned int* flags,
bool* removedFound); // 4J added
private:
std::unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
std::vector<PlayerChunk *> changedChunks;
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
std::unordered_map<__int64, PlayerChunk*, LongKeyHash, LongKeyEq>
chunks; // 4J - was LongHashMap
std::vector<PlayerChunk*> changedChunks;
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
ServerLevel *level;
ServerLevel* level;
int radius;
int dimension;
int dimension;
public:
PlayerChunkMap(ServerLevel *level, int dimension, int radius);
~PlayerChunkMap();
ServerLevel *getLevel();
PlayerChunkMap(ServerLevel* level, int dimension, int radius);
~PlayerChunkMap();
ServerLevel* getLevel();
void tick();
bool hasChunk(int x, int z);
bool hasChunk(int x, int z);
private:
PlayerChunk *getChunk(int x, int z, bool create);
void getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
void getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
PlayerChunk* getChunk(int x, int z, bool create);
void getChunkAndAddPlayer(
int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
void getChunkAndRemovePlayer(
int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
public:
void broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z);
void broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y,
int z);
void tileChanged(int x, int y, int z);
bool isTrackingTile(int x, int y, int z); // 4J added
void prioritiseTileChanges(int x, int y, int z); // 4J added
bool isTrackingTile(int x, int y, int z); // 4J added
void prioritiseTileChanges(int x, int y, int z); // 4J added
void add(std::shared_ptr<ServerPlayer> player);
void remove(std::shared_ptr<ServerPlayer> player);
private:
bool chunkInRange(int x, int z, int xc, int zc);
public:
void move(std::shared_ptr<ServerPlayer> player);
int getMaxRange();
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk);
static int convertChunkRangeToBlock(int radius);
// AP added for Vita
void setRadius(int newRadius);
private:
bool chunkInRange(int x, int z, int xc, int zc);
public:
void move(std::shared_ptr<ServerPlayer> player);
int getMaxRange();
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk,
int zChunk);
static int convertChunkRangeToBlock(int radius);
// AP added for Vita
void setRadius(int newRadius);
};

File diff suppressed because it is too large Load diff

View file

@ -8,132 +8,152 @@ class Connection;
class ServerPlayer;
class INetworkPlayer;
class PlayerConnection : public PacketListener, public ConsoleInputSource
{
// public static Logger logger = Logger.getLogger("Minecraft");
class PlayerConnection : public PacketListener, public ConsoleInputSource {
// public static Logger logger = Logger.getLogger("Minecraft");
public:
Connection *connection;
Connection* connection;
bool done;
CRITICAL_SECTION done_cs;
CRITICAL_SECTION done_cs;
// 4J Stu - Added this so that we can manage UGC privileges
PlayerUID m_offlineXUID, m_onlineXUID;
bool m_friendsOnlyUGC;
// 4J Stu - Added this so that we can manage UGC privileges
PlayerUID m_offlineXUID, m_onlineXUID;
bool m_friendsOnlyUGC;
private:
MinecraftServer *server;
MinecraftServer* server;
std::shared_ptr<ServerPlayer> player;
int tickCount;
int aboveGroundTickCount;
bool didTick;
int lastKeepAliveId;
__int64 lastKeepAliveTime;
static Random random;
__int64 lastKeepAliveTick;
int chatSpamTickCount;
int dropSpamTickCount;
int lastKeepAliveId;
__int64 lastKeepAliveTime;
static Random random;
__int64 lastKeepAliveTick;
int chatSpamTickCount;
int dropSpamTickCount;
bool m_bHasClientTickedOnce;
bool m_bHasClientTickedOnce;
public:
PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player);
~PlayerConnection();
PlayerConnection(MinecraftServer* server, Connection* connection,
std::shared_ptr<ServerPlayer> player);
~PlayerConnection();
void tick();
void disconnect(DisconnectPacket::eDisconnectReason reason);
private:
double xLastOk, yLastOk, zLastOk;
double xLastOk, yLastOk, zLastOk;
bool synched;
public:
virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet);
virtual void handlePlayerInput(std::shared_ptr<PlayerInputPacket> packet);
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
void teleport(double x, double y, double z, float yRot, float xRot, bool sendPacket = true); // 4J Added sendPacket param
void teleport(double x, double y, double z, float yRot, float xRot,
bool sendPacket = true); // 4J Added sendPacket param
virtual void handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet);
virtual void handleUseItem(std::shared_ptr<UseItemPacket> packet);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
void* reasonObjects);
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
void send(std::shared_ptr<Packet> packet);
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
virtual void handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet);
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
virtual void handleSetCarriedItem(
std::shared_ptr<SetCarriedItemPacket> packet);
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
private:
void handleCommand(const std::wstring& message);
void handleCommand(const std::wstring& message);
public:
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet);
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
virtual void handlePlayerCommand(
std::shared_ptr<PlayerCommandPacket> packet);
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
int countDelayedPackets();
virtual void info(const std::wstring& string);
virtual void warn(const std::wstring& string);
virtual std::wstring getConsoleName();
virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
bool canHandleAsyncPackets();
virtual void handleClientCommand(std::shared_ptr<ClientCommandPacket> packet);
bool canHandleAsyncPackets();
virtual void handleClientCommand(
std::shared_ptr<ClientCommandPacket> packet);
virtual void handleRespawn(std::shared_ptr<RespawnPacket> packet);
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
virtual void handleContainerClose(
std::shared_ptr<ContainerClosePacket> packet);
private:
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
public:
// 4J Stu - Handlers only valid in debug mode
#ifndef _CONTENT_PACKAGE
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
// 4J Stu - Handlers only valid in debug mode
#ifndef _CONTENT_PACKAGE
virtual void handleContainerSetSlot(
std::shared_ptr<ContainerSetSlotPacket> packet);
#endif
virtual void handleContainerClick(std::shared_ptr<ContainerClickPacket> packet);
virtual void handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet);
virtual void handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> packet);
virtual void handleContainerClick(
std::shared_ptr<ContainerClickPacket> packet);
virtual void handleContainerButtonClick(
std::shared_ptr<ContainerButtonClickPacket> packet);
virtual void handleSetCreativeModeSlot(
std::shared_ptr<SetCreativeModeSlotPacket> packet);
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
virtual void handlePlayerInfo(
std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
virtual bool isServerPacketListener();
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
virtual void handlePlayerAbilities(
std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
virtual void handleCustomPayload(
std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
// 4J Added
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
// 4J Added
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
virtual void handleTextureAndGeometry(
std::shared_ptr<TextureAndGeometryPacket> packet);
virtual void handleTextureChange(
std::shared_ptr<TextureChangePacket> packet);
virtual void handleTextureAndGeometryChange(
std::shared_ptr<TextureAndGeometryChangePacket> packet);
virtual void handleServerSettingsChanged(
std::shared_ptr<ServerSettingsChangedPacket> packet);
virtual void handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
INetworkPlayer *getNetworkPlayer();
bool isLocal();
bool isGuest();
INetworkPlayer* getNetworkPlayer();
bool isLocal();
bool isGuest();
// 4J Added as we need to set this from outside sometimes
void setPlayer(std::shared_ptr<ServerPlayer> player) { this->player = player; }
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
// 4J Added as we need to set this from outside sometimes
void setPlayer(std::shared_ptr<ServerPlayer> player) {
this->player = player;
}
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
// 4J Added to signal a disconnect from another thread
void closeOnTick() { m_bCloseOnTick = true; }
// 4J Added to signal a disconnect from another thread
void closeOnTick() { m_bCloseOnTick = true; }
// 4J Added so that we can send on textures that get received after this connection requested them
void handleTextureReceived(const std::wstring &textureName);
void handleTextureAndGeometryReceived(const std::wstring &textureName);
// 4J Added so that we can send on textures that get received after this
// connection requested them
void handleTextureReceived(const std::wstring& textureName);
void handleTextureAndGeometryReceived(const std::wstring& textureName);
void setShowOnMaps(bool bVal);
void setShowOnMaps(bool bVal);
void setWasKicked() { m_bWasKicked = true; }
bool getWasKicked() { return m_bWasKicked; }
void setWasKicked() { m_bWasKicked = true; }
bool getWasKicked() { return m_bWasKicked; }
// 4J Added
bool hasClientTickedOnce() { return m_bHasClientTickedOnce; }
// 4J Added
bool hasClientTickedOnce() { return m_bHasClientTickedOnce; }
private:
bool m_bCloseOnTick;
std::vector<std::wstring> m_texturesRequested;
bool m_bCloseOnTick;
std::vector<std::wstring> m_texturesRequested;
bool m_bWasKicked;
bool m_bWasKicked;
};

View file

@ -1,15 +1,12 @@
#pragma once
class PlayerInfo
{
class PlayerInfo {
public:
std::wstring name;
int latency;
std::wstring name;
int latency;
PlayerInfo(const std::wstring &name)
{
this->name = name;
latency = 0;
}
PlayerInfo(const std::wstring& name) {
this->name = name;
latency = 0;
}
};

File diff suppressed because it is too large Load diff

View file

@ -15,114 +15,136 @@ class ProgressListener;
class GameType;
class LoginPacket;
class PlayerList
{
class PlayerList {
private:
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
// public static Logger logger = Logger.getLogger("Minecraft");
static const int SEND_PLAYER_INFO_INTERVAL =
20 * 10; // 4J - brought forward from 1.2.3
// public static Logger logger = Logger.getLogger("Minecraft");
public:
std::vector<std::shared_ptr<ServerPlayer> > players;
std::vector<std::shared_ptr<ServerPlayer> > players;
private:
MinecraftServer *server;
MinecraftServer* server;
unsigned int maxPlayers;
// 4J Added
std::vector<PlayerUID> m_bannedXuids;
std::deque<std::uint8_t> m_smallIdsToKick;
CRITICAL_SECTION m_kickPlayersCS;
std::deque<std::uint8_t> m_smallIdsToClose;
CRITICAL_SECTION m_closePlayersCS;
/* 4J - removed
Set<String> bans = new HashSet<String>();
Set<String> ipBans = new HashSet<String>();
Set<String> ops = new HashSet<String>();
Set<String> whitelist = new HashSet<String>();
File banFile, ipBanFile, opFile, whiteListFile;
*/
PlayerIO *playerIo;
// 4J Added
std::vector<PlayerUID> m_bannedXuids;
std::deque<std::uint8_t> m_smallIdsToKick;
CRITICAL_SECTION m_kickPlayersCS;
std::deque<std::uint8_t> m_smallIdsToClose;
CRITICAL_SECTION m_closePlayersCS;
/* 4J - removed
Set<String> bans = new HashSet<String>();
Set<String> ipBans = new HashSet<String>();
Set<String> ops = new HashSet<String>();
Set<String> whitelist = new HashSet<String>();
File banFile, ipBanFile, opFile, whiteListFile;
*/
PlayerIO* playerIo;
bool doWhiteList;
GameType *overrideGameMode;
bool allowCheatsForAllPlayers;
int viewDistance;
GameType* overrideGameMode;
bool allowCheatsForAllPlayers;
int viewDistance;
int sendAllPlayerInfoIn;
int sendAllPlayerInfoIn;
// 4J Added to maintain which players in which dimensions can receive all
// packet types
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
// 4J Added to maintain which players in which dimensions can receive all packet types
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
private:
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> currentPlayer);
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(
std::shared_ptr<ServerPlayer> currentPlayer);
public:
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
bool usePlayerDimension = true,
int dimension = 0);
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
public:
PlayerList(MinecraftServer *server);
~PlayerList();
void placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet);
PlayerList(MinecraftServer* server);
~PlayerList();
void placeNewPlayer(Connection* connection,
std::shared_ptr<ServerPlayer> player,
std::shared_ptr<LoginPacket> packet);
void setLevel(ServerLevelArray levels);
void changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from);
void changeDimension(std::shared_ptr<ServerPlayer> player,
ServerLevel* from);
int getMaxRange();
bool load(std::shared_ptr<ServerPlayer> player); // 4J Changed return val to bool to check if new player or loaded player
bool load(std::shared_ptr<ServerPlayer>
player); // 4J Changed return val to bool to check if new
// player or loaded player
protected:
void save(std::shared_ptr<ServerPlayer> player);
void save(std::shared_ptr<ServerPlayer> player);
public:
void validatePlayerSpawnPosition(std::shared_ptr<ServerPlayer> player); // 4J Added
void validatePlayerSpawnPosition(
std::shared_ptr<ServerPlayer> player); // 4J Added
void add(std::shared_ptr<ServerPlayer> player);
void move(std::shared_ptr<ServerPlayer> player);
void remove(std::shared_ptr<ServerPlayer> player);
std::shared_ptr<ServerPlayer> getPlayerForLogin(PendingConnection *pendingConnection, const std::wstring& userName, PlayerUID xuid, PlayerUID OnlineXuid);
std::shared_ptr<ServerPlayer> respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
void toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension);
std::shared_ptr<ServerPlayer> getPlayerForLogin(
PendingConnection* pendingConnection, const std::wstring& userName,
PlayerUID xuid, PlayerUID OnlineXuid);
std::shared_ptr<ServerPlayer> respawn(
std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension,
bool keepAllPlayerData);
void toggleDimension(std::shared_ptr<ServerPlayer> player,
int targetDimension);
void tick();
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
bool isTrackingTile(int x, int y, int z, int dimension); // 4J added
void prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
void broadcastAll(std::shared_ptr<Packet> packet);
void broadcastAll(std::shared_ptr<Packet> packet, int dimension);
std::wstring getPlayerNames();
public:
bool isWhiteListed(const std::wstring& name);
bool isWhiteListed(const std::wstring& name);
bool isOp(const std::wstring& name);
bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
bool isOp(std::shared_ptr<ServerPlayer> player); // 4J Added
std::shared_ptr<ServerPlayer> getPlayer(const std::wstring& name);
std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
std::shared_ptr<ServerPlayer> getPlayer(PlayerUID uid);
void sendMessage(const std::wstring& name, const std::wstring& message);
void broadcast(double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
void broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
void broadcast(double x, double y, double z, double range, int dimension,
std::shared_ptr<Packet> packet);
void broadcast(std::shared_ptr<Player> except, double x, double y, double z,
double range, int dimension, std::shared_ptr<Packet> packet);
void broadcastToAllOps(const std::wstring& message);
bool sendTo(const std::wstring& name, std::shared_ptr<Packet> packet);
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps
// param
void saveAll(ProgressListener* progressListener,
bool bDeleteGuestMaps = false);
void whiteList(const std::wstring& playerName);
void blackList(const std::wstring& playerName);
// Set<String> getWhiteList(); / 4J removed
// Set<String> getWhiteList(); / 4J removed
void reloadWhitelist();
void sendLevelInfo(std::shared_ptr<ServerPlayer> player, ServerLevel *level);
void sendLevelInfo(std::shared_ptr<ServerPlayer> player,
ServerLevel* level);
void sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player);
int getPlayerCount();
int getPlayerCount(ServerLevel *level); // 4J Added
int getMaxPlayers();
MinecraftServer *getServer();
int getViewDistance();
void setOverrideGameMode(GameType *gameMode);
int getPlayerCount();
int getPlayerCount(ServerLevel* level); // 4J Added
int getMaxPlayers();
MinecraftServer* getServer();
int getViewDistance();
void setOverrideGameMode(GameType* gameMode);
private:
void updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer, std::shared_ptr<ServerPlayer> oldPlayer, Level *level);
void updatePlayerGameMode(std::shared_ptr<ServerPlayer> newPlayer,
std::shared_ptr<ServerPlayer> oldPlayer,
Level* level);
public:
void setAllowCheatsForAllPlayers(bool allowCommands);
void setAllowCheatsForAllPlayers(bool allowCommands);
// 4J Added
void kickPlayerByShortId(std::uint8_t networkSmallId);
void closePlayerConnectionBySmallId(std::uint8_t networkSmallId);
bool isXuidBanned(PlayerUID xuid);
// AP added for Vita so the range can be increased once the level starts
void setViewDistance(int newViewDistance);
// 4J Added
void kickPlayerByShortId(std::uint8_t networkSmallId);
void closePlayerConnectionBySmallId(std::uint8_t networkSmallId);
bool isXuidBanned(PlayerUID xuid);
// AP added for Vita so the range can be increased once the level starts
void setViewDistance(int newViewDistance);
};

File diff suppressed because it is too large Load diff

View file

@ -8,94 +8,99 @@
class ServerLevel;
class ServerChunkCache : public ChunkSource
{
class ServerChunkCache : public ChunkSource {
private:
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
private:
LevelChunk* emptyChunk;
ChunkSource* source;
ChunkStorage* storage;
public:
bool autoCreate;
private:
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
private:
LevelChunk *emptyChunk;
ChunkSource *source;
ChunkStorage *storage;
public:
bool autoCreate;
private:
LevelChunk **cache;
std::vector<LevelChunk *> m_loadedChunkList;
ServerLevel *level;
LevelChunk** cache;
std::vector<LevelChunk*> m_loadedChunkList;
ServerLevel* level;
#ifdef _LARGE_WORLDS
std::deque<LevelChunk *> m_toDrop;
LevelChunk **m_unloadedCache;
std::deque<LevelChunk*> m_toDrop;
LevelChunk** m_unloadedCache;
#endif
// 4J - added for multithreaded support
CRITICAL_SECTION m_csLoadCreate;
// 4J - size of cache is defined by size of one side - must be even
int XZSIZE;
int XZOFFSET;
// 4J - added for multithreaded support
CRITICAL_SECTION m_csLoadCreate;
// 4J - size of cache is defined by size of one side - must be even
int XZSIZE;
int XZOFFSET;
public:
ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
virtual ~ServerChunkCache();
ServerChunkCache(ServerLevel* level, ChunkStorage* storage,
ChunkSource* source);
virtual ~ServerChunkCache();
virtual bool hasChunk(int x, int z);
std::vector<LevelChunk *> *getLoadedChunkList();
std::vector<LevelChunk*>* getLoadedChunkList();
void drop(int x, int z);
void dropAll();
virtual LevelChunk *create(int x, int z);
LevelChunk *create(int x, int z, bool asyncPostProcess ); // 4J added
virtual LevelChunk *getChunk(int x, int z);
#ifdef _LARGE_WORLDS
LevelChunk *getChunkLoadedOrUnloaded(int x, int z); // 4J added
void dropAll();
virtual LevelChunk* create(int x, int z);
LevelChunk* create(int x, int z, bool asyncPostProcess); // 4J added
virtual LevelChunk* getChunk(int x, int z);
#ifdef _LARGE_WORLDS
LevelChunk* getChunkLoadedOrUnloaded(int x, int z); // 4J added
#endif
virtual LevelChunk **getCache() { return cache; } // 4J added
virtual LevelChunk** getCache() { return cache; } // 4J added
// 4J-JEV Added; Remove chunk from the toDrop queue.
#ifdef _LARGE_WORLDS
void dontDrop(int x, int z);
// 4J-JEV Added; Remove chunk from the toDrop queue.
#ifdef _LARGE_WORLDS
void dontDrop(int x, int z);
#endif
private:
LevelChunk *load(int x, int z);
void saveEntities(LevelChunk *levelChunk);
void save(LevelChunk *levelChunk);
LevelChunk* load(int x, int z);
void saveEntities(LevelChunk* levelChunk);
void save(LevelChunk* levelChunk);
void updatePostProcessFlag(short flag, int x, int z, int xo, int zo, LevelChunk *lc); // 4J added
void updatePostProcessFlags(int x, int z); // 4J added
void flagPostProcessComplete(short flag, int x, int z); // 4J added
void updatePostProcessFlag(short flag, int x, int z, int xo, int zo,
LevelChunk* lc); // 4J added
void updatePostProcessFlags(int x, int z); // 4J added
void flagPostProcessComplete(short flag, int x, int z); // 4J added
public:
virtual void postProcess(ChunkSource *parent, int x, int z);
virtual void postProcess(ChunkSource* parent, int x, int z);
private:
#ifdef _LARGE_WORLDS
static const int MAX_SAVES = 20;
static const int MAX_SAVES = 20;
#else
// 4J Stu - Was 24, but lowering it drastically so that we can trickle save chunks
static const int MAX_SAVES = 1;
// 4J Stu - Was 24, but lowering it drastically so that we can trickle save
// chunks
static const int MAX_SAVES = 1;
#endif
public:
virtual bool saveAllEntities();
virtual bool save(bool force, ProgressListener *progressListener);
virtual bool saveAllEntities();
virtual bool save(bool force, ProgressListener* progressListener);
virtual bool tick();
virtual bool shouldSave();
virtual std::wstring gatherStats();
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
virtual std::vector<Biome::MobSpawnerData*>* getMobsAt(
MobCategory* mobCategory, int x, int y, int z);
virtual TilePos* findNearestMapFeature(Level* level,
const std::wstring& featureName,
int x, int y, int z);
private:
typedef struct _SaveThreadData
{
ServerChunkCache *cache;
LevelChunk *chunkToSave;
bool saveEntities;
bool useSharedThreadStorage;
C4JThread::Event *notificationEvent;
C4JThread::Event *wakeEvent; // This is a handle to the one fired by the producer thread
} SaveThreadData;
typedef struct _SaveThreadData {
ServerChunkCache* cache;
LevelChunk* chunkToSave;
bool saveEntities;
bool useSharedThreadStorage;
C4JThread::Event* notificationEvent;
C4JThread::Event* wakeEvent; // This is a handle to the one fired by
// the producer thread
} SaveThreadData;
public:
static int runSaveThreadProc(void *lpParam);
static int runSaveThreadProc(void* lpParam);
};

View file

@ -7,69 +7,72 @@
#include "../Commands/TeleportCommand.h"
#include "ServerCommandDispatcher.h"
ServerCommandDispatcher::ServerCommandDispatcher()
{
addCommand(new TimeCommand());
addCommand(new GameModeCommand());
addCommand(new DefaultGameModeCommand());
addCommand(new KillCommand());
addCommand(new ToggleDownfallCommand());
addCommand(new ExperienceCommand());
addCommand(new TeleportCommand());
addCommand(new GiveItemCommand());
addCommand(new EnchantItemCommand());
//addCommand(new EmoteCommand());
//addCommand(new ShowSeedCommand());
//addCommand(new HelpCommand());
//addCommand(new DebugCommand());
//addCommand(new MessageCommand());
ServerCommandDispatcher::ServerCommandDispatcher() {
addCommand(new TimeCommand());
addCommand(new GameModeCommand());
addCommand(new DefaultGameModeCommand());
addCommand(new KillCommand());
addCommand(new ToggleDownfallCommand());
addCommand(new ExperienceCommand());
addCommand(new TeleportCommand());
addCommand(new GiveItemCommand());
addCommand(new EnchantItemCommand());
// addCommand(new EmoteCommand());
// addCommand(new ShowSeedCommand());
// addCommand(new HelpCommand());
// addCommand(new DebugCommand());
// addCommand(new MessageCommand());
//if (MinecraftServer::getInstance()->isDedicatedServer())
//{
// addCommand(new OpCommand());
// addCommand(new DeOpCommand());
// addCommand(new StopCommand());
// addCommand(new SaveAllCommand());
// addCommand(new SaveOffCommand());
// addCommand(new SaveOnCommand());
// addCommand(new BanIpCommand());
// addCommand(new PardonIpCommand());
// addCommand(new BanPlayerCommand());
// addCommand(new ListBansCommand());
// addCommand(new PardonPlayerCommand());
// addCommand(new KickCommand());
// addCommand(new ListPlayersCommand());
// addCommand(new BroadcastCommand());
// addCommand(new WhitelistCommand());
//}
//else
//{
// addCommand(new PublishLocalServerCommand());
//}
// if (MinecraftServer::getInstance()->isDedicatedServer())
//{
// addCommand(new OpCommand());
// addCommand(new DeOpCommand());
// addCommand(new StopCommand());
// addCommand(new SaveAllCommand());
// addCommand(new SaveOffCommand());
// addCommand(new SaveOnCommand());
// addCommand(new BanIpCommand());
// addCommand(new PardonIpCommand());
// addCommand(new BanPlayerCommand());
// addCommand(new ListBansCommand());
// addCommand(new PardonPlayerCommand());
// addCommand(new KickCommand());
// addCommand(new ListPlayersCommand());
// addCommand(new BroadcastCommand());
// addCommand(new WhitelistCommand());
// }
// else
//{
// addCommand(new PublishLocalServerCommand());
// }
// addCommand(new ServerTempDebugCommand());
// addCommand(new ServerTempDebugCommand());
Command::setLogger(this);
Command::setLogger(this);
}
void ServerCommandDispatcher::logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message, int customData, const std::wstring& additionalMessage)
{
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
//for (Player player : MinecraftServer.getInstance().getPlayers().players)
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
{
std::shared_ptr<ServerPlayer> player = *it;
if (player != source && playerList->isOp(player))
{
// TODO: Change chat packet to be able to send more bits of data
// 4J Stu - Take this out until we can add the name of the player performing the action. Also if the target is a mod then maybe don't need the message?
//player->sendMessage(message, messageType, customData, additionalMessage);
//player->sendMessage("\u00A77\u00A7o[" + source.getName() + ": " + player.localize(message, args) + "]");
}
}
void ServerCommandDispatcher::logAdminCommand(
std::shared_ptr<CommandSender> source, int type,
ChatPacket::EChatPacketMessage messageType, const std::wstring& message,
int customData, const std::wstring& additionalMessage) {
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
// for (Player player : MinecraftServer.getInstance().getPlayers().players)
for (AUTO_VAR(it, playerList->players.begin());
it != playerList->players.end(); ++it) {
std::shared_ptr<ServerPlayer> player = *it;
if (player != source && playerList->isOp(player)) {
// TODO: Change chat packet to be able to send more bits of data
// 4J Stu - Take this out until we can add the name of the player
// performing the action. Also if the target is a mod then maybe
// don't need the message?
// player->sendMessage(message, messageType, customData,
// additionalMessage); player->sendMessage("\u00A77\u00A7o[" +
// source.getName() + ": " + player.localize(message, args) + "]");
}
}
if ((type & LOGTYPE_DONT_SHOW_TO_SELF) != LOGTYPE_DONT_SHOW_TO_SELF)
{
source->sendMessage(message, messageType, customData, additionalMessage);
}
if ((type & LOGTYPE_DONT_SHOW_TO_SELF) != LOGTYPE_DONT_SHOW_TO_SELF) {
source->sendMessage(message, messageType, customData,
additionalMessage);
}
}

View file

@ -3,9 +3,12 @@
#include "../../Minecraft.World/Commands/CommandDispatcher.h"
#include "../../Minecraft.World/Commands/AdminLogCommand.h"
class ServerCommandDispatcher : public CommandDispatcher, public AdminLogCommand
{
class ServerCommandDispatcher : public CommandDispatcher,
public AdminLogCommand {
public:
ServerCommandDispatcher();
void logAdminCommand(std::shared_ptr<CommandSender> source, int type, ChatPacket::EChatPacketMessage messageType, const std::wstring& message = L"", int customData = -1, const std::wstring& additionalMessage = L"");
ServerCommandDispatcher();
void logAdminCommand(std::shared_ptr<CommandSender> source, int type,
ChatPacket::EChatPacketMessage messageType,
const std::wstring& message = L"", int customData = -1,
const std::wstring& additionalMessage = L"");
};

View file

@ -9,196 +9,187 @@
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
#include "../Level/MultiPlayerLevel.h"
ServerConnection::ServerConnection(MinecraftServer *server)
{
// 4J - added initialiser
connectionCounter = 0;
InitializeCriticalSection(&pending_cs);
ServerConnection::ServerConnection(MinecraftServer* server) {
// 4J - added initialiser
connectionCounter = 0;
InitializeCriticalSection(&pending_cs);
this->server = server;
this->server = server;
}
ServerConnection::~ServerConnection()
{
DeleteCriticalSection(&pending_cs);
ServerConnection::~ServerConnection() { DeleteCriticalSection(&pending_cs); }
// 4J - added to handle incoming connections, to replace thread that original
// used to have
void ServerConnection::NewIncomingSocket(Socket* socket) {
std::shared_ptr<PendingConnection> unconnectedClient =
std::shared_ptr<PendingConnection>(new PendingConnection(
server, socket,
L"Connection #" + _toString<int>(connectionCounter++)));
handleConnection(unconnectedClient);
}
// 4J - added to handle incoming connections, to replace thread that original used to have
void ServerConnection::NewIncomingSocket(Socket *socket)
{
std::shared_ptr<PendingConnection> unconnectedClient = std::shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++)));
handleConnection(unconnectedClient);
void ServerConnection::addPlayerConnection(
std::shared_ptr<PlayerConnection> uc) {
players.push_back(uc);
}
void ServerConnection::addPlayerConnection(std::shared_ptr<PlayerConnection> uc)
{
players.push_back(uc);
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc) {
EnterCriticalSection(&pending_cs);
pending.push_back(uc);
LeaveCriticalSection(&pending_cs);
}
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc)
{
EnterCriticalSection(&pending_cs);
pending.push_back(uc);
LeaveCriticalSection(&pending_cs);
}
void ServerConnection::stop()
{
EnterCriticalSection(&pending_cs);
for (unsigned int i = 0; i < pending.size(); i++)
{
void ServerConnection::stop() {
EnterCriticalSection(&pending_cs);
for (unsigned int i = 0; i < pending.size(); i++) {
std::shared_ptr<PendingConnection> uc = pending[i];
uc->connection->close(DisconnectPacket::eDisconnect_Closed);
}
LeaveCriticalSection(&pending_cs);
LeaveCriticalSection(&pending_cs);
for (unsigned int i = 0; i < players.size(); i++)
{
for (unsigned int i = 0; i < players.size(); i++) {
std::shared_ptr<PlayerConnection> player = players[i];
player->connection->close(DisconnectPacket::eDisconnect_Closed);
}
}
void ServerConnection::tick()
{
{
// MGH - changed this so that the the CS lock doesn't cover the tick (was causing a lockup when 2 players tried to join)
EnterCriticalSection(&pending_cs);
std::vector< std::shared_ptr<PendingConnection> > tempPending = pending;
LeaveCriticalSection(&pending_cs);
void ServerConnection::tick() {
{
// MGH - changed this so that the the CS lock doesn't cover the tick
// (was causing a lockup when 2 players tried to join)
EnterCriticalSection(&pending_cs);
std::vector<std::shared_ptr<PendingConnection> > tempPending = pending;
LeaveCriticalSection(&pending_cs);
for (unsigned int i = 0; i < tempPending.size(); i++)
{
std::shared_ptr<PendingConnection> uc = tempPending[i];
// try { // 4J - removed try/catch
uc->tick();
// } catch (Exception e) {
// uc.disconnect("Internal server error");
// logger.log(Level.WARNING, "Failed to handle packet: " + e, e);
// }
if(uc->connection != NULL) uc->connection->flush();
}
}
for (unsigned int i = 0; i < tempPending.size(); i++) {
std::shared_ptr<PendingConnection> uc = tempPending[i];
// try { // 4J - removed try/catch
uc->tick();
// } catch (Exception e) {
// uc.disconnect("Internal server error");
// logger.log(Level.WARNING, "Failed to handle packet: "
// + e, e);
// }
if (uc->connection != NULL) uc->connection->flush();
}
}
// now remove from the pending list
EnterCriticalSection(&pending_cs);
for (unsigned int i = 0; i < pending.size(); i++)
if (pending[i]->done)
{
pending.erase(pending.begin()+i);
i--;
}
LeaveCriticalSection(&pending_cs);
// now remove from the pending list
EnterCriticalSection(&pending_cs);
for (unsigned int i = 0; i < pending.size(); i++)
if (pending[i]->done) {
pending.erase(pending.begin() + i);
i--;
}
LeaveCriticalSection(&pending_cs);
for (unsigned int i = 0; i < players.size(); i++)
{
for (unsigned int i = 0; i < players.size(); i++) {
std::shared_ptr<PlayerConnection> player = players[i];
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
if( serverPlayer )
{
serverPlayer->doChunkSendingTick(false);
}
// try { // 4J - removed try/catch
player->tick();
// } catch (Exception e) {
// logger.log(Level.WARNING, "Failed to handle packet: " + e, e);
// player.disconnect("Internal server error");
// }
if (player->done)
{
players.erase(players.begin()+i);
i--;
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
if (serverPlayer) {
serverPlayer->doChunkSendingTick(false);
}
// try { // 4J - removed try/catch
player->tick();
// } catch (Exception e) {
// logger.log(Level.WARNING, "Failed to handle packet: " + e,
// e); player.disconnect("Internal server error");
// }
if (player->done) {
players.erase(players.begin() + i);
i--;
}
player->connection->flush();
}
}
bool ServerConnection::addPendingTextureRequest(const std::wstring &textureName)
{
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
if( it == m_pendingTextureRequests.end() )
{
m_pendingTextureRequests.push_back(textureName);
return true;
}
bool ServerConnection::addPendingTextureRequest(
const std::wstring& textureName) {
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName));
if (it == m_pendingTextureRequests.end()) {
m_pendingTextureRequests.push_back(textureName);
return true;
}
// 4J Stu - We want to request this texture from everyone, if we have a duplicate it's most likely because the first person we asked for it didn't have it
// eg They selected a skin then deleted the skin pack. The side effect of this change is that in certain cases we can send a few more requests, and receive
// a few more responses if people join with the same skin in a short space of time
return true;
// 4J Stu - We want to request this texture from everyone, if we have a
// duplicate it's most likely because the first person we asked for it
// didn't have it eg They selected a skin then deleted the skin pack. The
// side effect of this change is that in certain cases we can send a few
// more requests, and receive a few more responses if people join with the
// same skin in a short space of time
return true;
}
void ServerConnection::handleTextureReceived(const std::wstring &textureName)
{
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
if( it != m_pendingTextureRequests.end() )
{
m_pendingTextureRequests.erase(it);
}
for (unsigned int i = 0; i < players.size(); i++)
{
void ServerConnection::handleTextureReceived(const std::wstring& textureName) {
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName));
if (it != m_pendingTextureRequests.end()) {
m_pendingTextureRequests.erase(it);
}
for (unsigned int i = 0; i < players.size(); i++) {
std::shared_ptr<PlayerConnection> player = players[i];
if (!player->done)
{
player->handleTextureReceived(textureName);
if (!player->done) {
player->handleTextureReceived(textureName);
}
}
}
void ServerConnection::handleTextureAndGeometryReceived(const std::wstring &textureName)
{
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
if( it != m_pendingTextureRequests.end() )
{
m_pendingTextureRequests.erase(it);
}
for (unsigned int i = 0; i < players.size(); i++)
{
std::shared_ptr<PlayerConnection> player = players[i];
if (!player->done)
{
player->handleTextureAndGeometryReceived(textureName);
}
}
void ServerConnection::handleTextureAndGeometryReceived(
const std::wstring& textureName) {
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
m_pendingTextureRequests.end(), textureName));
if (it != m_pendingTextureRequests.end()) {
m_pendingTextureRequests.erase(it);
}
for (unsigned int i = 0; i < players.size(); i++) {
std::shared_ptr<PlayerConnection> player = players[i];
if (!player->done) {
player->handleTextureAndGeometryReceived(textureName);
}
}
}
void ServerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
{
Minecraft *pMinecraft = Minecraft::GetInstance();
void ServerConnection::handleServerSettingsChanged(
std::shared_ptr<ServerSettingsChangedPacket> packet) {
Minecraft* pMinecraft = Minecraft::GetInstance();
if(packet->action==ServerSettingsChangedPacket::HOST_DIFFICULTY)
{
for(unsigned int i = 0; i < pMinecraft->levels.length; ++i)
{
if( pMinecraft->levels[i] != NULL )
{
app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data);
pMinecraft->levels[i]->difficulty = packet->data;
}
}
}
// else if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)// options
// {
// app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings)
// }
// else
// {
// unsigned char ucData=(unsigned char)packet->data;
// if(ucData&1)
// {
// // hide gamertags
// pMinecraft->options->SetGamertagSetting(true);
// }
// else
// {
// pMinecraft->options->SetGamertagSetting(false);
// }
//
// for (unsigned int i = 0; i < players.size(); i++)
// {
// std::shared_ptr<PlayerConnection> playerconnection = players[i];
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
// }
// }
if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) {
for (unsigned int i = 0; i < pMinecraft->levels.length; ++i) {
if (pMinecraft->levels[i] != NULL) {
app.DebugPrintf(
"ClientConnection::handleServerSettingsChanged - "
"Difficulty = %d",
packet->data);
pMinecraft->levels[i]->difficulty = packet->data;
}
}
}
// else
// if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)//
// options
// {
// app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings)
// }
// else
// {
// unsigned char ucData=(unsigned char)packet->data;
// if(ucData&1)
// {
// // hide gamertags
// pMinecraft->options->SetGamertagSetting(true);
// }
// else
// {
// pMinecraft->options->SetGamertagSetting(false);
// }
//
// for (unsigned int i = 0; i < players.size(); i++)
// {
// std::shared_ptr<PlayerConnection> playerconnection =
// players[i];
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
// }
// }
}

View file

@ -5,45 +5,52 @@ class MinecraftServer;
class Socket;
class ServerSettingsChangedPacket;
class ServerConnection
{
// public static Logger logger = Logger.getLogger("Minecraft");
class ServerConnection {
// public static Logger logger = Logger.getLogger("Minecraft");
private:
// ServerSocket serverSocket;
// private Thread listenThread;
// ServerSocket serverSocket;
// private Thread listenThread;
public:
volatile bool running;
volatile bool running;
private:
int connectionCounter;
int connectionCounter;
private:
CRITICAL_SECTION pending_cs; // 4J added
std::vector< std::shared_ptr<PendingConnection> > pending;
std::vector< std::shared_ptr<PlayerConnection> > players;
CRITICAL_SECTION pending_cs; // 4J added
std::vector<std::shared_ptr<PendingConnection> > pending;
std::vector<std::shared_ptr<PlayerConnection> > players;
// 4J - When the server requests a texture, it should add it to here while we are waiting for it
std::vector<std::wstring> m_pendingTextureRequests;
public:
MinecraftServer *server;
// 4J - When the server requests a texture, it should add it to here while
// we are waiting for it
std::vector<std::wstring> m_pendingTextureRequests;
public:
ServerConnection(MinecraftServer *server); // 4J - removed params InetAddress address, int port);
~ServerConnection();
void NewIncomingSocket(Socket *socket); // 4J - added
MinecraftServer* server;
void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required
public:
ServerConnection(
MinecraftServer*
server); // 4J - removed params InetAddress address, int port);
~ServerConnection();
void NewIncomingSocket(Socket* socket); // 4J - added
void removeSpamProtection(Socket* socket) {
} // 4J Stu - Not implemented as not required
void addPlayerConnection(std::shared_ptr<PlayerConnection> uc);
private:
void handleConnection(std::shared_ptr<PendingConnection> uc);
void handleConnection(std::shared_ptr<PendingConnection> uc);
public:
void stop();
void stop();
void tick();
// 4J Added
bool addPendingTextureRequest(const std::wstring &textureName);
void handleTextureReceived(const std::wstring &textureName);
void handleTextureAndGeometryReceived(const std::wstring &textureName);
void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
// 4J Added
bool addPendingTextureRequest(const std::wstring& textureName);
void handleTextureReceived(const std::wstring& textureName);
void handleTextureAndGeometryReceived(const std::wstring& textureName);
void handleServerSettingsChanged(
std::shared_ptr<ServerSettingsChangedPacket> packet);
};

View file

@ -1,29 +1,29 @@
#pragma once
class ServerInterface
{
virtual int getConfigInt(const std::wstring &name, int defaultValue) = 0;
virtual std::wstring getConfigString(const std::wstring &name, const std::wstring &defaultValue) = 0;
virtual bool getConfigBoolean(const std::wstring &name, bool defaultValue) = 0;
virtual void setProperty(std::wstring &propertyName, void *value) = 0;
virtual void configSave() = 0;
virtual std::wstring getConfigPath() = 0;
virtual std::wstring getServerIp() = 0;
virtual int getServerPort() = 0;
virtual std::wstring getServerName() = 0;
virtual std::wstring getServerVersion() = 0;
virtual int getPlayerCount() = 0;
virtual int getMaxPlayers() = 0;
virtual std::wstring[] getPlayerNames() = 0;
virtual std::wstring getWorldName() = 0;
virtual std::wstring getPluginNames() = 0;
virtual void disablePlugin() = 0;
virtual std::wstring runCommand(const std::wstring &command) = 0;
virtual bool isDebugging() = 0;
// Logging
virtual void info(const std::wstring &string) = 0;
virtual void warn(const std::wstring &string) = 0;
virtual void error(const std::wstring &string) = 0;
virtual void debug(const std::wstring &string) = 0;
class ServerInterface {
virtual int getConfigInt(const std::wstring& name, int defaultValue) = 0;
virtual std::wstring getConfigString(const std::wstring& name,
const std::wstring& defaultValue) = 0;
virtual bool getConfigBoolean(const std::wstring& name,
bool defaultValue) = 0;
virtual void setProperty(std::wstring& propertyName, void* value) = 0;
virtual void configSave() = 0;
virtual std::wstring getConfigPath() = 0;
virtual std::wstring getServerIp() = 0;
virtual int getServerPort() = 0;
virtual std::wstring getServerName() = 0;
virtual std::wstring getServerVersion() = 0;
virtual int getPlayerCount() = 0;
virtual int getMaxPlayers() = 0;
virtual std::wstring[] getPlayerNames() = 0;
virtual std::wstring getWorldName() = 0;
virtual std::wstring getPluginNames() = 0;
virtual void disablePlugin() = 0;
virtual std::wstring runCommand(const std::wstring& command) = 0;
virtual bool isDebugging() = 0;
// Logging
virtual void info(const std::wstring& string) = 0;
virtual void warn(const std::wstring& string) = 0;
virtual void error(const std::wstring& string) = 0;
virtual void debug(const std::wstring& string) = 0;
};

View file

@ -22,16 +22,15 @@
#define false 0
// Iggy GDraw support functions - normally in the Iggy library, stubbed here
void * IggyGDrawMallocAnnotated(SINTa size, const char *file, int line) {
(void)file; (void)line;
void* IggyGDrawMallocAnnotated(SINTa size, const char* file, int line) {
(void)file;
(void)line;
return malloc((size_t)size);
}
void IggyGDrawFree(void *ptr) {
free(ptr);
}
void IggyGDrawFree(void* ptr) { free(ptr); }
void IggyGDrawSendWarning(Iggy *f, char const *message, ...) {
void IggyGDrawSendWarning(Iggy* f, char const* message, ...) {
(void)f;
va_list args;
va_start(args, message);
@ -41,8 +40,9 @@ void IggyGDrawSendWarning(Iggy *f, char const *message, ...) {
va_end(args);
}
void IggyDiscardVertexBufferCallback(void *owner, void *buf) {
(void)owner; (void)buf;
void IggyDiscardVertexBufferCallback(void* owner, void* buf) {
(void)owner;
(void)buf;
}
///////////////////////////////////////////////////////////////////////////////
@ -55,61 +55,67 @@ void IggyDiscardVertexBufferCallback(void *owner, void *buf) {
// The shared code calls them by name and the real functions are used directly.
//
#define GDRAW_GL_EXTENSION_LIST \
/* identifier import procname */ \
/* GL_ARB_vertex_buffer_object */ \
GLE(GenBuffers, "GenBuffersARB", GENBUFFERSARB) \
GLE(DeleteBuffers, "DeleteBuffersARB", DELETEBUFFERSARB) \
GLE(BindBuffer, "BindBufferARB", BINDBUFFERARB) \
GLE(BufferData, "BufferDataARB", BUFFERDATAARB) \
GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \
GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \
GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \
GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", ENABLEVERTEXATTRIBARRAYARB) \
GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", DISABLEVERTEXATTRIBARRAYARB) \
/* GL_ARB_shader_objects */ \
GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \
GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(ShaderSource, "ShaderSourceARB", SHADERSOURCEARB) \
GLE(CompileShader, "CompileShaderARB", COMPILESHADERARB) \
GLE(GetShaderiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetShaderInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(CreateProgram, "CreateProgramObjectARB", CREATEPROGRAMOBJECTARB) \
GLE(DeleteProgram, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(AttachShader, "AttachObjectARB", ATTACHOBJECTARB) \
GLE(LinkProgram, "LinkProgramARB", LINKPROGRAMARB) \
GLE(GetUniformLocation, "GetUniformLocationARB", GETUNIFORMLOCATIONARB) \
GLE(UseProgram, "UseProgramObjectARB", USEPROGRAMOBJECTARB) \
GLE(GetProgramiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetProgramInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(Uniform1i, "Uniform1iARB", UNIFORM1IARB) \
GLE(Uniform4f, "Uniform4fARB", UNIFORM4FARB) \
GLE(Uniform4fv, "Uniform4fvARB", UNIFORM4FVARB) \
/* GL_ARB_vertex_shader */ \
GLE(BindAttribLocation, "BindAttribLocationARB", BINDATTRIBLOCATIONARB) \
/* Missing from WGL but needed by shared code */ \
GLE(Uniform1f, "Uniform1fARB", UNIFORM1FARB) \
/* GL_EXT_framebuffer_object */ \
GLE(GenRenderbuffers, "GenRenderbuffersEXT", GENRENDERBUFFERSEXT) \
GLE(DeleteRenderbuffers, "DeleteRenderbuffersEXT", DELETERENDERBUFFERSEXT) \
GLE(BindRenderbuffer, "BindRenderbufferEXT", BINDRENDERBUFFEREXT) \
GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBUFFERSTORAGEEXT) \
GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \
GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \
GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \
GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", CHECKFRAMEBUFFERSTATUSEXT) \
GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", FRAMEBUFFERRENDERBUFFEREXT) \
GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", FRAMEBUFFERTEXTURE2DEXT) \
GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \
/* GL_EXT_framebuffer_blit */ \
GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \
/* GL_EXT_framebuffer_multisample */ \
GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT",RENDERBUFFERSTORAGEMULTISAMPLEEXT) \
/* <end> */
#define GDRAW_GL_EXTENSION_LIST \
/* identifier import procname */ \
/* GL_ARB_vertex_buffer_object */ \
GLE(GenBuffers, "GenBuffersARB", GENBUFFERSARB) \
GLE(DeleteBuffers, "DeleteBuffersARB", DELETEBUFFERSARB) \
GLE(BindBuffer, "BindBufferARB", BINDBUFFERARB) \
GLE(BufferData, "BufferDataARB", BUFFERDATAARB) \
GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \
GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \
GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \
GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", \
ENABLEVERTEXATTRIBARRAYARB) \
GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", \
DISABLEVERTEXATTRIBARRAYARB) \
/* GL_ARB_shader_objects */ \
GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \
GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(ShaderSource, "ShaderSourceARB", SHADERSOURCEARB) \
GLE(CompileShader, "CompileShaderARB", COMPILESHADERARB) \
GLE(GetShaderiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetShaderInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(CreateProgram, "CreateProgramObjectARB", CREATEPROGRAMOBJECTARB) \
GLE(DeleteProgram, "DeleteObjectARB", DELETEOBJECTARB) \
GLE(AttachShader, "AttachObjectARB", ATTACHOBJECTARB) \
GLE(LinkProgram, "LinkProgramARB", LINKPROGRAMARB) \
GLE(GetUniformLocation, "GetUniformLocationARB", GETUNIFORMLOCATIONARB) \
GLE(UseProgram, "UseProgramObjectARB", USEPROGRAMOBJECTARB) \
GLE(GetProgramiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \
GLE(GetProgramInfoLog, "GetInfoLogARB", GETINFOLOGARB) \
GLE(Uniform1i, "Uniform1iARB", UNIFORM1IARB) \
GLE(Uniform4f, "Uniform4fARB", UNIFORM4FARB) \
GLE(Uniform4fv, "Uniform4fvARB", UNIFORM4FVARB) \
/* GL_ARB_vertex_shader */ \
GLE(BindAttribLocation, "BindAttribLocationARB", BINDATTRIBLOCATIONARB) \
/* Missing from WGL but needed by shared code */ \
GLE(Uniform1f, "Uniform1fARB", UNIFORM1FARB) \
/* GL_EXT_framebuffer_object */ \
GLE(GenRenderbuffers, "GenRenderbuffersEXT", GENRENDERBUFFERSEXT) \
GLE(DeleteRenderbuffers, "DeleteRenderbuffersEXT", DELETERENDERBUFFERSEXT) \
GLE(BindRenderbuffer, "BindRenderbufferEXT", BINDRENDERBUFFEREXT) \
GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBUFFERSTORAGEEXT) \
GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \
GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \
GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \
GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", \
CHECKFRAMEBUFFERSTATUSEXT) \
GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", \
FRAMEBUFFERRENDERBUFFEREXT) \
GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", \
FRAMEBUFFERTEXTURE2DEXT) \
GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \
/* GL_EXT_framebuffer_blit */ \
GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \
/* GL_EXT_framebuffer_multisample */ \
GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT", \
RENDERBUFFERSTORAGEMULTISAMPLEEXT) \
/* <end> */
#define gdraw_GLx_(id) gdraw_GL_##id
#define GDRAW_GLx_(id) GDRAW_GL_##id
#define GDRAW_SHADERS "gdraw_gl_shaders.inl"
#define gdraw_GLx_(id) gdraw_GL_##id
#define GDRAW_GLx_(id) GDRAW_GL_##id
#define GDRAW_SHADERS "gdraw_gl_shaders.inl"
// On Linux, GLhandleARB is void* (not GLuint) but the shader functions
// actually return/take GLuint values. Use GLuint as our handle type,
@ -123,20 +129,18 @@ typedef gdraw_gl_resourcetype gdraw_resourcetype;
GDRAW_GL_EXTENSION_LIST
#undef GLE
static void load_extensions(void)
{
#define GLE(id, import, procname) gl##id = (PFNGL##procname##PROC) SDL_GL_GetProcAddress("gl" import);
static void load_extensions(void) {
#define GLE(id, import, procname) \
gl##id = (PFNGL##procname##PROC)SDL_GL_GetProcAddress("gl" import);
GDRAW_GL_EXTENSION_LIST
#undef GLE
#undef GLE
}
static void clear_renderstate_platform_specific(void)
{
static void clear_renderstate_platform_specific(void) {
glDisable(GL_ALPHA_TEST);
}
static void error_msg_platform_specific(const char *msg)
{
static void error_msg_platform_specific(const char* msg) {
fprintf(stderr, "[GDraw GL] %s\n", msg);
}
@ -151,7 +155,10 @@ static void error_msg_platform_specific(const char *msg)
#ifdef RR_BREAK
#undef RR_BREAK
#endif
#define RR_BREAK() do { fprintf(stderr, "[GDraw] RR_BREAK suppressed (GL error)\n"); } while(0)
#define RR_BREAK() \
do { \
fprintf(stderr, "[GDraw] RR_BREAK suppressed (GL error)\n"); \
} while (0)
#include "../../../Windows64/Iggy/gdraw/gdraw_gl_shared.inl"
@ -160,32 +167,42 @@ static void error_msg_platform_specific(const char *msg)
// Initialization and platform-specific functionality
//
GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
{
GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) {
static const TextureFormatDesc tex_formats[] = {
{ IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 },
{ IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 },
{ IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_i_8, 1, 1, 1, GL_INTENSITY8, GL_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_i_4, 1, 1, 1, GL_INTENSITY4, GL_ALPHA, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_l_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0, GL_UNSIGNED_BYTE },
{ IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0, GL_UNSIGNED_BYTE },
{ 0, 0, 0, 0, 0, 0, 0 },
{IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
{IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA,
GL_UNSIGNED_SHORT_4_4_4_4},
{IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA,
GL_UNSIGNED_SHORT_5_5_5_1},
{IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_i_8, 1, 1, 1, GL_INTENSITY8, GL_ALPHA, GL_UNSIGNED_BYTE},
{IFT_FORMAT_i_4, 1, 1, 1, GL_INTENSITY4, GL_ALPHA, GL_UNSIGNED_BYTE},
{IFT_FORMAT_l_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0,
GL_UNSIGNED_BYTE},
{IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0,
GL_UNSIGNED_BYTE},
{0, 0, 0, 0, 0, 0, 0},
};
GDrawFunctions *funcs;
const char *s;
GDrawFunctions* funcs;
const char* s;
GLint n;
// check for the extensions we need
s = (const char *) glGetString(GL_EXTENSIONS);
s = (const char*)glGetString(GL_EXTENSIONS);
if (s == NULL) {
fprintf(stderr, "[GDraw GL] glGetString(GL_EXTENSIONS) returned NULL - GL context not current?\n");
fprintf(stderr,
"[GDraw GL] glGetString(GL_EXTENSIONS) returned NULL - GL "
"context not current?\n");
assert(s != NULL);
return NULL;
}
@ -199,8 +216,7 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
!hasext(s, "GL_EXT_framebuffer_object") ||
!hasext(s, "GL_ARB_shader_objects") ||
!hasext(s, "GL_ARB_vertex_shader") ||
!hasext(s, "GL_ARB_fragment_shader"))
{
!hasext(s, "GL_ARB_fragment_shader")) {
fprintf(stderr, "[GDraw GL] Required GL extensions not available\n");
return NULL;
}
@ -211,17 +227,17 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
load_extensions();
funcs = create_context(w, h);
if (!funcs)
return NULL;
if (!funcs) return NULL;
gdraw->tex_formats = tex_formats;
// check for optional extensions
gdraw->has_mapbuffer = true; // part of core VBO extension on regular GL
gdraw->has_depth24 = true; // we just assume.
gdraw->has_texture_max_level = true; // core on regular GL
gdraw->has_mapbuffer = true; // part of core VBO extension on regular GL
gdraw->has_depth24 = true; // we just assume.
gdraw->has_texture_max_level = true; // core on regular GL
if (hasext(s, "GL_EXT_packed_depth_stencil")) gdraw->has_packed_depth_stencil = true;
if (hasext(s, "GL_EXT_packed_depth_stencil"))
gdraw->has_packed_depth_stencil = true;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &n);
gdraw->has_conditional_non_power_of_two = n < 8192;
@ -234,7 +250,9 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
opengl_check();
fprintf(stderr, "[GDraw GL] Context created successfully (%dx%d, msaa=%d)\n", w, h, msaa_samples);
fprintf(stderr,
"[GDraw GL] Context created successfully (%dx%d, msaa=%d)\n", w, h,
msaa_samples);
return funcs;
}
@ -243,14 +261,15 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
// 4J-specific custom draw functions
//
void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion *region, F32 *matrix)
{
void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
F32* matrix) {
// Same as BeginCustomDraw but uses different depth param
clear_renderstate();
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, depth_from_id(0), 1);
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection,
depth_from_id(0), 1);
}
void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion *region, F32 *matrix)
{
void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region,
F32* matrix) {
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0);
}

View file

@ -8,35 +8,49 @@
extern "C" {
#endif
typedef enum gdraw_gl_resourcetype
{
GDRAW_GL_RESOURCE_rendertarget,
GDRAW_GL_RESOURCE_texture,
GDRAW_GL_RESOURCE_vertexbuffer,
typedef enum gdraw_gl_resourcetype {
GDRAW_GL_RESOURCE_rendertarget,
GDRAW_GL_RESOURCE_texture,
GDRAW_GL_RESOURCE_vertexbuffer,
GDRAW_GL_RESOURCE__count,
GDRAW_GL_RESOURCE__count,
} gdraw_gl_resourcetype;
struct IggyCustomDrawCallbackRegion;
extern int gdraw_GL_SetResourceLimits(gdraw_gl_resourcetype type, S32 num_handles, S32 num_bytes);
extern GDrawFunctions * gdraw_GL_CreateContext(S32 min_w, S32 min_h, S32 msaa_samples);
extern int gdraw_GL_SetResourceLimits(gdraw_gl_resourcetype type,
S32 num_handles, S32 num_bytes);
extern GDrawFunctions* gdraw_GL_CreateContext(S32 min_w, S32 min_h,
S32 msaa_samples);
extern void gdraw_GL_DestroyContext(void);
extern void gdraw_GL_SetTileOrigin(S32 vx, S32 vy, unsigned int framebuffer); // framebuffer=FBO handle, or 0 for main frame buffer
extern void gdraw_GL_SetTileOrigin(
S32 vx, S32 vy,
unsigned int
framebuffer); // framebuffer=FBO handle, or 0 for main frame buffer
extern void gdraw_GL_NoMoreGDrawThisFrame(void);
extern GDrawTexture *gdraw_GL_WrappedTextureCreate(S32 gl_texture_handle, S32 width, S32 height, int has_mipmaps);
extern void gdraw_GL_WrappedTextureChange(GDrawTexture *tex, S32 new_gl_texture_handle, S32 new_width, S32 new_height, int new_has_mipmaps);
extern void gdraw_GL_WrappedTextureDestroy(GDrawTexture *tex);
extern GDrawTexture* gdraw_GL_WrappedTextureCreate(S32 gl_texture_handle,
S32 width, S32 height,
int has_mipmaps);
extern void gdraw_GL_WrappedTextureChange(GDrawTexture* tex,
S32 new_gl_texture_handle,
S32 new_width, S32 new_height,
int new_has_mipmaps);
extern void gdraw_GL_WrappedTextureDestroy(GDrawTexture* tex);
extern void gdraw_GL_BeginCustomDraw(struct IggyCustomDrawCallbackRegion *region, float *matrix);
extern void gdraw_GL_EndCustomDraw(struct IggyCustomDrawCallbackRegion *region);
extern void gdraw_GL_BeginCustomDraw(
struct IggyCustomDrawCallbackRegion* region, float* matrix);
extern void gdraw_GL_EndCustomDraw(struct IggyCustomDrawCallbackRegion* region);
extern void gdraw_GL_CalculateCustomDraw_4J(struct IggyCustomDrawCallbackRegion *region, float *matrix);
extern void gdraw_GL_BeginCustomDraw_4J(struct IggyCustomDrawCallbackRegion *region, float *matrix);
extern void gdraw_GL_CalculateCustomDraw_4J(
struct IggyCustomDrawCallbackRegion* region, float* matrix);
extern void gdraw_GL_BeginCustomDraw_4J(
struct IggyCustomDrawCallbackRegion* region, float* matrix);
extern GDrawTexture * gdraw_GL_MakeTextureFromResource(unsigned char *resource_file, S32 resource_len, IggyFileTextureRaw *texture);
extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture *tex);
extern GDrawTexture* gdraw_GL_MakeTextureFromResource(
unsigned char* resource_file, S32 resource_len,
IggyFileTextureRaw* texture);
extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture* tex);
#ifdef __cplusplus
}

View file

@ -2,4 +2,6 @@
#include "LinuxLeaderboardManager.h"
LeaderboardManager *LeaderboardManager::m_instance = new LinuxLeaderboardManager(); //Singleton instance of the LeaderboardManager
LeaderboardManager* LeaderboardManager::m_instance =
new LinuxLeaderboardManager(); // Singleton instance of the
// LeaderboardManager

View file

@ -2,35 +2,50 @@
#include "../../Common/Leaderboards/LeaderboardManager.h"
class LinuxLeaderboardManager : public LeaderboardManager
{
class LinuxLeaderboardManager : public LeaderboardManager {
public:
virtual void Tick() {}
virtual void Tick() {}
//Open a session
virtual bool OpenSession() { return true; }
// Open a session
virtual bool OpenSession() { return true; }
//Close a session
virtual void CloseSession() {}
// Close a session
virtual void CloseSession() {}
//Delete a session
virtual void DeleteSession() {}
// Delete a session
virtual void DeleteSession() {}
//Write the given stats
//This is called synchronously and will not free any memory allocated for views when it is done
// Write the given stats
// This is called synchronously and will not free any memory allocated for
// views when it is done
virtual bool WriteStats(unsigned int viewCount, ViewIn views) { return false; }
virtual bool WriteStats(unsigned int viewCount, ViewIn views) {
return false;
}
virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID) { return false; }
virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount) { return false; }
virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount) { return false; }
virtual bool ReadStats_Friends(LeaderboardReadListener* callback,
int difficulty, EStatsType type,
PlayerUID myUID) {
return false;
}
virtual bool ReadStats_MyScore(LeaderboardReadListener* callback,
int difficulty, EStatsType type,
PlayerUID myUID, unsigned int readCount) {
return false;
}
virtual bool ReadStats_TopRank(LeaderboardReadListener* callback,
int difficulty, EStatsType type,
unsigned int startIndex,
unsigned int readCount) {
return false;
}
//Perform a flush of the stats
virtual void FlushStats() {}
// Perform a flush of the stats
virtual void FlushStats() {}
//Cancel the current operation
virtual void CancelOperation() {}
// Cancel the current operation
virtual void CancelOperation() {}
//Is the leaderboard manager idle.
virtual bool isIdle() { return true; }
// Is the leaderboard manager idle.
virtual bool isIdle() { return true; }
};

View file

@ -9,96 +9,81 @@
#include "../../Minecraft.World/IO/Streams/FloatBuffer.h"
#include "../../Minecraft.World/IO/Streams/ByteBuffer.h"
int glGenTextures()
{
GLuint id = 0;
::glGenTextures(1, &id);
return (int)id;
int glGenTextures() {
GLuint id = 0;
::glGenTextures(1, &id);
return (int)id;
}
void glGenTextures(IntBuffer *buf)
{
GLuint id = 0;
::glGenTextures(1, &id);
buf->put((int)id);
buf->flip();
void glGenTextures(IntBuffer* buf) {
GLuint id = 0;
::glGenTextures(1, &id);
buf->put((int)id);
buf->flip();
}
void glDeleteTextures(int id)
{
GLuint uid = (GLuint)id;
::glDeleteTextures(1, &uid);
void glDeleteTextures(int id) {
GLuint uid = (GLuint)id;
::glDeleteTextures(1, &uid);
}
void glDeleteTextures(IntBuffer *buf)
{
int id = buf->get(0);
GLuint uid = (GLuint)id;
::glDeleteTextures(1, &uid);
void glDeleteTextures(IntBuffer* buf) {
int id = buf->get(0);
GLuint uid = (GLuint)id;
::glDeleteTextures(1, &uid);
}
void glLight(int light, int pname, FloatBuffer *params)
{
::glLightfv((GLenum)light, (GLenum)pname, params->_getDataPointer());
void glLight(int light, int pname, FloatBuffer* params) {
::glLightfv((GLenum)light, (GLenum)pname, params->_getDataPointer());
}
void glLightModel(int pname, FloatBuffer *params)
{
::glLightModelfv((GLenum)pname, params->_getDataPointer());
void glLightModel(int pname, FloatBuffer* params) {
::glLightModelfv((GLenum)pname, params->_getDataPointer());
}
void glGetFloat(int pname, FloatBuffer *params)
{
::glGetFloatv((GLenum)pname, params->_getDataPointer());
void glGetFloat(int pname, FloatBuffer* params) {
::glGetFloatv((GLenum)pname, params->_getDataPointer());
}
void glTexGen(int coord, int pname, FloatBuffer *params)
{
::glTexGenfv((GLenum)coord, (GLenum)pname, params->_getDataPointer());
void glTexGen(int coord, int pname, FloatBuffer* params) {
::glTexGenfv((GLenum)coord, (GLenum)pname, params->_getDataPointer());
}
void glFog(int pname, FloatBuffer *params)
{
::glFogfv((GLenum)pname, params->_getDataPointer());
void glFog(int pname, FloatBuffer* params) {
::glFogfv((GLenum)pname, params->_getDataPointer());
}
void glTexCoordPointer(int size, int type, FloatBuffer *pointer)
{
::glTexCoordPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
void glTexCoordPointer(int size, int type, FloatBuffer* pointer) {
::glTexCoordPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
}
void glNormalPointer(int type, ByteBuffer *pointer)
{
::glNormalPointer((GLenum)type, 0, pointer->getBuffer());
void glNormalPointer(int type, ByteBuffer* pointer) {
::glNormalPointer((GLenum)type, 0, pointer->getBuffer());
}
void glColorPointer(int size, bool normalized, int stride, ByteBuffer *pointer)
{
(void)normalized;
::glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer->getBuffer());
void glColorPointer(int size, bool normalized, int stride,
ByteBuffer* pointer) {
(void)normalized;
::glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer->getBuffer());
}
void glVertexPointer(int size, int type, FloatBuffer *pointer)
{
::glVertexPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
void glVertexPointer(int size, int type, FloatBuffer* pointer) {
::glVertexPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
}
void glEndList(int)
{
::glEndList();
void glEndList(int) { ::glEndList(); }
void glTexImage2D(int target, int level, int internalformat, int width,
int height, int border, int format, int type,
ByteBuffer* pixels) {
void* data = pixels ? pixels->getBuffer() : nullptr;
::glTexImage2D((GLenum)target, level, internalformat, width, height, border,
(GLenum)format, (GLenum)type, data);
}
void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer *pixels)
{
void *data = pixels ? pixels->getBuffer() : nullptr;
::glTexImage2D((GLenum)target, level, internalformat, width, height, border, (GLenum)format, (GLenum)type, data);
}
void glCallLists(IntBuffer *lists)
{
int count = lists->limit() - lists->position();
::glCallLists(count, GL_INT, lists->getBuffer());
void glCallLists(IntBuffer* lists) {
int count = lists->limit() - lists->position();
::glCallLists(count, GL_INT, lists->getBuffer());
}
static PFNGLGENQUERIESARBPROC _glGenQueriesARB = nullptr;
@ -107,55 +92,52 @@ static PFNGLENDQUERYARBPROC _glEndQueryARB = nullptr;
static PFNGLGETQUERYOBJECTUIVARBPROC _glGetQueryObjectuivARB = nullptr;
static bool _queriesInitialized = false;
static void initQueryFuncs()
{
if (_queriesInitialized) return;
_queriesInitialized = true;
_glGenQueriesARB = (PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB");
_glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)dlsym(RTLD_DEFAULT, "glBeginQueryARB");
_glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB");
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(RTLD_DEFAULT, "glGetQueryObjectuivARB");
static void initQueryFuncs() {
if (_queriesInitialized) return;
_queriesInitialized = true;
_glGenQueriesARB =
(PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB");
_glBeginQueryARB =
(PFNGLBEGINQUERYARBPROC)dlsym(RTLD_DEFAULT, "glBeginQueryARB");
_glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB");
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(
RTLD_DEFAULT, "glGetQueryObjectuivARB");
}
void glGenQueriesARB(IntBuffer *buf)
{
initQueryFuncs();
if (_glGenQueriesARB)
{
GLuint id = 0;
_glGenQueriesARB(1, &id);
buf->put((int)id);
buf->flip();
}
void glGenQueriesARB(IntBuffer* buf) {
initQueryFuncs();
if (_glGenQueriesARB) {
GLuint id = 0;
_glGenQueriesARB(1, &id);
buf->put((int)id);
buf->flip();
}
}
void glBeginQueryARB(int target, int id)
{
initQueryFuncs();
if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id);
void glBeginQueryARB(int target, int id) {
initQueryFuncs();
if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id);
}
void glEndQueryARB(int target)
{
initQueryFuncs();
if (_glEndQueryARB) _glEndQueryARB((GLenum)target);
void glEndQueryARB(int target) {
initQueryFuncs();
if (_glEndQueryARB) _glEndQueryARB((GLenum)target);
}
void glGetQueryObjectuARB(int id, int pname, IntBuffer *params)
{
initQueryFuncs();
if (_glGetQueryObjectuivARB)
{
GLuint val = 0;
_glGetQueryObjectuivARB((GLuint)id, (GLenum)pname, &val);
params->put((int)val);
params->flip();
}
void glGetQueryObjectuARB(int id, int pname, IntBuffer* params) {
initQueryFuncs();
if (_glGetQueryObjectuivARB) {
GLuint val = 0;
_glGetQueryObjectuivARB((GLuint)id, (GLenum)pname, &val);
params->put((int)val);
params->flip();
}
}
void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer *pixels)
{
::glReadPixels(x, y, width, height, (GLenum)format, (GLenum)type, pixels->getBuffer());
void glReadPixels(int x, int y, int width, int height, int format, int type,
ByteBuffer* pixels) {
::glReadPixels(x, y, width, height, (GLenum)format, (GLenum)type,
pixels->getBuffer());
}
#endif

View file

@ -9,31 +9,31 @@ class FloatBuffer;
class IntBuffer;
class ByteBuffer;
void glGenTextures(IntBuffer *);
void glGenTextures(IntBuffer*);
int glGenTextures();
void glDeleteTextures(IntBuffer *);
void glLight(int, int, FloatBuffer *);
void glLightModel(int, FloatBuffer *);
void glGetFloat(int a, FloatBuffer *b);
void glDeleteTextures(IntBuffer*);
void glLight(int, int, FloatBuffer*);
void glLightModel(int, FloatBuffer*);
void glGetFloat(int a, FloatBuffer* b);
void glTexCoordPointer(int, int, int, int);
void glTexCoordPointer(int, int, FloatBuffer *);
void glTexCoordPointer(int, int, FloatBuffer*);
void glNormalPointer(int, int, int);
void glNormalPointer(int, ByteBuffer *);
void glColorPointer(int, bool, int, ByteBuffer *);
void glNormalPointer(int, ByteBuffer*);
void glColorPointer(int, bool, int, ByteBuffer*);
void glColorPointer(int, int, int, int);
void glVertexPointer(int, int, int, int);
void glVertexPointer(int, int, FloatBuffer *);
void glVertexPointer(int, int, FloatBuffer*);
void glNewList(int, int);
void glEndList(int vertexCount = 0);
void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer *);
void glCallLists(IntBuffer *);
void glGenQueriesARB(IntBuffer *);
void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer*);
void glCallLists(IntBuffer*);
void glGenQueriesARB(IntBuffer*);
void glBeginQueryARB(int, int);
void glEndQueryARB(int);
void glGetQueryObjectuARB(int, int, IntBuffer *);
void glFog(int, FloatBuffer *);
void glTexGen(int, int, FloatBuffer *);
void glReadPixels(int, int, int, int, int, int, ByteBuffer *);
void glGetQueryObjectuARB(int, int, IntBuffer*);
void glFog(int, FloatBuffer*);
void glTexGen(int, int, FloatBuffer*);
void glReadPixels(int, int, int, int, int, int, ByteBuffer*);
void glTexGeni(int, int, int);
void glMultiTexCoord2f(int, float, float);
void glClientActiveTexture(int);

View file

@ -13,64 +13,55 @@
CConsoleMinecraftApp app;
#define CONTEXT_GAME_STATE 0
#define CONTEXT_GAME_STATE 0
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp()
{
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {}
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) {
ProfileManager.SetRichPresenceContextValue(iPad, CONTEXT_GAME_STATE,
contextId);
}
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId)
{
ProfileManager.SetRichPresenceContextValue(iPad,CONTEXT_GAME_STATE,contextId);
}
void CConsoleMinecraftApp::StoreLaunchData()
{
}
void CConsoleMinecraftApp::ExitGame()
{
}
void CConsoleMinecraftApp::FatalLoadError()
{
app.DebugPrintf("CConsoleMinecraftApp::FatalLoadError - asserting 0 and dying...\n");
void CConsoleMinecraftApp::StoreLaunchData() {}
void CConsoleMinecraftApp::ExitGame() {}
void CConsoleMinecraftApp::FatalLoadError() {
app.DebugPrintf(
"CConsoleMinecraftApp::FatalLoadError - asserting 0 and dying...\n");
assert(0);
}
void CConsoleMinecraftApp::CaptureSaveThumbnail()
{
}
void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize)
{
}
void CConsoleMinecraftApp::ReleaseSaveThumbnail()
{
}
void CConsoleMinecraftApp::CaptureSaveThumbnail() {}
void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t** thumbnailData,
unsigned int* thumbnailSize) {}
void CConsoleMinecraftApp::ReleaseSaveThumbnail() {}
void CConsoleMinecraftApp::GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize)
{
}
void CConsoleMinecraftApp::GetScreenshot(int iPad,
std::uint8_t** screenshotData,
unsigned int* screenshotSize) {}
void CConsoleMinecraftApp::TemporaryCreateGameStart()
{
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit
void CConsoleMinecraftApp::TemporaryCreateGameStart() {
//////////////////////////////////////////////////////////////////////////////////////////////
///From CScene_Main::OnInit
app.setLevelGenerationOptions(NULL);
// From CScene_Main::RunPlayGame
Minecraft *pMinecraft=Minecraft::GetInstance();
Minecraft* pMinecraft = Minecraft::GetInstance();
app.ReleaseSaveThumbnail();
ProfileManager.SetLockedProfile(0);
pMinecraft->user->name = L"Windows";
app.ApplyGameSettingsChanged(0);
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
//////////////////////////////////////////////////////////////////////////////////////////////
///From CScene_MultiGameJoinLoad::OnInit
MinecraftServer::resetFlags();
// From CScene_MultiGameJoinLoad::OnNotifyPressEx
app.SetTutorialMode( false );
app.SetTutorialMode(false);
app.SetCorruptSaveDeleted(false);
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
//////////////////////////////////////////////////////////////////////////////////////////////
///From CScene_MultiGameCreate::CreateGame
app.ClearTerrainFeaturePosition();
std::wstring wWorldName = L"TestWorld";
@ -79,60 +70,62 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
StorageManager.SetSaveTitle(wWorldName.c_str());
bool isFlat = false;
__int64 seedValue = 0; // BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal); // 4J - was (new Random())->nextLong() - now trying to actually find a seed to suit our requirements
__int64 seedValue =
0; // BiomeSource::findSeed(isFlat?LevelType::lvl_flat:LevelType::lvl_normal);
// // 4J - was (new Random())->nextLong() - now trying to actually
// find a seed to suit our requirements
NetworkGameInitData *param = new NetworkGameInitData();
NetworkGameInitData* param = new NetworkGameInitData();
param->seed = seedValue;
param->saveData = NULL;
app.SetGameHostOption(eGameHostOption_Difficulty,0);
app.SetGameHostOption(eGameHostOption_FriendsOfFriends,0);
app.SetGameHostOption(eGameHostOption_Gamertags,1);
app.SetGameHostOption(eGameHostOption_BedrockFog,1);
app.SetGameHostOption(eGameHostOption_Difficulty, 0);
app.SetGameHostOption(eGameHostOption_FriendsOfFriends, 0);
app.SetGameHostOption(eGameHostOption_Gamertags, 1);
app.SetGameHostOption(eGameHostOption_BedrockFog, 1);
app.SetGameHostOption(eGameHostOption_GameType,GameType::CREATIVE->getId() ); // LevelSettings::GAMETYPE_SURVIVAL
app.SetGameHostOption(eGameHostOption_LevelType, 0 );
app.SetGameHostOption(eGameHostOption_Structures, 1 );
app.SetGameHostOption(eGameHostOption_BonusChest, 0 );
app.SetGameHostOption(
eGameHostOption_GameType,
GameType::CREATIVE->getId()); // LevelSettings::GAMETYPE_SURVIVAL
app.SetGameHostOption(eGameHostOption_LevelType, 0);
app.SetGameHostOption(eGameHostOption_Structures, 1);
app.SetGameHostOption(eGameHostOption_BonusChest, 0);
app.SetGameHostOption(eGameHostOption_PvP, 1);
app.SetGameHostOption(eGameHostOption_TrustPlayers, 1 );
app.SetGameHostOption(eGameHostOption_FireSpreads, 1 );
app.SetGameHostOption(eGameHostOption_TNT, 1 );
app.SetGameHostOption(eGameHostOption_TrustPlayers, 1);
app.SetGameHostOption(eGameHostOption_FireSpreads, 1);
app.SetGameHostOption(eGameHostOption_TNT, 1);
app.SetGameHostOption(eGameHostOption_HostCanFly, 1);
app.SetGameHostOption(eGameHostOption_HostCanChangeHunger, 1);
app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, 1 );
app.SetGameHostOption(eGameHostOption_HostCanBeInvisible, 1);
param->settings = app.GetGameHostOption( eGameHostOption_All );
param->settings = app.GetGameHostOption(eGameHostOption_All);
g_NetworkManager.FakeLocalPlayerJoined();
LoadingInputParams *loadingParams = new LoadingInputParams();
LoadingInputParams* loadingParams = new LoadingInputParams();
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
loadingParams->lpParam = (LPVOID)param;
// Reset the autosave time
app.SetAutosaveTimerTime();
C4JThread* thread = new C4JThread(loadingParams->func, loadingParams->lpParam, "RunNetworkGame");
C4JThread* thread = new C4JThread(loadingParams->func,
loadingParams->lpParam, "RunNetworkGame");
thread->Run();
}
int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT)
{
int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR* wchTMSFile,
bool bFilenameIncludesExtension,
eFileExtensionType eEXT) {
return -1;
}
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile)
{
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR* wchTMSFile) { return -1; }
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR* wchTMSFile,
eFileExtensionType eExt) {
return -1;
}
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt)
{
return -1;
}
void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType)
{
}
void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) {}

View file

@ -1,34 +1,38 @@
#pragma once
class CConsoleMinecraftApp : public CMinecraftApp
{
class CConsoleMinecraftApp : public CMinecraftApp {
public:
CConsoleMinecraftApp();
CConsoleMinecraftApp();
virtual void SetRichPresenceContext(int iPad, int contextId);
virtual void SetRichPresenceContext(int iPad, int contextId);
virtual void StoreLaunchData();
virtual void ExitGame();
virtual void FatalLoadError();
virtual void StoreLaunchData();
virtual void ExitGame();
virtual void FatalLoadError();
virtual void CaptureSaveThumbnail();
virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize);
virtual void ReleaseSaveThumbnail();
virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize);
virtual void CaptureSaveThumbnail();
virtual void GetSaveThumbnail(std::uint8_t** thumbnailData,
unsigned int* thumbnailSize);
virtual void ReleaseSaveThumbnail();
virtual void GetScreenshot(int iPad, std::uint8_t** screenshotData,
unsigned int* screenshotSize);
virtual int LoadLocalTMSFile(WCHAR *wchTMSFile);
virtual int LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt);
virtual int LoadLocalTMSFile(WCHAR* wchTMSFile);
virtual int LoadLocalTMSFile(WCHAR* wchTMSFile, eFileExtensionType eExt);
virtual void FreeLocalTMSFiles(eTMSFileType eType);
virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT=eFileExtensionType_PNG);
virtual void FreeLocalTMSFiles(eTMSFileType eType);
virtual int GetLocalTMSFileIndex(
WCHAR* wchTMSFile, bool bFilenameIncludesExtension,
eFileExtensionType eEXT = eFileExtensionType_PNG);
// BANNED LEVEL LIST
virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {}
// BANNED LEVEL LIST
virtual void ReadBannedList(int iPad, eTMSAction action = (eTMSAction)0,
bool bCallback = false) {}
C4JStringTable *GetStringTable() { return NULL;}
C4JStringTable* GetStringTable() { return NULL; }
// original code
virtual void TemporaryCreateGameStart();
// original code
virtual void TemporaryCreateGameStart();
};
extern CConsoleMinecraftApp app;

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,9 @@ void ShutdownManager::StartShutdown() {}
void ShutdownManager::MainThreadHandleShutdown() {}
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/) {}
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/, C4JThread::EventArray * /*eventArray*/) {}
bool ShutdownManager::ShouldRun(ShutdownManager::EThreadId /*threadId*/) { return true; }
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/,
C4JThread::EventArray* /*eventArray*/) {}
bool ShutdownManager::ShouldRun(ShutdownManager::EThreadId /*threadId*/) {
return true;
}
void ShutdownManager::HasFinished(ShutdownManager::EThreadId /*threadId*/) {}

View file

@ -12,115 +12,105 @@
ConsoleUIController ui;
void ConsoleUIController::init(S32 w, S32 h)
{
void ConsoleUIController::init(S32 w, S32 h) {
#ifdef _ENABLEIGGY
// Shared init
preInit(w, h);
// Shared init
preInit(w, h);
//init
gdraw_funcs = gdraw_GL_CreateContext(w, h, 0);
// init
gdraw_funcs = gdraw_GL_CreateContext(w, h, 0);
if (!gdraw_funcs)
{
app.DebugPrintf("Failed to initialise GDraw GL!\n");
fprintf(stderr, "[Linux_UIController] Failed to initialise GDraw GL!\n");
// nott fatal for now
}
else
{
if (!gdraw_funcs) {
app.DebugPrintf("Failed to initialise GDraw GL!\n");
fprintf(stderr,
"[Linux_UIController] Failed to initialise GDraw GL!\n");
// nott fatal for now
} else {
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000,
16 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000,
128 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10,
32 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000, 16 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000, 128 * 1024 * 1024);
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10, 32 * 1024 * 1024);
IggySetGDraw(gdraw_funcs);
}
IggySetGDraw(gdraw_funcs);
}
postInit();
postInit();
#endif
}
void ConsoleUIController::render()
{
void ConsoleUIController::render() {
#ifdef _ENABLEIGGY
if (!gdraw_funcs)
return;
if (!gdraw_funcs) return;
gdraw_GL_SetTileOrigin(0, 0, 0);
gdraw_GL_SetTileOrigin(0, 0, 0);
// render
renderScenes();
// render
renderScenes();
gdraw_GL_NoMoreGDrawThisFrame();
gdraw_GL_NoMoreGDrawThisFrame();
#endif
}
void ConsoleUIController::beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion)
{
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
void ConsoleUIController::beginIggyCustomDraw4J(
IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) {
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
}
CustomDrawData *ConsoleUIController::setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region)
{
CustomDrawData *customDrawRegion = new CustomDrawData();
customDrawRegion->x0 = region->x0;
customDrawRegion->x1 = region->x1;
customDrawRegion->y0 = region->y0;
customDrawRegion->y1 = region->y1;
CustomDrawData* ConsoleUIController::setupCustomDraw(
UIScene* scene, IggyCustomDrawCallbackRegion* region) {
CustomDrawData* customDrawRegion = new CustomDrawData();
customDrawRegion->x0 = region->x0;
customDrawRegion->x1 = region->x1;
customDrawRegion->y0 = region->y0;
customDrawRegion->y1 = region->y1;
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
setupCustomDrawGameStateAndMatrices(scene, customDrawRegion);
setupCustomDrawGameStateAndMatrices(scene, customDrawRegion);
return customDrawRegion;
return customDrawRegion;
}
CustomDrawData *ConsoleUIController::calculateCustomDraw(IggyCustomDrawCallbackRegion *region)
{
CustomDrawData *customDrawRegion = new CustomDrawData();
customDrawRegion->x0 = region->x0;
customDrawRegion->x1 = region->x1;
customDrawRegion->y0 = region->y0;
customDrawRegion->y1 = region->y1;
CustomDrawData* ConsoleUIController::calculateCustomDraw(
IggyCustomDrawCallbackRegion* region) {
CustomDrawData* customDrawRegion = new CustomDrawData();
customDrawRegion->x0 = region->x0;
customDrawRegion->x1 = region->x1;
customDrawRegion->y0 = region->y0;
customDrawRegion->y1 = region->y1;
gdraw_GL_CalculateCustomDraw_4J(region, customDrawRegion->mat);
gdraw_GL_CalculateCustomDraw_4J(region, customDrawRegion->mat);
return customDrawRegion;
return customDrawRegion;
}
void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion *region)
{
endCustomDrawGameStateAndMatrices();
void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion* region) {
endCustomDrawGameStateAndMatrices();
gdraw_GL_EndCustomDraw(region);
gdraw_GL_EndCustomDraw(region);
}
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos)
{
gdraw_GL_SetTileOrigin(xPos, yPos, 0);
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) {
gdraw_GL_SetTileOrigin(xPos, yPos, 0);
}
GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId)
{
// todo impl
return nullptr;
GDrawTexture* ConsoleUIController::getSubstitutionTexture(int textureId) {
// todo impl
return nullptr;
}
void ConsoleUIController::destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle)
{
if (handle)
gdraw_GL_WrappedTextureDestroy(handle);
void ConsoleUIController::destroySubstitutionTexture(void* destroyCallBackData,
GDrawTexture* handle) {
if (handle) gdraw_GL_WrappedTextureDestroy(handle);
}
void ConsoleUIController::shutdown()
{
void ConsoleUIController::shutdown() {
#ifdef _ENABLEIGGY
if (gdraw_funcs)
{
gdraw_GL_DestroyContext();
gdraw_funcs = nullptr;
}
if (gdraw_funcs) {
gdraw_GL_DestroyContext();
gdraw_funcs = nullptr;
}
#endif
}

View file

@ -2,26 +2,29 @@
#include "../Common/UI/UIController.h"
class ConsoleUIController : public UIController
{
class ConsoleUIController : public UIController {
public:
void init(S32 w, S32 h);
void init(S32 w, S32 h);
void render();
void beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion);
virtual CustomDrawData *setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region);
virtual CustomDrawData *calculateCustomDraw(IggyCustomDrawCallbackRegion *region);
virtual void endCustomDraw(IggyCustomDrawCallbackRegion *region);
void render();
void beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion* region,
CustomDrawData* customDrawRegion);
virtual CustomDrawData* setupCustomDraw(
UIScene* scene, IggyCustomDrawCallbackRegion* region);
virtual CustomDrawData* calculateCustomDraw(
IggyCustomDrawCallbackRegion* region);
virtual void endCustomDraw(IggyCustomDrawCallbackRegion* region);
protected:
virtual void setTileOrigin(S32 xPos, S32 yPos);
virtual void setTileOrigin(S32 xPos, S32 yPos);
public:
GDrawTexture *getSubstitutionTexture(int textureId);
void destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle);
GDrawTexture* getSubstitutionTexture(int textureId);
void destroySubstitutionTexture(void* destroyCallBackData,
GDrawTexture* handle);
public:
void shutdown();
void shutdown();
};
extern ConsoleUIController ui;

View file

@ -5,17 +5,11 @@
#ifndef _SOCIAL_MANAGER_H
#define _SOCIAL_MANAGER_H
enum ESocialNetwork
{
eFacebook = 0,
eNumSocialNetworks
};
enum ESocialNetwork { eFacebook = 0, eNumSocialNetworks };
class CSocialManager
{
class CSocialManager {
public:
static CSocialManager* Instance()
{
static CSocialManager* Instance() {
static CSocialManager s_instance;
return &s_instance;
}
@ -23,21 +17,21 @@ public:
void Initialise() {}
void Tick() {}
bool RefreshPostingCapability() { return false; }
bool IsTitleAllowedToPostAnything() { return false; }
bool IsTitleAllowedToPostImages() { return false; }
bool IsTitleAllowedToPostLinks() { return false; }
bool AreAllUsersAllowedToPostImages() { return false; }
bool RefreshPostingCapability() { return false; }
bool IsTitleAllowedToPostAnything() { return false; }
bool IsTitleAllowedToPostImages() { return false; }
bool IsTitleAllowedToPostLinks() { return false; }
bool AreAllUsersAllowedToPostImages() { return false; }
bool PostLinkToSocialNetwork( ESocialNetwork, DWORD, bool ) { return false; }
bool PostImageToSocialNetwork( ESocialNetwork, DWORD, bool ) { return false; }
bool PostLinkToSocialNetwork(ESocialNetwork, DWORD, bool) { return false; }
bool PostImageToSocialNetwork(ESocialNetwork, DWORD, bool) { return false; }
void SetSocialPostText( const WCHAR*, const WCHAR*, const WCHAR* ) {}
void SetSocialPostText(const WCHAR*, const WCHAR*, const WCHAR*) {}
private:
CSocialManager() {}
CSocialManager( const CSocialManager& );
CSocialManager& operator=( const CSocialManager& );
CSocialManager(const CSocialManager&);
CSocialManager& operator=(const CSocialManager&);
};
#endif // _SOCIAL_MANAGER_H
#endif // _SOCIAL_MANAGER_H

View file

@ -11,334 +11,413 @@
#include "DirectXMath.h"
namespace DirectX
{
namespace DirectX {
enum ContainmentType
{
DISJOINT = 0,
INTERSECTS = 1,
CONTAINS = 2
};
enum ContainmentType { DISJOINT = 0, INTERSECTS = 1, CONTAINS = 2 };
enum PlaneIntersectionType
{
FRONT = 0,
INTERSECTING = 1,
BACK = 2
};
enum PlaneIntersectionType { FRONT = 0, INTERSECTING = 1, BACK = 2 };
struct BoundingBox;
struct BoundingOrientedBox;
struct BoundingFrustum;
struct BoundingBox;
struct BoundingOrientedBox;
struct BoundingFrustum;
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4324 4820)
// C4324: alignment padding warnings
// C4820: Off by default noise
#pragma warning(disable : 4324 4820)
// C4324: alignment padding warnings
// C4820: Off by default noise
#endif
//-------------------------------------------------------------------------------------
// Bounding sphere
//-------------------------------------------------------------------------------------
struct BoundingSphere
{
XMFLOAT3 Center; // Center of the sphere.
float Radius; // Radius of the sphere.
// Creators
BoundingSphere() noexcept : Center(0, 0, 0), Radius(1.f) {}
BoundingSphere(const BoundingSphere&) = default;
BoundingSphere& operator=(const BoundingSphere&) = default;
BoundingSphere(BoundingSphere&&) = default;
BoundingSphere& operator=(BoundingSphere&&) = default;
constexpr BoundingSphere(_In_ const XMFLOAT3& center, _In_ float radius) noexcept
: Center(center), Radius(radius) {}
// Methods
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out, _In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
// Transform the sphere
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sh) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
// Triangle-sphere test
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-sphere test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
// Ray-sphere test
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test sphere against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateMerged(_Out_ BoundingSphere& Out, _In_ const BoundingSphere& S1, _In_ const BoundingSphere& S2) noexcept;
static void CreateFromBoundingBox(_Out_ BoundingSphere& Out, _In_ const BoundingBox& box) noexcept;
static void CreateFromBoundingBox(_Out_ BoundingSphere& Out, _In_ const BoundingOrientedBox& box) noexcept;
static void CreateFromPoints(_Out_ BoundingSphere& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3) + Stride * (Count - 1)) const XMFLOAT3* pPoints, _In_ size_t Stride) noexcept;
static void CreateFromFrustum(_Out_ BoundingSphere& Out, _In_ const BoundingFrustum& fr) noexcept;
};
//-------------------------------------------------------------------------------------
// Axis-aligned bounding box
//-------------------------------------------------------------------------------------
struct BoundingBox
{
static constexpr size_t CORNER_COUNT = 8;
XMFLOAT3 Center; // Center of the box.
XMFLOAT3 Extents; // Distance from the center to each side.
// Creators
BoundingBox() noexcept : Center(0, 0, 0), Extents(1.f, 1.f, 1.f) {}
BoundingBox(const BoundingBox&) = default;
BoundingBox& operator=(const BoundingBox&) = default;
BoundingBox(BoundingBox&&) = default;
BoundingBox& operator=(BoundingBox&&) = default;
constexpr BoundingBox(_In_ const XMFLOAT3& center, _In_ const XMFLOAT3& extents) noexcept
: Center(center), Extents(extents) {}
// Methods
void XM_CALLCONV Transform(_Out_ BoundingBox& Out, _In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingBox& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
// Gets the 8 corners of the box
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sh) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
// Triangle-Box test
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-box test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
// Ray-Box test
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test box against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateMerged(_Out_ BoundingBox& Out, _In_ const BoundingBox& b1, _In_ const BoundingBox& b2) noexcept;
static void CreateFromSphere(_Out_ BoundingBox& Out, _In_ const BoundingSphere& sh) noexcept;
static void XM_CALLCONV CreateFromPoints(_Out_ BoundingBox& Out, _In_ FXMVECTOR pt1, _In_ FXMVECTOR pt2) noexcept;
static void CreateFromPoints(_Out_ BoundingBox& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3) + Stride * (Count - 1)) const XMFLOAT3* pPoints, _In_ size_t Stride) noexcept;
};
//-------------------------------------------------------------------------------------
// Oriented bounding box
//-------------------------------------------------------------------------------------
struct BoundingOrientedBox
{
static constexpr size_t CORNER_COUNT = 8;
XMFLOAT3 Center; // Center of the box.
XMFLOAT3 Extents; // Distance from the center to each side.
XMFLOAT4 Orientation; // Unit quaternion representing rotation (box -> world).
// Creators
BoundingOrientedBox() noexcept : Center(0, 0, 0), Extents(1.f, 1.f, 1.f), Orientation(0, 0, 0, 1.f) {}
BoundingOrientedBox(const BoundingOrientedBox&) = default;
BoundingOrientedBox& operator=(const BoundingOrientedBox&) = default;
BoundingOrientedBox(BoundingOrientedBox&&) = default;
BoundingOrientedBox& operator=(BoundingOrientedBox&&) = default;
constexpr BoundingOrientedBox(_In_ const XMFLOAT3& center, _In_ const XMFLOAT3& extents, _In_ const XMFLOAT4& orientation) noexcept
: Center(center), Extents(extents), Orientation(orientation) {}
// Methods
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out, _In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
// Gets the 8 corners of the box
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sh) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
// Triangle-OrientedBox test
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-OrientedBox test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
// Ray-OrientedBox test
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test OrientedBox against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateFromBoundingBox(_Out_ BoundingOrientedBox& Out, _In_ const BoundingBox& box) noexcept;
static void CreateFromPoints(_Out_ BoundingOrientedBox& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3) + Stride * (Count - 1)) const XMFLOAT3* pPoints, _In_ size_t Stride) noexcept;
};
//-------------------------------------------------------------------------------------
// Bounding frustum
//-------------------------------------------------------------------------------------
struct BoundingFrustum
{
static constexpr size_t CORNER_COUNT = 8;
XMFLOAT3 Origin; // Origin of the frustum (and projection).
XMFLOAT4 Orientation; // Quaternion representing rotation.
float RightSlope; // Positive X (X/Z)
float LeftSlope; // Negative X
float TopSlope; // Positive Y (Y/Z)
float BottomSlope; // Negative Y
float Near, Far; // Z of the near plane and far plane.
// Creators
BoundingFrustum() noexcept :
Origin(0, 0, 0), Orientation(0, 0, 0, 1.f), RightSlope(1.f), LeftSlope(-1.f),
TopSlope(1.f), BottomSlope(-1.f), Near(0), Far(1.f) {}
BoundingFrustum(const BoundingFrustum&) = default;
BoundingFrustum& operator=(const BoundingFrustum&) = default;
BoundingFrustum(BoundingFrustum&&) = default;
BoundingFrustum& operator=(BoundingFrustum&&) = default;
constexpr BoundingFrustum(_In_ const XMFLOAT3& origin, _In_ const XMFLOAT4& orientation,
_In_ float rightSlope, _In_ float leftSlope, _In_ float topSlope, _In_ float bottomSlope,
_In_ float nearPlane, _In_ float farPlane) noexcept
: Origin(origin), Orientation(orientation),
RightSlope(rightSlope), LeftSlope(leftSlope), TopSlope(topSlope), BottomSlope(bottomSlope),
Near(nearPlane), Far(farPlane) {}
BoundingFrustum(_In_ CXMMATRIX Projection, bool rhcoords = false) noexcept;
// Methods
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out, _In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
// Gets the 8 corners of the frustum
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sp) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
// Frustum-Frustum test
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2) const noexcept;
// Triangle-Frustum test
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-Frustum test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR rayOrigin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
// Ray-Frustum test
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test frustum against six planes (see BoundingFrustum::GetPlanes)
void GetPlanes(_Out_opt_ XMVECTOR* NearPlane, _Out_opt_ XMVECTOR* FarPlane, _Out_opt_ XMVECTOR* RightPlane,
_Out_opt_ XMVECTOR* LeftPlane, _Out_opt_ XMVECTOR* TopPlane, _Out_opt_ XMVECTOR* BottomPlane) const noexcept;
// Create 6 Planes representation of Frustum
// Static methods
static void XM_CALLCONV CreateFromMatrix(_Out_ BoundingFrustum& Out, _In_ FXMMATRIX Projection, bool rhcoords = false) noexcept;
};
//-----------------------------------------------------------------------------
// Triangle intersection testing routines.
//-----------------------------------------------------------------------------
namespace TriangleTests
{
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _In_ FXMVECTOR V0, _In_ GXMVECTOR V1, _In_ HXMVECTOR V2, _Out_ float& Dist) noexcept;
// Ray-Triangle
bool XM_CALLCONV Intersects(_In_ FXMVECTOR A0, _In_ FXMVECTOR A1, _In_ FXMVECTOR A2, _In_ GXMVECTOR B0, _In_ HXMVECTOR B1, _In_ HXMVECTOR B2) noexcept;
// Triangle-Triangle
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2, _In_ GXMVECTOR Plane) noexcept;
// Plane-Triangle
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2,
//-------------------------------------------------------------------------------------
// Bounding sphere
//-------------------------------------------------------------------------------------
struct BoundingSphere {
XMFLOAT3 Center; // Center of the sphere.
float Radius; // Radius of the sphere.
// Creators
BoundingSphere() noexcept : Center(0, 0, 0), Radius(1.f) {}
BoundingSphere(const BoundingSphere&) = default;
BoundingSphere& operator=(const BoundingSphere&) = default;
BoundingSphere(BoundingSphere&&) = default;
BoundingSphere& operator=(BoundingSphere&&) = default;
constexpr BoundingSphere(_In_ const XMFLOAT3& center,
_In_ float radius) noexcept
: Center(center), Radius(radius) {}
// Methods
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out,
_In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out, _In_ float Scale,
_In_ FXMVECTOR Rotation,
_In_ FXMVECTOR Translation) const noexcept;
// Transform the sphere
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sh) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(
_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
// Triangle-sphere test
PlaneIntersectionType XM_CALLCONV
Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-sphere test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
_Out_ float& Dist) const noexcept;
// Ray-sphere test
ContainmentType XM_CALLCONV
ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1,
_In_ FXMVECTOR Plane2, _In_ GXMVECTOR Plane3,
_In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test sphere against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateMerged(_Out_ BoundingSphere& Out,
_In_ const BoundingSphere& S1,
_In_ const BoundingSphere& S2) noexcept;
static void CreateFromBoundingBox(_Out_ BoundingSphere& Out,
_In_ const BoundingBox& box) noexcept;
static void CreateFromBoundingBox(
_Out_ BoundingSphere& Out,
_In_ const BoundingOrientedBox& box) noexcept;
static void CreateFromPoints(_Out_ BoundingSphere& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3) +
Stride * (Count - 1))
const XMFLOAT3* pPoints,
_In_ size_t Stride) noexcept;
static void CreateFromFrustum(_Out_ BoundingSphere& Out,
_In_ const BoundingFrustum& fr) noexcept;
};
//-------------------------------------------------------------------------------------
// Axis-aligned bounding box
//-------------------------------------------------------------------------------------
struct BoundingBox {
static constexpr size_t CORNER_COUNT = 8;
XMFLOAT3 Center; // Center of the box.
XMFLOAT3 Extents; // Distance from the center to each side.
// Creators
BoundingBox() noexcept : Center(0, 0, 0), Extents(1.f, 1.f, 1.f) {}
BoundingBox(const BoundingBox&) = default;
BoundingBox& operator=(const BoundingBox&) = default;
BoundingBox(BoundingBox&&) = default;
BoundingBox& operator=(BoundingBox&&) = default;
constexpr BoundingBox(_In_ const XMFLOAT3& center,
_In_ const XMFLOAT3& extents) noexcept
: Center(center), Extents(extents) {}
// Methods
void XM_CALLCONV Transform(_Out_ BoundingBox& Out,
_In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingBox& Out, _In_ float Scale,
_In_ FXMVECTOR Rotation,
_In_ FXMVECTOR Translation) const noexcept;
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
// Gets the 8 corners of the box
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sh) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(
_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
// Triangle-Box test
PlaneIntersectionType XM_CALLCONV
Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-box test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
_Out_ float& Dist) const noexcept;
// Ray-Box test
ContainmentType XM_CALLCONV
ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1,
_In_ FXMVECTOR Plane2, _In_ GXMVECTOR Plane3,
_In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test box against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateMerged(_Out_ BoundingBox& Out, _In_ const BoundingBox& b1,
_In_ const BoundingBox& b2) noexcept;
static void CreateFromSphere(_Out_ BoundingBox& Out,
_In_ const BoundingSphere& sh) noexcept;
static void XM_CALLCONV CreateFromPoints(_Out_ BoundingBox& Out,
_In_ FXMVECTOR pt1,
_In_ FXMVECTOR pt2) noexcept;
static void CreateFromPoints(_Out_ BoundingBox& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3) +
Stride * (Count - 1))
const XMFLOAT3* pPoints,
_In_ size_t Stride) noexcept;
};
//-------------------------------------------------------------------------------------
// Oriented bounding box
//-------------------------------------------------------------------------------------
struct BoundingOrientedBox {
static constexpr size_t CORNER_COUNT = 8;
XMFLOAT3 Center; // Center of the box.
XMFLOAT3 Extents; // Distance from the center to each side.
XMFLOAT4
Orientation; // Unit quaternion representing rotation (box -> world).
// Creators
BoundingOrientedBox() noexcept
: Center(0, 0, 0), Extents(1.f, 1.f, 1.f), Orientation(0, 0, 0, 1.f) {}
BoundingOrientedBox(const BoundingOrientedBox&) = default;
BoundingOrientedBox& operator=(const BoundingOrientedBox&) = default;
BoundingOrientedBox(BoundingOrientedBox&&) = default;
BoundingOrientedBox& operator=(BoundingOrientedBox&&) = default;
constexpr BoundingOrientedBox(_In_ const XMFLOAT3& center,
_In_ const XMFLOAT3& extents,
_In_ const XMFLOAT4& orientation) noexcept
: Center(center), Extents(extents), Orientation(orientation) {}
// Methods
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out,
_In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out, _In_ float Scale,
_In_ FXMVECTOR Rotation,
_In_ FXMVECTOR Translation) const noexcept;
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
// Gets the 8 corners of the box
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sh) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(
_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
// Triangle-OrientedBox test
PlaneIntersectionType XM_CALLCONV
Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-OrientedBox test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
_Out_ float& Dist) const noexcept;
// Ray-OrientedBox test
ContainmentType XM_CALLCONV
ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1,
_In_ FXMVECTOR Plane2, _In_ GXMVECTOR Plane3,
_In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test OrientedBox against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateFromBoundingBox(_Out_ BoundingOrientedBox& Out,
_In_ const BoundingBox& box) noexcept;
static void CreateFromPoints(_Out_ BoundingOrientedBox& Out,
_In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3) +
Stride * (Count - 1))
const XMFLOAT3* pPoints,
_In_ size_t Stride) noexcept;
};
//-------------------------------------------------------------------------------------
// Bounding frustum
//-------------------------------------------------------------------------------------
struct BoundingFrustum {
static constexpr size_t CORNER_COUNT = 8;
XMFLOAT3 Origin; // Origin of the frustum (and projection).
XMFLOAT4 Orientation; // Quaternion representing rotation.
float RightSlope; // Positive X (X/Z)
float LeftSlope; // Negative X
float TopSlope; // Positive Y (Y/Z)
float BottomSlope; // Negative Y
float Near, Far; // Z of the near plane and far plane.
// Creators
BoundingFrustum() noexcept
: Origin(0, 0, 0),
Orientation(0, 0, 0, 1.f),
RightSlope(1.f),
LeftSlope(-1.f),
TopSlope(1.f),
BottomSlope(-1.f),
Near(0),
Far(1.f) {}
BoundingFrustum(const BoundingFrustum&) = default;
BoundingFrustum& operator=(const BoundingFrustum&) = default;
BoundingFrustum(BoundingFrustum&&) = default;
BoundingFrustum& operator=(BoundingFrustum&&) = default;
constexpr BoundingFrustum(_In_ const XMFLOAT3& origin,
_In_ const XMFLOAT4& orientation,
_In_ float rightSlope, _In_ float leftSlope,
_In_ float topSlope, _In_ float bottomSlope,
_In_ float nearPlane,
_In_ float farPlane) noexcept
: Origin(origin),
Orientation(orientation),
RightSlope(rightSlope),
LeftSlope(leftSlope),
TopSlope(topSlope),
BottomSlope(bottomSlope),
Near(nearPlane),
Far(farPlane) {}
BoundingFrustum(_In_ CXMMATRIX Projection, bool rhcoords = false) noexcept;
// Methods
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out,
_In_ FXMMATRIX M) const noexcept;
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out, _In_ float Scale,
_In_ FXMVECTOR Rotation,
_In_ FXMVECTOR Translation) const noexcept;
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
// Gets the 8 corners of the frustum
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
ContainmentType Contains(_In_ const BoundingSphere& sp) const noexcept;
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
ContainmentType Contains(
_In_ const BoundingOrientedBox& box) const noexcept;
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
// Frustum-Frustum test
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
bool Intersects(_In_ const BoundingBox& box) const noexcept;
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
bool Intersects(_In_ const BoundingFrustum& fr) const noexcept;
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
_In_ FXMVECTOR V2) const noexcept;
// Triangle-Frustum test
PlaneIntersectionType XM_CALLCONV
Intersects(_In_ FXMVECTOR Plane) const noexcept;
// Plane-Frustum test
bool XM_CALLCONV Intersects(_In_ FXMVECTOR rayOrigin,
_In_ FXMVECTOR Direction,
_Out_ float& Dist) const noexcept;
// Ray-Frustum test
ContainmentType XM_CALLCONV
ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1,
_In_ FXMVECTOR Plane2, _In_ GXMVECTOR Plane3,
_In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
// Test frustum against six planes (see BoundingFrustum::GetPlanes)
void GetPlanes(_Out_opt_ XMVECTOR* NearPlane, _Out_opt_ XMVECTOR* FarPlane,
_Out_opt_ XMVECTOR* RightPlane,
_Out_opt_ XMVECTOR* LeftPlane, _Out_opt_ XMVECTOR* TopPlane,
_Out_opt_ XMVECTOR* BottomPlane) const noexcept;
// Create 6 Planes representation of Frustum
// Static methods
static void XM_CALLCONV CreateFromMatrix(_Out_ BoundingFrustum& Out,
_In_ FXMMATRIX Projection,
bool rhcoords = false) noexcept;
};
//-----------------------------------------------------------------------------
// Triangle intersection testing routines.
//-----------------------------------------------------------------------------
namespace TriangleTests {
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
_In_ FXMVECTOR V0, _In_ GXMVECTOR V1,
_In_ HXMVECTOR V2, _Out_ float& Dist) noexcept;
// Ray-Triangle
bool XM_CALLCONV Intersects(_In_ FXMVECTOR A0, _In_ FXMVECTOR A1,
_In_ FXMVECTOR A2, _In_ GXMVECTOR B0,
_In_ HXMVECTOR B1, _In_ HXMVECTOR B2) noexcept;
// Triangle-Triangle
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR V0,
_In_ FXMVECTOR V1,
_In_ FXMVECTOR V2,
_In_ GXMVECTOR Plane) noexcept;
// Plane-Triangle
ContainmentType XM_CALLCONV
ContainedBy(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2,
_In_ GXMVECTOR Plane0, _In_ HXMVECTOR Plane1, _In_ HXMVECTOR Plane2,
_In_ CXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5) noexcept;
// Test a triangle against six planes at once (see BoundingFrustum::GetPlanes)
}
_In_ CXMVECTOR Plane3, _In_ CXMVECTOR Plane4,
_In_ CXMVECTOR Plane5) noexcept;
// Test a triangle against six planes at once (see BoundingFrustum::GetPlanes)
} // namespace TriangleTests
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/****************************************************************************
*
* Implementation
*
****************************************************************************/
/****************************************************************************
*
* Implementation
*
****************************************************************************/
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4068 4365 4616 6001)
// C4068/4616: ignore unknown pragmas
// C4365: Off by default noise
// C6001: False positives
// C4068/4616: ignore unknown pragmas
// C4365: Off by default noise
// C6001: False positives
#endif
#ifdef _PREFAST_
@ -366,5 +445,4 @@ namespace DirectX
#pragma warning(pop)
#endif
} // namespace DirectX
} // namespace DirectX

View file

@ -11,302 +11,490 @@
#include "DirectXMath.h"
namespace DirectX
{
namespace DirectX {
namespace Colors
{
// Standard colors (Red/Green/Blue/Alpha) in sRGB colorspace
XMGLOBALCONST XMVECTORF32 AliceBlue = { { { 0.941176534f, 0.972549081f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 AntiqueWhite = { { { 0.980392218f, 0.921568692f, 0.843137324f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Aqua = { { { 0.f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Aquamarine = { { { 0.498039246f, 1.f, 0.831372619f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Azure = { { { 0.941176534f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Beige = { { { 0.960784376f, 0.960784376f, 0.862745166f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Bisque = { { { 1.f, 0.894117713f, 0.768627524f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Black = { { { 0.f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 BlanchedAlmond = { { { 1.f, 0.921568692f, 0.803921640f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Blue = { { { 0.f, 0.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 BlueViolet = { { { 0.541176498f, 0.168627456f, 0.886274576f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Brown = { { { 0.647058845f, 0.164705887f, 0.164705887f, 1.f } } };
XMGLOBALCONST XMVECTORF32 BurlyWood = { { { 0.870588303f, 0.721568644f, 0.529411793f, 1.f } } };
XMGLOBALCONST XMVECTORF32 CadetBlue = { { { 0.372549027f, 0.619607866f, 0.627451003f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Chartreuse = { { { 0.498039246f, 1.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Chocolate = { { { 0.823529482f, 0.411764741f, 0.117647067f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Coral = { { { 1.f, 0.498039246f, 0.313725501f, 1.f } } };
XMGLOBALCONST XMVECTORF32 CornflowerBlue = { { { 0.392156899f, 0.584313750f, 0.929411829f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Cornsilk = { { { 1.f, 0.972549081f, 0.862745166f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Crimson = { { { 0.862745166f, 0.078431375f, 0.235294133f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Cyan = { { { 0.f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkBlue = { { { 0.f, 0.f, 0.545098066f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkCyan = { { { 0.f, 0.545098066f, 0.545098066f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = { { { 0.721568644f, 0.525490224f, 0.043137256f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkGray = { { { 0.662745118f, 0.662745118f, 0.662745118f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkGreen = { { { 0.f, 0.392156899f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkKhaki = { { { 0.741176486f, 0.717647076f, 0.419607878f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkMagenta = { { { 0.545098066f, 0.f, 0.545098066f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkOliveGreen = { { { 0.333333343f, 0.419607878f, 0.184313729f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkOrange = { { { 1.f, 0.549019635f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkOrchid = { { { 0.600000024f, 0.196078449f, 0.800000072f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkRed = { { { 0.545098066f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSalmon = { { { 0.913725555f, 0.588235319f, 0.478431404f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = { { { 0.560784340f, 0.737254918f, 0.545098066f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = { { { 0.282352954f, 0.239215702f, 0.545098066f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSlateGray = { { { 0.184313729f, 0.309803933f, 0.309803933f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkTurquoise = { { { 0.f, 0.807843208f, 0.819607913f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkViolet = { { { 0.580392182f, 0.f, 0.827451050f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DeepPink = { { { 1.f, 0.078431375f, 0.576470613f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DeepSkyBlue = { { { 0.f, 0.749019623f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DimGray = { { { 0.411764741f, 0.411764741f, 0.411764741f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DodgerBlue = { { { 0.117647067f, 0.564705908f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Firebrick = { { { 0.698039234f, 0.133333340f, 0.133333340f, 1.f } } };
XMGLOBALCONST XMVECTORF32 FloralWhite = { { { 1.f, 0.980392218f, 0.941176534f, 1.f } } };
XMGLOBALCONST XMVECTORF32 ForestGreen = { { { 0.133333340f, 0.545098066f, 0.133333340f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Fuchsia = { { { 1.f, 0.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Gainsboro = { { { 0.862745166f, 0.862745166f, 0.862745166f, 1.f } } };
XMGLOBALCONST XMVECTORF32 GhostWhite = { { { 0.972549081f, 0.972549081f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Gold = { { { 1.f, 0.843137324f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Goldenrod = { { { 0.854902029f, 0.647058845f, 0.125490203f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Gray = { { { 0.501960814f, 0.501960814f, 0.501960814f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Green = { { { 0.f, 0.501960814f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 GreenYellow = { { { 0.678431392f, 1.f, 0.184313729f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Honeydew = { { { 0.941176534f, 1.f, 0.941176534f, 1.f } } };
XMGLOBALCONST XMVECTORF32 HotPink = { { { 1.f, 0.411764741f, 0.705882370f, 1.f } } };
XMGLOBALCONST XMVECTORF32 IndianRed = { { { 0.803921640f, 0.360784322f, 0.360784322f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Indigo = { { { 0.294117659f, 0.f, 0.509803951f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Ivory = { { { 1.f, 1.f, 0.941176534f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Khaki = { { { 0.941176534f, 0.901960850f, 0.549019635f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Lavender = { { { 0.901960850f, 0.901960850f, 0.980392218f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LavenderBlush = { { { 1.f, 0.941176534f, 0.960784376f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LawnGreen = { { { 0.486274540f, 0.988235354f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LemonChiffon = { { { 1.f, 0.980392218f, 0.803921640f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightBlue = { { { 0.678431392f, 0.847058892f, 0.901960850f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightCoral = { { { 0.941176534f, 0.501960814f, 0.501960814f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightCyan = { { { 0.878431439f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = { { { 0.980392218f, 0.980392218f, 0.823529482f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightGray = { { { 0.827451050f, 0.827451050f, 0.827451050f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightGreen = { { { 0.564705908f, 0.933333397f, 0.564705908f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightPink = { { { 1.f, 0.713725507f, 0.756862819f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSalmon = { { { 1.f, 0.627451003f, 0.478431404f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSeaGreen = { { { 0.125490203f, 0.698039234f, 0.666666687f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSkyBlue = { { { 0.529411793f, 0.807843208f, 0.980392218f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSlateGray = { { { 0.466666698f, 0.533333361f, 0.600000024f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSteelBlue = { { { 0.690196097f, 0.768627524f, 0.870588303f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightYellow = { { { 1.f, 1.f, 0.878431439f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Lime = { { { 0.f, 1.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LimeGreen = { { { 0.196078449f, 0.803921640f, 0.196078449f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Linen = { { { 0.980392218f, 0.941176534f, 0.901960850f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Magenta = { { { 1.f, 0.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Maroon = { { { 0.501960814f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumAquamarine = { { { 0.400000036f, 0.803921640f, 0.666666687f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumBlue = { { { 0.f, 0.f, 0.803921640f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumOrchid = { { { 0.729411781f, 0.333333343f, 0.827451050f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumPurple = { { { 0.576470613f, 0.439215720f, 0.858823597f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = { { { 0.235294133f, 0.701960802f, 0.443137288f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = { { { 0.482352972f, 0.407843173f, 0.933333397f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = { { { 0.f, 0.980392218f, 0.603921592f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumTurquoise = { { { 0.282352954f, 0.819607913f, 0.800000072f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumVioletRed = { { { 0.780392230f, 0.082352944f, 0.521568656f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MidnightBlue = { { { 0.098039225f, 0.098039225f, 0.439215720f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MintCream = { { { 0.960784376f, 1.f, 0.980392218f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MistyRose = { { { 1.f, 0.894117713f, 0.882353008f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Moccasin = { { { 1.f, 0.894117713f, 0.709803939f, 1.f } } };
XMGLOBALCONST XMVECTORF32 NavajoWhite = { { { 1.f, 0.870588303f, 0.678431392f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Navy = { { { 0.f, 0.f, 0.501960814f, 1.f } } };
XMGLOBALCONST XMVECTORF32 OldLace = { { { 0.992156923f, 0.960784376f, 0.901960850f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Olive = { { { 0.501960814f, 0.501960814f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 OliveDrab = { { { 0.419607878f, 0.556862772f, 0.137254909f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Orange = { { { 1.f, 0.647058845f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 OrangeRed = { { { 1.f, 0.270588249f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Orchid = { { { 0.854902029f, 0.439215720f, 0.839215755f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = { { { 0.933333397f, 0.909803987f, 0.666666687f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleGreen = { { { 0.596078455f, 0.984313786f, 0.596078455f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleTurquoise = { { { 0.686274529f, 0.933333397f, 0.933333397f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleVioletRed = { { { 0.858823597f, 0.439215720f, 0.576470613f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PapayaWhip = { { { 1.f, 0.937254965f, 0.835294187f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PeachPuff = { { { 1.f, 0.854902029f, 0.725490212f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Peru = { { { 0.803921640f, 0.521568656f, 0.247058839f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Pink = { { { 1.f, 0.752941251f, 0.796078503f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Plum = { { { 0.866666734f, 0.627451003f, 0.866666734f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PowderBlue = { { { 0.690196097f, 0.878431439f, 0.901960850f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Purple = { { { 0.501960814f, 0.f, 0.501960814f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Red = { { { 1.f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 RosyBrown = { { { 0.737254918f, 0.560784340f, 0.560784340f, 1.f } } };
XMGLOBALCONST XMVECTORF32 RoyalBlue = { { { 0.254901975f, 0.411764741f, 0.882353008f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SaddleBrown = { { { 0.545098066f, 0.270588249f, 0.074509807f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Salmon = { { { 0.980392218f, 0.501960814f, 0.447058856f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SandyBrown = { { { 0.956862807f, 0.643137276f, 0.376470625f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SeaGreen = { { { 0.180392161f, 0.545098066f, 0.341176480f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SeaShell = { { { 1.f, 0.960784376f, 0.933333397f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Sienna = { { { 0.627451003f, 0.321568638f, 0.176470593f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Silver = { { { 0.752941251f, 0.752941251f, 0.752941251f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SkyBlue = { { { 0.529411793f, 0.807843208f, 0.921568692f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SlateBlue = { { { 0.415686309f, 0.352941185f, 0.803921640f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SlateGray = { { { 0.439215720f, 0.501960814f, 0.564705908f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Snow = { { { 1.f, 0.980392218f, 0.980392218f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SpringGreen = { { { 0.f, 1.f, 0.498039246f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SteelBlue = { { { 0.274509817f, 0.509803951f, 0.705882370f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Tan = { { { 0.823529482f, 0.705882370f, 0.549019635f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Teal = { { { 0.f, 0.501960814f, 0.501960814f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Thistle = { { { 0.847058892f, 0.749019623f, 0.847058892f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Tomato = { { { 1.f, 0.388235331f, 0.278431386f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Transparent = { { { 0.f, 0.f, 0.f, 0.f } } };
XMGLOBALCONST XMVECTORF32 Turquoise = { { { 0.250980407f, 0.878431439f, 0.815686345f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Violet = { { { 0.933333397f, 0.509803951f, 0.933333397f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Wheat = { { { 0.960784376f, 0.870588303f, 0.701960802f, 1.f } } };
XMGLOBALCONST XMVECTORF32 White = { { { 1.f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 WhiteSmoke = { { { 0.960784376f, 0.960784376f, 0.960784376f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Yellow = { { { 1.f, 1.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 YellowGreen = { { { 0.603921592f, 0.803921640f, 0.196078449f, 1.f } } };
namespace Colors {
// Standard colors (Red/Green/Blue/Alpha) in sRGB colorspace
XMGLOBALCONST XMVECTORF32 AliceBlue = {
{{0.941176534f, 0.972549081f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 AntiqueWhite = {
{{0.980392218f, 0.921568692f, 0.843137324f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Aqua = {{{0.f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Aquamarine = {
{{0.498039246f, 1.f, 0.831372619f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Azure = {{{0.941176534f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Beige = {
{{0.960784376f, 0.960784376f, 0.862745166f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Bisque = {{{1.f, 0.894117713f, 0.768627524f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Black = {{{0.f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 BlanchedAlmond = {
{{1.f, 0.921568692f, 0.803921640f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Blue = {{{0.f, 0.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 BlueViolet = {
{{0.541176498f, 0.168627456f, 0.886274576f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Brown = {
{{0.647058845f, 0.164705887f, 0.164705887f, 1.f}}};
XMGLOBALCONST XMVECTORF32 BurlyWood = {
{{0.870588303f, 0.721568644f, 0.529411793f, 1.f}}};
XMGLOBALCONST XMVECTORF32 CadetBlue = {
{{0.372549027f, 0.619607866f, 0.627451003f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Chartreuse = {{{0.498039246f, 1.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Chocolate = {
{{0.823529482f, 0.411764741f, 0.117647067f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Coral = {{{1.f, 0.498039246f, 0.313725501f, 1.f}}};
XMGLOBALCONST XMVECTORF32 CornflowerBlue = {
{{0.392156899f, 0.584313750f, 0.929411829f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Cornsilk = {{{1.f, 0.972549081f, 0.862745166f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Crimson = {
{{0.862745166f, 0.078431375f, 0.235294133f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Cyan = {{{0.f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkBlue = {{{0.f, 0.f, 0.545098066f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkCyan = {{{0.f, 0.545098066f, 0.545098066f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = {
{{0.721568644f, 0.525490224f, 0.043137256f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkGray = {
{{0.662745118f, 0.662745118f, 0.662745118f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkGreen = {{{0.f, 0.392156899f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkKhaki = {
{{0.741176486f, 0.717647076f, 0.419607878f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkMagenta = {
{{0.545098066f, 0.f, 0.545098066f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkOliveGreen = {
{{0.333333343f, 0.419607878f, 0.184313729f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkOrange = {{{1.f, 0.549019635f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkOrchid = {
{{0.600000024f, 0.196078449f, 0.800000072f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkRed = {{{0.545098066f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSalmon = {
{{0.913725555f, 0.588235319f, 0.478431404f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = {
{{0.560784340f, 0.737254918f, 0.545098066f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = {
{{0.282352954f, 0.239215702f, 0.545098066f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSlateGray = {
{{0.184313729f, 0.309803933f, 0.309803933f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkTurquoise = {
{{0.f, 0.807843208f, 0.819607913f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkViolet = {
{{0.580392182f, 0.f, 0.827451050f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DeepPink = {{{1.f, 0.078431375f, 0.576470613f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DeepSkyBlue = {{{0.f, 0.749019623f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DimGray = {
{{0.411764741f, 0.411764741f, 0.411764741f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DodgerBlue = {
{{0.117647067f, 0.564705908f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Firebrick = {
{{0.698039234f, 0.133333340f, 0.133333340f, 1.f}}};
XMGLOBALCONST XMVECTORF32 FloralWhite = {
{{1.f, 0.980392218f, 0.941176534f, 1.f}}};
XMGLOBALCONST XMVECTORF32 ForestGreen = {
{{0.133333340f, 0.545098066f, 0.133333340f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Fuchsia = {{{1.f, 0.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Gainsboro = {
{{0.862745166f, 0.862745166f, 0.862745166f, 1.f}}};
XMGLOBALCONST XMVECTORF32 GhostWhite = {
{{0.972549081f, 0.972549081f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Gold = {{{1.f, 0.843137324f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Goldenrod = {
{{0.854902029f, 0.647058845f, 0.125490203f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Gray = {
{{0.501960814f, 0.501960814f, 0.501960814f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Green = {{{0.f, 0.501960814f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 GreenYellow = {
{{0.678431392f, 1.f, 0.184313729f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Honeydew = {{{0.941176534f, 1.f, 0.941176534f, 1.f}}};
XMGLOBALCONST XMVECTORF32 HotPink = {{{1.f, 0.411764741f, 0.705882370f, 1.f}}};
XMGLOBALCONST XMVECTORF32 IndianRed = {
{{0.803921640f, 0.360784322f, 0.360784322f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Indigo = {{{0.294117659f, 0.f, 0.509803951f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Ivory = {{{1.f, 1.f, 0.941176534f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Khaki = {
{{0.941176534f, 0.901960850f, 0.549019635f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Lavender = {
{{0.901960850f, 0.901960850f, 0.980392218f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LavenderBlush = {
{{1.f, 0.941176534f, 0.960784376f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LawnGreen = {
{{0.486274540f, 0.988235354f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LemonChiffon = {
{{1.f, 0.980392218f, 0.803921640f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightBlue = {
{{0.678431392f, 0.847058892f, 0.901960850f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightCoral = {
{{0.941176534f, 0.501960814f, 0.501960814f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightCyan = {{{0.878431439f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = {
{{0.980392218f, 0.980392218f, 0.823529482f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightGray = {
{{0.827451050f, 0.827451050f, 0.827451050f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightGreen = {
{{0.564705908f, 0.933333397f, 0.564705908f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightPink = {
{{1.f, 0.713725507f, 0.756862819f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSalmon = {
{{1.f, 0.627451003f, 0.478431404f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSeaGreen = {
{{0.125490203f, 0.698039234f, 0.666666687f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSkyBlue = {
{{0.529411793f, 0.807843208f, 0.980392218f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSlateGray = {
{{0.466666698f, 0.533333361f, 0.600000024f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSteelBlue = {
{{0.690196097f, 0.768627524f, 0.870588303f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightYellow = {{{1.f, 1.f, 0.878431439f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Lime = {{{0.f, 1.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LimeGreen = {
{{0.196078449f, 0.803921640f, 0.196078449f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Linen = {
{{0.980392218f, 0.941176534f, 0.901960850f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Magenta = {{{1.f, 0.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Maroon = {{{0.501960814f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumAquamarine = {
{{0.400000036f, 0.803921640f, 0.666666687f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumBlue = {{{0.f, 0.f, 0.803921640f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumOrchid = {
{{0.729411781f, 0.333333343f, 0.827451050f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumPurple = {
{{0.576470613f, 0.439215720f, 0.858823597f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = {
{{0.235294133f, 0.701960802f, 0.443137288f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = {
{{0.482352972f, 0.407843173f, 0.933333397f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = {
{{0.f, 0.980392218f, 0.603921592f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumTurquoise = {
{{0.282352954f, 0.819607913f, 0.800000072f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumVioletRed = {
{{0.780392230f, 0.082352944f, 0.521568656f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MidnightBlue = {
{{0.098039225f, 0.098039225f, 0.439215720f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MintCream = {
{{0.960784376f, 1.f, 0.980392218f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MistyRose = {
{{1.f, 0.894117713f, 0.882353008f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Moccasin = {{{1.f, 0.894117713f, 0.709803939f, 1.f}}};
XMGLOBALCONST XMVECTORF32 NavajoWhite = {
{{1.f, 0.870588303f, 0.678431392f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Navy = {{{0.f, 0.f, 0.501960814f, 1.f}}};
XMGLOBALCONST XMVECTORF32 OldLace = {
{{0.992156923f, 0.960784376f, 0.901960850f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Olive = {{{0.501960814f, 0.501960814f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 OliveDrab = {
{{0.419607878f, 0.556862772f, 0.137254909f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Orange = {{{1.f, 0.647058845f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 OrangeRed = {{{1.f, 0.270588249f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Orchid = {
{{0.854902029f, 0.439215720f, 0.839215755f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = {
{{0.933333397f, 0.909803987f, 0.666666687f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleGreen = {
{{0.596078455f, 0.984313786f, 0.596078455f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleTurquoise = {
{{0.686274529f, 0.933333397f, 0.933333397f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleVioletRed = {
{{0.858823597f, 0.439215720f, 0.576470613f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PapayaWhip = {
{{1.f, 0.937254965f, 0.835294187f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PeachPuff = {
{{1.f, 0.854902029f, 0.725490212f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Peru = {
{{0.803921640f, 0.521568656f, 0.247058839f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Pink = {{{1.f, 0.752941251f, 0.796078503f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Plum = {
{{0.866666734f, 0.627451003f, 0.866666734f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PowderBlue = {
{{0.690196097f, 0.878431439f, 0.901960850f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Purple = {{{0.501960814f, 0.f, 0.501960814f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Red = {{{1.f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 RosyBrown = {
{{0.737254918f, 0.560784340f, 0.560784340f, 1.f}}};
XMGLOBALCONST XMVECTORF32 RoyalBlue = {
{{0.254901975f, 0.411764741f, 0.882353008f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SaddleBrown = {
{{0.545098066f, 0.270588249f, 0.074509807f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Salmon = {
{{0.980392218f, 0.501960814f, 0.447058856f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SandyBrown = {
{{0.956862807f, 0.643137276f, 0.376470625f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SeaGreen = {
{{0.180392161f, 0.545098066f, 0.341176480f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SeaShell = {{{1.f, 0.960784376f, 0.933333397f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Sienna = {
{{0.627451003f, 0.321568638f, 0.176470593f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Silver = {
{{0.752941251f, 0.752941251f, 0.752941251f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SkyBlue = {
{{0.529411793f, 0.807843208f, 0.921568692f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SlateBlue = {
{{0.415686309f, 0.352941185f, 0.803921640f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SlateGray = {
{{0.439215720f, 0.501960814f, 0.564705908f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Snow = {{{1.f, 0.980392218f, 0.980392218f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SpringGreen = {{{0.f, 1.f, 0.498039246f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SteelBlue = {
{{0.274509817f, 0.509803951f, 0.705882370f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Tan = {
{{0.823529482f, 0.705882370f, 0.549019635f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Teal = {{{0.f, 0.501960814f, 0.501960814f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Thistle = {
{{0.847058892f, 0.749019623f, 0.847058892f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Tomato = {{{1.f, 0.388235331f, 0.278431386f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Transparent = {{{0.f, 0.f, 0.f, 0.f}}};
XMGLOBALCONST XMVECTORF32 Turquoise = {
{{0.250980407f, 0.878431439f, 0.815686345f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Violet = {
{{0.933333397f, 0.509803951f, 0.933333397f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Wheat = {
{{0.960784376f, 0.870588303f, 0.701960802f, 1.f}}};
XMGLOBALCONST XMVECTORF32 White = {{{1.f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 WhiteSmoke = {
{{0.960784376f, 0.960784376f, 0.960784376f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Yellow = {{{1.f, 1.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 YellowGreen = {
{{0.603921592f, 0.803921640f, 0.196078449f, 1.f}}};
} // namespace Colors
} // namespace Colors
namespace ColorsLinear
{
// Standard colors (Red/Green/Blue/Alpha) in linear colorspace
XMGLOBALCONST XMVECTORF32 AliceBlue = { { { 0.871367335f, 0.938685894f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 AntiqueWhite = { { { 0.955973506f, 0.830770075f, 0.679542601f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Aqua = { { { 0.f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Aquamarine = { { { 0.212230787f, 1.f, 0.658374965f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Azure = { { { 0.871367335f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Beige = { { { 0.913098991f, 0.913098991f, 0.715693772f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Bisque = { { { 1.f, 0.775822461f, 0.552011609f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Black = { { { 0.f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 BlanchedAlmond = { { { 1.f, 0.830770075f, 0.610495746f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Blue = { { { 0.f, 0.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 BlueViolet = { { { 0.254152179f, 0.024157630f, 0.760524750f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Brown = { { { 0.376262218f, 0.023153365f, 0.023153365f, 1.f } } };
XMGLOBALCONST XMVECTORF32 BurlyWood = { { { 0.730461001f, 0.479320228f, 0.242281199f, 1.f } } };
XMGLOBALCONST XMVECTORF32 CadetBlue = { { { 0.114435382f, 0.341914445f, 0.351532698f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Chartreuse = { { { 0.212230787f, 1.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Chocolate = { { { 0.644479871f, 0.141263321f, 0.012983031f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Coral = { { { 1.f, 0.212230787f, 0.080219828f, 1.f } } };
XMGLOBALCONST XMVECTORF32 CornflowerBlue = { { { 0.127437726f, 0.300543845f, 0.846873462f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Cornsilk = { { { 1.f, 0.938685894f, 0.715693772f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Crimson = { { { 0.715693772f, 0.006995410f, 0.045186214f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Cyan = { { { 0.f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkBlue = { { { 0.f, 0.f, 0.258182913f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkCyan = { { { 0.f, 0.258182913f, 0.258182913f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = { { { 0.479320228f, 0.238397658f, 0.003346536f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkGray = { { { 0.396755308f, 0.396755308f, 0.396755308f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkGreen = { { { 0.f, 0.127437726f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkKhaki = { { { 0.508881450f, 0.473531544f, 0.147027299f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkMagenta = { { { 0.258182913f, 0.f, 0.258182913f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkOliveGreen = { { { 0.090841733f, 0.147027299f, 0.028426038f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkOrange = { { { 1.f, 0.262250721f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkOrchid = { { { 0.318546832f, 0.031896040f, 0.603827536f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkRed = { { { 0.258182913f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSalmon = { { { 0.814846814f, 0.304987371f, 0.194617867f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = { { { 0.274677366f, 0.502886593f, 0.258182913f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = { { { 0.064803280f, 0.046665095f, 0.258182913f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkSlateGray = { { { 0.028426038f, 0.078187428f, 0.078187428f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkTurquoise = { { { 0.f, 0.617206752f, 0.637597024f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DarkViolet = { { { 0.296138316f, 0.f, 0.651405811f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DeepPink = { { { 1.f, 0.006995410f, 0.291770697f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DeepSkyBlue = { { { 0.f, 0.520995677f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DimGray = { { { 0.141263321f, 0.141263321f, 0.141263321f, 1.f } } };
XMGLOBALCONST XMVECTORF32 DodgerBlue = { { { 0.012983031f, 0.278894335f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Firebrick = { { { 0.445201248f, 0.015996292f, 0.015996292f, 1.f } } };
XMGLOBALCONST XMVECTORF32 FloralWhite = { { { 1.f, 0.955973506f, 0.871367335f, 1.f } } };
XMGLOBALCONST XMVECTORF32 ForestGreen = { { { 0.015996292f, 0.258182913f, 0.015996292f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Fuchsia = { { { 1.f, 0.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Gainsboro = { { { 0.715693772f, 0.715693772f, 0.715693772f, 1.f } } };
XMGLOBALCONST XMVECTORF32 GhostWhite = { { { 0.938685894f, 0.938685894f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Gold = { { { 1.f, 0.679542601f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Goldenrod = { { { 0.701102138f, 0.376262218f, 0.014443844f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Gray = { { { 0.215860531f, 0.215860531f, 0.215860531f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Green = { { { 0.f, 0.215860531f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 GreenYellow = { { { 0.417885154f, 1.f, 0.028426038f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Honeydew = { { { 0.871367335f, 1.f, 0.871367335f, 1.f } } };
XMGLOBALCONST XMVECTORF32 HotPink = { { { 1.f, 0.141263321f, 0.456411064f, 1.f } } };
XMGLOBALCONST XMVECTORF32 IndianRed = { { { 0.610495746f, 0.107023112f, 0.107023112f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Indigo = { { { 0.070360109f, 0.f, 0.223227978f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Ivory = { { { 1.f, 1.f, 0.871367335f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Khaki = { { { 0.871367335f, 0.791298151f, 0.262250721f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Lavender = { { { 0.791298151f, 0.791298151f, 0.955973506f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LavenderBlush = { { { 1.f, 0.871367335f, 0.913098991f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LawnGreen = { { { 0.201556295f, 0.973445475f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LemonChiffon = { { { 1.f, 0.955973506f, 0.610495746f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightBlue = { { { 0.417885154f, 0.686685443f, 0.791298151f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightCoral = { { { 0.871367335f, 0.215860531f, 0.215860531f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightCyan = { { { 0.745404482f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = { { { 0.955973506f, 0.955973506f, 0.644479871f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightGray = { { { 0.651405811f, 0.651405811f, 0.651405811f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightGreen = { { { 0.278894335f, 0.854992807f, 0.278894335f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightPink = { { { 1.f, 0.467783839f, 0.533276618f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSalmon = { { { 1.f, 0.351532698f, 0.194617867f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSeaGreen = { { { 0.014443844f, 0.445201248f, 0.401977867f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSkyBlue = { { { 0.242281199f, 0.617206752f, 0.955973506f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSlateGray = { { { 0.184475034f, 0.246201396f, 0.318546832f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightSteelBlue = { { { 0.434153706f, 0.552011609f, 0.730461001f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LightYellow = { { { 1.f, 1.f, 0.745404482f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Lime = { { { 0.f, 1.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 LimeGreen = { { { 0.031896040f, 0.610495746f, 0.031896040f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Linen = { { { 0.955973506f, 0.871367335f, 0.791298151f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Magenta = { { { 1.f, 0.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Maroon = { { { 0.215860531f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumAquamarine = { { { 0.132868364f, 0.610495746f, 0.401977867f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumBlue = { { { 0.f, 0.f, 0.610495746f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumOrchid = { { { 0.491020888f, 0.090841733f, 0.651405811f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumPurple = { { { 0.291770697f, 0.162029430f, 0.708376050f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = { { { 0.045186214f, 0.450785846f, 0.165132239f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = { { { 0.198069349f, 0.138431653f, 0.854992807f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = { { { 0.f, 0.955973506f, 0.323143244f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumTurquoise = { { { 0.064803280f, 0.637597024f, 0.603827536f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MediumVioletRed = { { { 0.571125031f, 0.007499032f, 0.234550655f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MidnightBlue = { { { 0.009721218f, 0.009721218f, 0.162029430f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MintCream = { { { 0.913098991f, 1.f, 0.955973506f, 1.f } } };
XMGLOBALCONST XMVECTORF32 MistyRose = { { { 1.f, 0.775822461f, 0.752942443f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Moccasin = { { { 1.f, 0.775822461f, 0.462077051f, 1.f } } };
XMGLOBALCONST XMVECTORF32 NavajoWhite = { { { 1.f, 0.730461001f, 0.417885154f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Navy = { { { 0.f, 0.f, 0.215860531f, 1.f } } };
XMGLOBALCONST XMVECTORF32 OldLace = { { { 0.982250869f, 0.913098991f, 0.791298151f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Olive = { { { 0.215860531f, 0.215860531f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 OliveDrab = { { { 0.147027299f, 0.270497859f, 0.016807375f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Orange = { { { 1.f, 0.376262218f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 OrangeRed = { { { 1.f, 0.059511241f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Orchid = { { { 0.701102138f, 0.162029430f, 0.672443330f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = { { { 0.854992807f, 0.806952477f, 0.401977867f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleGreen = { { { 0.313988745f, 0.964686573f, 0.313988745f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleTurquoise = { { { 0.428690553f, 0.854992807f, 0.854992807f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PaleVioletRed = { { { 0.708376050f, 0.162029430f, 0.291770697f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PapayaWhip = { { { 1.f, 0.863157392f, 0.665387452f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PeachPuff = { { { 1.f, 0.701102138f, 0.485149980f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Peru = { { { 0.610495746f, 0.234550655f, 0.049706575f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Pink = { { { 1.f, 0.527115345f, 0.597202003f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Plum = { { { 0.723055363f, 0.351532698f, 0.723055363f, 1.f } } };
XMGLOBALCONST XMVECTORF32 PowderBlue = { { { 0.434153706f, 0.745404482f, 0.791298151f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Purple = { { { 0.215860531f, 0.f, 0.215860531f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Red = { { { 1.f, 0.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 RosyBrown = { { { 0.502886593f, 0.274677366f, 0.274677366f, 1.f } } };
XMGLOBALCONST XMVECTORF32 RoyalBlue = { { { 0.052860655f, 0.141263321f, 0.752942443f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SaddleBrown = { { { 0.258182913f, 0.059511241f, 0.006512091f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Salmon = { { { 0.955973506f, 0.215860531f, 0.168269455f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SandyBrown = { { { 0.904661357f, 0.371237785f, 0.116970696f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SeaGreen = { { { 0.027320892f, 0.258182913f, 0.095307484f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SeaShell = { { { 1.f, 0.913098991f, 0.854992807f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Sienna = { { { 0.351532698f, 0.084376216f, 0.026241222f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Silver = { { { 0.527115345f, 0.527115345f, 0.527115345f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SkyBlue = { { { 0.242281199f, 0.617206752f, 0.830770075f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SlateBlue = { { { 0.144128501f, 0.102241747f, 0.610495746f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SlateGray = { { { 0.162029430f, 0.215860531f, 0.278894335f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Snow = { { { 1.f, 0.955973506f, 0.955973506f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SpringGreen = { { { 0.f, 1.f, 0.212230787f, 1.f } } };
XMGLOBALCONST XMVECTORF32 SteelBlue = { { { 0.061246071f, 0.223227978f, 0.456411064f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Tan = { { { 0.644479871f, 0.456411064f, 0.262250721f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Teal = { { { 0.f, 0.215860531f, 0.215860531f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Thistle = { { { 0.686685443f, 0.520995677f, 0.686685443f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Tomato = { { { 1.f, 0.124771863f, 0.063010029f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Transparent = { { { 0.f, 0.f, 0.f, 0.f } } };
XMGLOBALCONST XMVECTORF32 Turquoise = { { { 0.051269468f, 0.745404482f, 0.630757332f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Violet = { { { 0.854992807f, 0.223227978f, 0.854992807f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Wheat = { { { 0.913098991f, 0.730461001f, 0.450785846f, 1.f } } };
XMGLOBALCONST XMVECTORF32 White = { { { 1.f, 1.f, 1.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 WhiteSmoke = { { { 0.913098991f, 0.913098991f, 0.913098991f, 1.f } } };
XMGLOBALCONST XMVECTORF32 Yellow = { { { 1.f, 1.f, 0.f, 1.f } } };
XMGLOBALCONST XMVECTORF32 YellowGreen = { { { 0.323143244f, 0.610495746f, 0.031896040f, 1.f } } };
namespace ColorsLinear {
// Standard colors (Red/Green/Blue/Alpha) in linear colorspace
XMGLOBALCONST XMVECTORF32 AliceBlue = {
{{0.871367335f, 0.938685894f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 AntiqueWhite = {
{{0.955973506f, 0.830770075f, 0.679542601f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Aqua = {{{0.f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Aquamarine = {
{{0.212230787f, 1.f, 0.658374965f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Azure = {{{0.871367335f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Beige = {
{{0.913098991f, 0.913098991f, 0.715693772f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Bisque = {{{1.f, 0.775822461f, 0.552011609f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Black = {{{0.f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 BlanchedAlmond = {
{{1.f, 0.830770075f, 0.610495746f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Blue = {{{0.f, 0.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 BlueViolet = {
{{0.254152179f, 0.024157630f, 0.760524750f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Brown = {
{{0.376262218f, 0.023153365f, 0.023153365f, 1.f}}};
XMGLOBALCONST XMVECTORF32 BurlyWood = {
{{0.730461001f, 0.479320228f, 0.242281199f, 1.f}}};
XMGLOBALCONST XMVECTORF32 CadetBlue = {
{{0.114435382f, 0.341914445f, 0.351532698f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Chartreuse = {{{0.212230787f, 1.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Chocolate = {
{{0.644479871f, 0.141263321f, 0.012983031f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Coral = {{{1.f, 0.212230787f, 0.080219828f, 1.f}}};
XMGLOBALCONST XMVECTORF32 CornflowerBlue = {
{{0.127437726f, 0.300543845f, 0.846873462f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Cornsilk = {{{1.f, 0.938685894f, 0.715693772f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Crimson = {
{{0.715693772f, 0.006995410f, 0.045186214f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Cyan = {{{0.f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkBlue = {{{0.f, 0.f, 0.258182913f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkCyan = {{{0.f, 0.258182913f, 0.258182913f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = {
{{0.479320228f, 0.238397658f, 0.003346536f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkGray = {
{{0.396755308f, 0.396755308f, 0.396755308f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkGreen = {{{0.f, 0.127437726f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkKhaki = {
{{0.508881450f, 0.473531544f, 0.147027299f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkMagenta = {
{{0.258182913f, 0.f, 0.258182913f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkOliveGreen = {
{{0.090841733f, 0.147027299f, 0.028426038f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkOrange = {{{1.f, 0.262250721f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkOrchid = {
{{0.318546832f, 0.031896040f, 0.603827536f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkRed = {{{0.258182913f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSalmon = {
{{0.814846814f, 0.304987371f, 0.194617867f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = {
{{0.274677366f, 0.502886593f, 0.258182913f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = {
{{0.064803280f, 0.046665095f, 0.258182913f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkSlateGray = {
{{0.028426038f, 0.078187428f, 0.078187428f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkTurquoise = {
{{0.f, 0.617206752f, 0.637597024f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DarkViolet = {
{{0.296138316f, 0.f, 0.651405811f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DeepPink = {{{1.f, 0.006995410f, 0.291770697f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DeepSkyBlue = {{{0.f, 0.520995677f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DimGray = {
{{0.141263321f, 0.141263321f, 0.141263321f, 1.f}}};
XMGLOBALCONST XMVECTORF32 DodgerBlue = {
{{0.012983031f, 0.278894335f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Firebrick = {
{{0.445201248f, 0.015996292f, 0.015996292f, 1.f}}};
XMGLOBALCONST XMVECTORF32 FloralWhite = {
{{1.f, 0.955973506f, 0.871367335f, 1.f}}};
XMGLOBALCONST XMVECTORF32 ForestGreen = {
{{0.015996292f, 0.258182913f, 0.015996292f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Fuchsia = {{{1.f, 0.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Gainsboro = {
{{0.715693772f, 0.715693772f, 0.715693772f, 1.f}}};
XMGLOBALCONST XMVECTORF32 GhostWhite = {
{{0.938685894f, 0.938685894f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Gold = {{{1.f, 0.679542601f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Goldenrod = {
{{0.701102138f, 0.376262218f, 0.014443844f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Gray = {
{{0.215860531f, 0.215860531f, 0.215860531f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Green = {{{0.f, 0.215860531f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 GreenYellow = {
{{0.417885154f, 1.f, 0.028426038f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Honeydew = {{{0.871367335f, 1.f, 0.871367335f, 1.f}}};
XMGLOBALCONST XMVECTORF32 HotPink = {{{1.f, 0.141263321f, 0.456411064f, 1.f}}};
XMGLOBALCONST XMVECTORF32 IndianRed = {
{{0.610495746f, 0.107023112f, 0.107023112f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Indigo = {{{0.070360109f, 0.f, 0.223227978f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Ivory = {{{1.f, 1.f, 0.871367335f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Khaki = {
{{0.871367335f, 0.791298151f, 0.262250721f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Lavender = {
{{0.791298151f, 0.791298151f, 0.955973506f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LavenderBlush = {
{{1.f, 0.871367335f, 0.913098991f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LawnGreen = {
{{0.201556295f, 0.973445475f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LemonChiffon = {
{{1.f, 0.955973506f, 0.610495746f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightBlue = {
{{0.417885154f, 0.686685443f, 0.791298151f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightCoral = {
{{0.871367335f, 0.215860531f, 0.215860531f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightCyan = {{{0.745404482f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = {
{{0.955973506f, 0.955973506f, 0.644479871f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightGray = {
{{0.651405811f, 0.651405811f, 0.651405811f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightGreen = {
{{0.278894335f, 0.854992807f, 0.278894335f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightPink = {
{{1.f, 0.467783839f, 0.533276618f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSalmon = {
{{1.f, 0.351532698f, 0.194617867f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSeaGreen = {
{{0.014443844f, 0.445201248f, 0.401977867f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSkyBlue = {
{{0.242281199f, 0.617206752f, 0.955973506f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSlateGray = {
{{0.184475034f, 0.246201396f, 0.318546832f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightSteelBlue = {
{{0.434153706f, 0.552011609f, 0.730461001f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LightYellow = {{{1.f, 1.f, 0.745404482f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Lime = {{{0.f, 1.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 LimeGreen = {
{{0.031896040f, 0.610495746f, 0.031896040f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Linen = {
{{0.955973506f, 0.871367335f, 0.791298151f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Magenta = {{{1.f, 0.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Maroon = {{{0.215860531f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumAquamarine = {
{{0.132868364f, 0.610495746f, 0.401977867f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumBlue = {{{0.f, 0.f, 0.610495746f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumOrchid = {
{{0.491020888f, 0.090841733f, 0.651405811f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumPurple = {
{{0.291770697f, 0.162029430f, 0.708376050f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = {
{{0.045186214f, 0.450785846f, 0.165132239f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = {
{{0.198069349f, 0.138431653f, 0.854992807f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = {
{{0.f, 0.955973506f, 0.323143244f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumTurquoise = {
{{0.064803280f, 0.637597024f, 0.603827536f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MediumVioletRed = {
{{0.571125031f, 0.007499032f, 0.234550655f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MidnightBlue = {
{{0.009721218f, 0.009721218f, 0.162029430f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MintCream = {
{{0.913098991f, 1.f, 0.955973506f, 1.f}}};
XMGLOBALCONST XMVECTORF32 MistyRose = {
{{1.f, 0.775822461f, 0.752942443f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Moccasin = {{{1.f, 0.775822461f, 0.462077051f, 1.f}}};
XMGLOBALCONST XMVECTORF32 NavajoWhite = {
{{1.f, 0.730461001f, 0.417885154f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Navy = {{{0.f, 0.f, 0.215860531f, 1.f}}};
XMGLOBALCONST XMVECTORF32 OldLace = {
{{0.982250869f, 0.913098991f, 0.791298151f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Olive = {{{0.215860531f, 0.215860531f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 OliveDrab = {
{{0.147027299f, 0.270497859f, 0.016807375f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Orange = {{{1.f, 0.376262218f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 OrangeRed = {{{1.f, 0.059511241f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Orchid = {
{{0.701102138f, 0.162029430f, 0.672443330f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = {
{{0.854992807f, 0.806952477f, 0.401977867f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleGreen = {
{{0.313988745f, 0.964686573f, 0.313988745f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleTurquoise = {
{{0.428690553f, 0.854992807f, 0.854992807f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PaleVioletRed = {
{{0.708376050f, 0.162029430f, 0.291770697f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PapayaWhip = {
{{1.f, 0.863157392f, 0.665387452f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PeachPuff = {
{{1.f, 0.701102138f, 0.485149980f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Peru = {
{{0.610495746f, 0.234550655f, 0.049706575f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Pink = {{{1.f, 0.527115345f, 0.597202003f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Plum = {
{{0.723055363f, 0.351532698f, 0.723055363f, 1.f}}};
XMGLOBALCONST XMVECTORF32 PowderBlue = {
{{0.434153706f, 0.745404482f, 0.791298151f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Purple = {{{0.215860531f, 0.f, 0.215860531f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Red = {{{1.f, 0.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 RosyBrown = {
{{0.502886593f, 0.274677366f, 0.274677366f, 1.f}}};
XMGLOBALCONST XMVECTORF32 RoyalBlue = {
{{0.052860655f, 0.141263321f, 0.752942443f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SaddleBrown = {
{{0.258182913f, 0.059511241f, 0.006512091f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Salmon = {
{{0.955973506f, 0.215860531f, 0.168269455f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SandyBrown = {
{{0.904661357f, 0.371237785f, 0.116970696f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SeaGreen = {
{{0.027320892f, 0.258182913f, 0.095307484f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SeaShell = {{{1.f, 0.913098991f, 0.854992807f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Sienna = {
{{0.351532698f, 0.084376216f, 0.026241222f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Silver = {
{{0.527115345f, 0.527115345f, 0.527115345f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SkyBlue = {
{{0.242281199f, 0.617206752f, 0.830770075f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SlateBlue = {
{{0.144128501f, 0.102241747f, 0.610495746f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SlateGray = {
{{0.162029430f, 0.215860531f, 0.278894335f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Snow = {{{1.f, 0.955973506f, 0.955973506f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SpringGreen = {{{0.f, 1.f, 0.212230787f, 1.f}}};
XMGLOBALCONST XMVECTORF32 SteelBlue = {
{{0.061246071f, 0.223227978f, 0.456411064f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Tan = {
{{0.644479871f, 0.456411064f, 0.262250721f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Teal = {{{0.f, 0.215860531f, 0.215860531f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Thistle = {
{{0.686685443f, 0.520995677f, 0.686685443f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Tomato = {{{1.f, 0.124771863f, 0.063010029f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Transparent = {{{0.f, 0.f, 0.f, 0.f}}};
XMGLOBALCONST XMVECTORF32 Turquoise = {
{{0.051269468f, 0.745404482f, 0.630757332f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Violet = {
{{0.854992807f, 0.223227978f, 0.854992807f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Wheat = {
{{0.913098991f, 0.730461001f, 0.450785846f, 1.f}}};
XMGLOBALCONST XMVECTORF32 White = {{{1.f, 1.f, 1.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 WhiteSmoke = {
{{0.913098991f, 0.913098991f, 0.913098991f, 1.f}}};
XMGLOBALCONST XMVECTORF32 Yellow = {{{1.f, 1.f, 0.f, 1.f}}};
XMGLOBALCONST XMVECTORF32 YellowGreen = {
{{0.323143244f, 0.610495746f, 0.031896040f, 1.f}}};
} // namespace ColorsLinear
} // namespace DirectX
} // namespace ColorsLinear
} // namespace DirectX

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -32,4 +32,4 @@
#include "xbox_stubs.h"
#include "iggy_stubs.h"
#endif // STUBS_H
#endif // STUBS_H

View file

@ -8,12 +8,11 @@
using namespace DirectX;
typedef struct _RECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
typedef struct _RECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT;
// stole- i mean borrowed from OrbisStubs.h
@ -27,45 +26,42 @@ typedef void ID3D11Buffer;
// typedef DWORD (*PTHREAD_START_ROUTINE)( LPVOID lpThreadParameter);
// typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
// Used only by windows/durango gdraw and UIController. Will be unnecessary once we have our own
// UIController stubs.
// Used only by windows/durango gdraw and UIController. Will be unnecessary once
// we have our own UIController stubs.
typedef void ID3D11ShaderResourceView;
typedef void ID3D11Resource;
typedef void ID3D11Texture2D;
typedef void D3D11_TEXTURE2D_DESC;
enum D3D11_BLEND
{
D3D11_BLEND_ZERO = 1,
D3D11_BLEND_ONE = 2,
D3D11_BLEND_SRC_COLOR = 3,
D3D11_BLEND_INV_SRC_COLOR = 4,
D3D11_BLEND_SRC_ALPHA = 5,
D3D11_BLEND_INV_SRC_ALPHA = 6,
D3D11_BLEND_DEST_ALPHA = 7,
D3D11_BLEND_INV_DEST_ALPHA = 8,
D3D11_BLEND_DEST_COLOR = 9,
D3D11_BLEND_INV_DEST_COLOR = 10,
D3D11_BLEND_SRC_ALPHA_SAT = 11,
D3D11_BLEND_BLEND_FACTOR = 14,
D3D11_BLEND_INV_BLEND_FACTOR = 15,
D3D11_BLEND_SRC1_COLOR = 16,
D3D11_BLEND_INV_SRC1_COLOR = 17,
D3D11_BLEND_SRC1_ALPHA = 18,
D3D11_BLEND_INV_SRC1_ALPHA = 19
enum D3D11_BLEND {
D3D11_BLEND_ZERO = 1,
D3D11_BLEND_ONE = 2,
D3D11_BLEND_SRC_COLOR = 3,
D3D11_BLEND_INV_SRC_COLOR = 4,
D3D11_BLEND_SRC_ALPHA = 5,
D3D11_BLEND_INV_SRC_ALPHA = 6,
D3D11_BLEND_DEST_ALPHA = 7,
D3D11_BLEND_INV_DEST_ALPHA = 8,
D3D11_BLEND_DEST_COLOR = 9,
D3D11_BLEND_INV_DEST_COLOR = 10,
D3D11_BLEND_SRC_ALPHA_SAT = 11,
D3D11_BLEND_BLEND_FACTOR = 14,
D3D11_BLEND_INV_BLEND_FACTOR = 15,
D3D11_BLEND_SRC1_COLOR = 16,
D3D11_BLEND_INV_SRC1_COLOR = 17,
D3D11_BLEND_SRC1_ALPHA = 18,
D3D11_BLEND_INV_SRC1_ALPHA = 19
};
enum D3D11_COMPARISON_FUNC
{
D3D11_COMPARISON_NEVER = 1,
D3D11_COMPARISON_LESS = 2,
D3D11_COMPARISON_EQUAL = 3,
D3D11_COMPARISON_LESS_EQUAL = 4,
D3D11_COMPARISON_GREATER = 5,
D3D11_COMPARISON_NOT_EQUAL = 6,
D3D11_COMPARISON_GREATER_EQUAL = 7,
D3D11_COMPARISON_ALWAYS = 8
enum D3D11_COMPARISON_FUNC {
D3D11_COMPARISON_NEVER = 1,
D3D11_COMPARISON_LESS = 2,
D3D11_COMPARISON_EQUAL = 3,
D3D11_COMPARISON_LESS_EQUAL = 4,
D3D11_COMPARISON_GREATER = 5,
D3D11_COMPARISON_NOT_EQUAL = 6,
D3D11_COMPARISON_GREATER_EQUAL = 7,
D3D11_COMPARISON_ALWAYS = 8
};
#endif // D3D11STUBS_H
#endif // D3D11STUBS_H

View file

@ -3,225 +3,258 @@
#pragma once
#include "../../Windows64/Iggy/include/iggy.h"
#define STUBBED {}
#define STUBBED \
{ \
}
RADEXPFUNC inline IggyValuePath * RADEXPLINK IggyPlayerRootPath(Iggy *f) {
STUBBED;
return nullptr;
RADEXPFUNC inline IggyValuePath* RADEXPLINK IggyPlayerRootPath(Iggy* f) {
STUBBED;
return nullptr;
}
RADEXPFUNC inline IggyResult RADEXPLINK IggyPlayerCallMethodRS(Iggy *f, IggyDataValue *result, IggyValuePath *target, IggyName methodname, S32 numargs, IggyDataValue *args) {
STUBBED;
return IGGY_RESULT_SUCCESS;
RADEXPFUNC inline IggyResult RADEXPLINK
IggyPlayerCallMethodRS(Iggy* f, IggyDataValue* result, IggyValuePath* target,
IggyName methodname, S32 numargs, IggyDataValue* args) {
STUBBED;
return IGGY_RESULT_SUCCESS;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerDestroy(Iggy *player) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetDisplaySize(Iggy *f, S32 w, S32 h) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyPlayerDestroy(Iggy* player) { STUBBED; }
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetDisplaySize(Iggy* f, S32 w,
S32 h) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesStart(Iggy *f) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesStart(Iggy* f) { STUBBED; }
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTile(Iggy *f, S32 x0, S32 y0, S32 x1, S32 y1, S32 padding) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesEnd(Iggy *f) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTile(Iggy* f, S32 x0, S32 y0,
S32 x1, S32 y1,
S32 padding) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesEnd(Iggy* f) { STUBBED; }
// Each fake Iggy player gets its own state block
struct FakeIggyPlayer {
int tickCount;
bool needsTick;
IggyProperties props;
void *userdata;
int tickCount;
bool needsTick;
IggyProperties props;
void* userdata;
};
// Simple player pool
// Simple player pool
static FakeIggyPlayer s_fakePlayers[64];
static int s_fakePlayerCount = 0;
RADEXPFUNC inline Iggy * RADEXPLINK IggyPlayerCreateFromMemory(
void const * data,
U32 data_size_in_bytes,
IggyPlayerConfig *config) {
if(s_fakePlayerCount >= 64) return nullptr;
FakeIggyPlayer *fp = &s_fakePlayers[s_fakePlayerCount++];
fp->tickCount = 0;
fp->needsTick = true;
fp->userdata = nullptr;
// Default to 1920x1080 at 30fps
memset(&fp->props, 0, sizeof(fp->props));
fp->props.movie_width_in_pixels = 1920;
fp->props.movie_height_in_pixels = 1080;
fp->props.movie_frame_rate_from_file_in_fps = 30.0f;
fp->props.movie_frame_rate_current_in_fps = 30.0f;
fprintf(stderr, "[Iggy Stub] Created fake player %d (data=%p, size=%u)\n", s_fakePlayerCount-1, data, data_size_in_bytes);
return (Iggy*)fp;
RADEXPFUNC inline Iggy* RADEXPLINK IggyPlayerCreateFromMemory(
void const* data, U32 data_size_in_bytes, IggyPlayerConfig* config) {
if (s_fakePlayerCount >= 64) return nullptr;
FakeIggyPlayer* fp = &s_fakePlayers[s_fakePlayerCount++];
fp->tickCount = 0;
fp->needsTick = true;
fp->userdata = nullptr;
// Default to 1920x1080 at 30fps
memset(&fp->props, 0, sizeof(fp->props));
fp->props.movie_width_in_pixels = 1920;
fp->props.movie_height_in_pixels = 1080;
fp->props.movie_frame_rate_from_file_in_fps = 30.0f;
fp->props.movie_frame_rate_current_in_fps = 30.0f;
fprintf(stderr, "[Iggy Stub] Created fake player %d (data=%p, size=%u)\n",
s_fakePlayerCount - 1, data, data_size_in_bytes);
return (Iggy*)fp;
}
static FakeIggyPlayer* getFakePlayer(Iggy *player) {
return (FakeIggyPlayer*)player;
static FakeIggyPlayer* getFakePlayer(Iggy* player) {
return (FakeIggyPlayer*)player;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerInitializeAndTickRS(Iggy *player) {
FakeIggyPlayer *fp = getFakePlayer(player);
if(fp) { fp->tickCount = 0; fp->needsTick = true; }
RADEXPFUNC inline void RADEXPLINK IggyPlayerInitializeAndTickRS(Iggy* player) {
FakeIggyPlayer* fp = getFakePlayer(player);
if (fp) {
fp->tickCount = 0;
fp->needsTick = true;
}
}
RADEXPFUNC inline IggyProperties * RADEXPLINK IggyPlayerProperties(Iggy *player) {
FakeIggyPlayer *fp = getFakePlayer(player);
if(fp) return &fp->props;
static IggyProperties defaultProps = {};
return &defaultProps;
RADEXPFUNC inline IggyProperties* RADEXPLINK
IggyPlayerProperties(Iggy* player) {
FakeIggyPlayer* fp = getFakePlayer(player);
if (fp) return &fp->props;
static IggyProperties defaultProps = {};
return &defaultProps;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetUserdata(Iggy *player, void *userdata) {
FakeIggyPlayer *fp = getFakePlayer(player);
if(fp) fp->userdata = userdata;
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetUserdata(Iggy* player,
void* userdata) {
FakeIggyPlayer* fp = getFakePlayer(player);
if (fp) fp->userdata = userdata;
}
RADEXPFUNC inline IggyName RADEXPLINK IggyPlayerCreateFastName(Iggy *f, IggyUTF16 const *name, S32 len) {
STUBBED;
return 0;
RADEXPFUNC inline IggyName RADEXPLINK
IggyPlayerCreateFastName(Iggy* f, IggyUTF16 const* name, S32 len) {
STUBBED;
return 0;
}
RADEXPFUNC inline rrbool RADEXPLINK IggyDebugGetMemoryUseInfo(Iggy *player, IggyLibrary lib, char const *category_string, S32 category_stringlen, S32 iteration, IggyMemoryUseInfo *data) {
STUBBED;
return false;
RADEXPFUNC inline rrbool RADEXPLINK IggyDebugGetMemoryUseInfo(
Iggy* player, IggyLibrary lib, char const* category_string,
S32 category_stringlen, S32 iteration, IggyMemoryUseInfo* data) {
STUBBED;
return false;
}
RADEXPFUNC inline rrbool RADEXPLINK IggyPlayerReadyToTick(Iggy *player) {
FakeIggyPlayer *fp = getFakePlayer(player);
if(fp && fp->needsTick) return true;
return false;
RADEXPFUNC inline rrbool RADEXPLINK IggyPlayerReadyToTick(Iggy* player) {
FakeIggyPlayer* fp = getFakePlayer(player);
if (fp && fp->needsTick) return true;
return false;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerTickRS(Iggy *player) {
FakeIggyPlayer *fp = getFakePlayer(player);
if(fp) {
fp->tickCount++;
// Allow one tick per frame cycle
fp->needsTick = false;
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerTickRS(Iggy* player) {
FakeIggyPlayer* fp = getFakePlayer(player);
if (fp) {
fp->tickCount++;
// Allow one tick per frame cycle
fp->needsTick = false;
}
}
RADEXPFUNC inline void RADEXPLINK IggyPlayerDraw(Iggy *f) {
// Re-arm tick for next frame
FakeIggyPlayer *fp = getFakePlayer(f);
if(fp) fp->needsTick = true;
RADEXPFUNC inline void RADEXPLINK IggyPlayerDraw(Iggy* f) {
// Re-arm tick for next frame
FakeIggyPlayer* fp = getFakePlayer(f);
if (fp) fp->needsTick = true;
}
RADEXPFUNC inline void RADEXPLINK IggyMakeEventKey(IggyEvent *event, IggyKeyevent event_type, IggyKeycode keycode, IggyKeyloc keyloc) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyMakeEventKey(IggyEvent* event,
IggyKeyevent event_type,
IggyKeycode keycode,
IggyKeyloc keyloc) {
STUBBED;
}
RADEXPFUNC inline rrbool RADEXPLINK IggyPlayerDispatchEventRS(Iggy *player, IggyEvent *event, IggyEventResult *result) {
STUBBED;
return false;
RADEXPFUNC inline rrbool RADEXPLINK IggyPlayerDispatchEventRS(
Iggy* player, IggyEvent* event, IggyEventResult* result) {
STUBBED;
return false;
}
RADEXPFUNC inline void RADEXPLINK IggyFontRemoveUTF8(const char *fontname, S32 namelen_in_bytes, U32 fontflags) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyFontRemoveUTF8(const char* fontname,
S32 namelen_in_bytes,
U32 fontflags) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyFontInstallBitmapUTF8(const IggyBitmapFontProvider *bmf, const char *fontname, S32 namelen_in_bytes, U32 fontflags) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyFontInstallBitmapUTF8(
const IggyBitmapFontProvider* bmf, const char* fontname,
S32 namelen_in_bytes, U32 fontflags) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyFontSetIndirectUTF8(const char *request_name, S32 request_namelen, U32 request_flags, const char *result_name, S32 result_namelen, U32 result_flags) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyFontSetIndirectUTF8(
const char* request_name, S32 request_namelen, U32 request_flags,
const char* result_name, S32 result_namelen, U32 result_flags) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeUTF8(const void *truetype_storage, S32 ttc_index, const char *fontname, S32 namelen_in_bytes, U32 fontflags) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeUTF8(
const void* truetype_storage, S32 ttc_index, const char* fontname,
S32 namelen_in_bytes, U32 fontflags) {
STUBBED;
}
RADEXPFUNC inline rrbool RADEXPLINK IggyValuePathMakeNameRef(IggyValuePath *result, IggyValuePath *parent, char const *text_utf8) {
STUBBED;
return false;
RADEXPFUNC inline rrbool RADEXPLINK IggyValuePathMakeNameRef(
IggyValuePath* result, IggyValuePath* parent, char const* text_utf8) {
STUBBED;
return false;
}
RADEXPFUNC inline IggyResult RADEXPLINK IggyValueGetBooleanRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, rrbool *result) {
STUBBED;
return IGGY_RESULT_SUCCESS;
RADEXPFUNC inline IggyResult RADEXPLINK
IggyValueGetBooleanRS(IggyValuePath* var, IggyName sub_name,
char const* sub_name_utf8, rrbool* result) {
STUBBED;
return IGGY_RESULT_SUCCESS;
}
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeFallbackCodepointUTF8(const char *fontname, S32 len, U32 fontflags, S32 fallback_codepoint) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeFallbackCodepointUTF8(
const char* fontname, S32 len, U32 fontflags, S32 fallback_codepoint) {
STUBBED;
}
RADEXPFUNC inline IggyResult RADEXPLINK IggyValueGetF64RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, F64 *result) {
STUBBED;
return IGGY_RESULT_SUCCESS;
RADEXPFUNC inline IggyResult RADEXPLINK
IggyValueGetF64RS(IggyValuePath* var, IggyName sub_name,
char const* sub_name_utf8, F64* result) {
STUBBED;
return IGGY_RESULT_SUCCESS;
}
RADEXPFUNC inline rrbool RADEXPLINK IggyValueSetBooleanRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, rrbool value) {
STUBBED;
return true;
RADEXPFUNC inline rrbool RADEXPLINK
IggyValueSetBooleanRS(IggyValuePath* var, IggyName sub_name,
char const* sub_name_utf8, rrbool value) {
STUBBED;
return true;
}
RADEXPFUNC inline void RADEXPLINK IggyInit(IggyAllocator *allocator) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyInit(IggyAllocator* allocator) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggySetWarningCallback(Iggy_WarningFunction *error, void *user_callback_data) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK
IggySetWarningCallback(Iggy_WarningFunction* error, void* user_callback_data) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggySetTraceCallbackUTF8(Iggy_TraceFunctionUTF8 *trace_utf8, void *user_callback_data) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggySetTraceCallbackUTF8(
Iggy_TraceFunctionUTF8* trace_utf8, void* user_callback_data) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggySetFontCachingCalculationBuffer(
S32 max_chars,
void *optional_temp_buffer,
S32 optional_temp_buffer_size_in_bytes) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK
IggySetFontCachingCalculationBuffer(S32 max_chars, void* optional_temp_buffer,
S32 optional_temp_buffer_size_in_bytes) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggySetCustomDrawCallback(Iggy_CustomDrawCallback *custom_draw, void *user_callback_data) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggySetCustomDrawCallback(
Iggy_CustomDrawCallback* custom_draw, void* user_callback_data) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggySetAS3ExternalFunctionCallbackUTF16(Iggy_AS3ExternalFunctionUTF16 *as3_external_function_utf16, void *user_callback_data) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggySetAS3ExternalFunctionCallbackUTF16(
Iggy_AS3ExternalFunctionUTF16* as3_external_function_utf16,
void* user_callback_data) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyMakeEventMouseMove(IggyEvent *event, S32 x, S32 y) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyMakeEventMouseMove(IggyEvent* event,
S32 x, S32 y) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggySetTextureSubstitutionCallbacks(Iggy_TextureSubstitutionCreateCallback *texture_create, Iggy_TextureSubstitutionDestroyCallback *texture_destroy, void *user_callback_data) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggySetTextureSubstitutionCallbacks(
Iggy_TextureSubstitutionCreateCallback* texture_create,
Iggy_TextureSubstitutionDestroyCallback* texture_destroy,
void* user_callback_data) {
STUBBED;
}
RADEXPFUNC inline void * RADEXPLINK IggyPlayerGetUserdata(Iggy *player) {
FakeIggyPlayer *fp = getFakePlayer(player);
if(fp) return fp->userdata;
return 0;
RADEXPFUNC inline void* RADEXPLINK IggyPlayerGetUserdata(Iggy* player) {
FakeIggyPlayer* fp = getFakePlayer(player);
if (fp) return fp->userdata;
return 0;
}
RADEXPFUNC inline IggyLibrary RADEXPLINK IggyLibraryCreateFromMemoryUTF16(
IggyUTF16 const * url_utf16_null_terminated,
void const * data,
U32 data_size_in_bytes,
IggyPlayerConfig *config) {
STUBBED;
return 0;
RADEXPFUNC inline IggyLibrary RADEXPLINK IggyLibraryCreateFromMemoryUTF16(
IggyUTF16 const* url_utf16_null_terminated, void const* data,
U32 data_size_in_bytes, IggyPlayerConfig* config) {
STUBBED;
return 0;
}
RADEXPFUNC inline void RADEXPLINK IggyLibraryDestroy(IggyLibrary lib) {
STUBBED;
STUBBED;
}
// Iggy is fake
static GDrawFunctions *s_iggy_gdraw_funcs = 0;
RADEXPFUNC inline void RADEXPLINK IggySetGDraw(GDrawFunctions *gdraw_funcs) {
s_iggy_gdraw_funcs = gdraw_funcs;
static GDrawFunctions* s_iggy_gdraw_funcs = 0;
RADEXPFUNC inline void RADEXPLINK IggySetGDraw(GDrawFunctions* gdraw_funcs) {
s_iggy_gdraw_funcs = gdraw_funcs;
}
// Audio stubs
RADEXPFUNC inline void RADEXPLINK IggyAudioUseDefault(void) {
STUBBED;
}
RADEXPFUNC inline void RADEXPLINK IggyAudioUseDefault(void) { STUBBED; }
// Explorer/Perfmon, shit implmentation
RADEXPFUNC inline void * RADEXPLINK IggyExpCreate(const char *host, int port, void *storage, int storage_size) {
STUBBED;
return 0;
RADEXPFUNC inline void* RADEXPLINK IggyExpCreate(const char* host, int port,
void* storage,
int storage_size) {
STUBBED;
return 0;
}
RADEXPFUNC inline void RADEXPLINK IggyUseExplorer(Iggy *player, void *explorer) {
STUBBED;
RADEXPFUNC inline void RADEXPLINK IggyUseExplorer(Iggy* player,
void* explorer) {
STUBBED;
}
RADEXPFUNC inline void * RADEXPLINK IggyPerfmonCreate(void *(*alloc_func)(unsigned long), void (*free_func)(void *), void *user) {
STUBBED;
return 0;
}
RADEXPFUNC inline void RADEXPLINK IggyInstallPerfmon(void *perfmon) {
STUBBED;
RADEXPFUNC inline void* RADEXPLINK IggyPerfmonCreate(
void* (*alloc_func)(unsigned long), void (*free_func)(void*), void* user) {
STUBBED;
return 0;
}
RADEXPFUNC inline void RADEXPLINK IggyInstallPerfmon(void* perfmon) { STUBBED; }
// GDraw memory/warning functions are defined in gdraw_glfw.c (C linkage)
// Juicey you stupid idiot do NOT define them here
// Juicey you stupid idiot do NOT define them here
#endif // IGGYSTUBS_H
#endif // IGGYSTUBS_H

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
//
//=============================================================================
#if !defined( XBOXSTUBS_H ) && !defined( _X360 )
#if !defined(XBOXSTUBS_H) && !defined(_X360)
#define XBOXSTUBS_H
#ifdef _WIN32
@ -12,7 +12,7 @@
#endif
// DecalOverdose: not available in 4J
//#include "tier0/platform.h"
// #include "tier0/platform.h"
#define POSIX
@ -23,66 +23,65 @@ typedef long long int int64;
#define FORCEINLINE inline
// Content creation/open flags
#define XCONTENTFLAG_NONE 0x00
#define XCONTENTFLAG_CREATENEW 0x00
#define XCONTENTFLAG_CREATEALWAYS 0x00
#define XCONTENTFLAG_OPENEXISTING 0x00
#define XCONTENTFLAG_OPENALWAYS 0x00
#define XCONTENTFLAG_TRUNCATEEXISTING 0x00
#define XCONTENTFLAG_NONE 0x00
#define XCONTENTFLAG_CREATENEW 0x00
#define XCONTENTFLAG_CREATEALWAYS 0x00
#define XCONTENTFLAG_OPENEXISTING 0x00
#define XCONTENTFLAG_OPENALWAYS 0x00
#define XCONTENTFLAG_TRUNCATEEXISTING 0x00
// Content attributes
#define XCONTENTFLAG_NOPROFILE_TRANSFER 0x00
#define XCONTENTFLAG_NODEVICE_TRANSFER 0x00
#define XCONTENTFLAG_STRONG_SIGNED 0x00
#define XCONTENTFLAG_ALLOWPROFILE_TRANSFER 0x00
#define XCONTENTFLAG_MOVEONLY_TRANSFER 0x00
#define XCONTENTFLAG_NOPROFILE_TRANSFER 0x00
#define XCONTENTFLAG_NODEVICE_TRANSFER 0x00
#define XCONTENTFLAG_STRONG_SIGNED 0x00
#define XCONTENTFLAG_ALLOWPROFILE_TRANSFER 0x00
#define XCONTENTFLAG_MOVEONLY_TRANSFER 0x00
// Console device ports
#define XDEVICE_PORT0 0
#define XDEVICE_PORT1 1
#define XDEVICE_PORT2 2
#define XDEVICE_PORT3 3
#define XDEVICE_PORT0 0
#define XDEVICE_PORT1 1
#define XDEVICE_PORT2 2
#define XDEVICE_PORT3 3
// #define XUSER_MAX_COUNT 4
#define XUSER_INDEX_NONE 0x000000FE
#define XUSER_INDEX_NONE 0x000000FE
#define XBX_CLR_DEFAULT 0xFF000000
#define XBX_CLR_WARNING 0x0000FFFF
#define XBX_CLR_ERROR 0x000000FF
#define XBX_CLR_DEFAULT 0xFF000000
#define XBX_CLR_WARNING 0x0000FFFF
#define XBX_CLR_ERROR 0x000000FF
#define XBOX_MINBORDERSAFE 0
#define XBOX_MAXBORDERSAFE 0
#define XBOX_MINBORDERSAFE 0
#define XBOX_MAXBORDERSAFE 0
typedef enum
{
XK_NULL,
XK_BUTTON_UP,
XK_BUTTON_DOWN,
XK_BUTTON_LEFT,
XK_BUTTON_RIGHT,
XK_BUTTON_START,
XK_BUTTON_BACK,
XK_BUTTON_STICK1,
XK_BUTTON_STICK2,
XK_BUTTON_A,
XK_BUTTON_B,
XK_BUTTON_X,
XK_BUTTON_Y,
XK_BUTTON_LEFT_SHOULDER,
XK_BUTTON_RIGHT_SHOULDER,
XK_BUTTON_LTRIGGER,
XK_BUTTON_RTRIGGER,
XK_STICK1_UP,
XK_STICK1_DOWN,
XK_STICK1_LEFT,
XK_STICK1_RIGHT,
XK_STICK2_UP,
XK_STICK2_DOWN,
XK_STICK2_LEFT,
XK_STICK2_RIGHT,
XK_MAX_KEYS,
typedef enum {
XK_NULL,
XK_BUTTON_UP,
XK_BUTTON_DOWN,
XK_BUTTON_LEFT,
XK_BUTTON_RIGHT,
XK_BUTTON_START,
XK_BUTTON_BACK,
XK_BUTTON_STICK1,
XK_BUTTON_STICK2,
XK_BUTTON_A,
XK_BUTTON_B,
XK_BUTTON_X,
XK_BUTTON_Y,
XK_BUTTON_LEFT_SHOULDER,
XK_BUTTON_RIGHT_SHOULDER,
XK_BUTTON_LTRIGGER,
XK_BUTTON_RTRIGGER,
XK_STICK1_UP,
XK_STICK1_DOWN,
XK_STICK1_LEFT,
XK_STICK1_RIGHT,
XK_STICK2_UP,
XK_STICK2_DOWN,
XK_STICK2_LEFT,
XK_STICK2_RIGHT,
XK_MAX_KEYS,
} xKey_t;
//typedef enum
// typedef enum
//{
// XVRB_NONE, // off
// XVRB_ERROR, // fatal error
@ -90,74 +89,70 @@ typedef enum
// XVRB_WARNING, // non-fatal warnings
// XVRB_STATUS, // status reports
// XVRB_ALL,
//} xverbose_e;
// } xverbose_e;
#ifdef POSIX
typedef DWORD COLORREF;
#endif
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
#define INVALID_HANDLE_VALUE ((HANDLE) - 1)
#endif
// typedef struct {
// IN_ADDR ina; // IP address (zero if not static/DHCP)
// IN_ADDR inaOnline; // Online IP address (zero if not online)
// WORD wPortOnline; // Online port
// BYTE abEnet[6]; // Ethernet MAC address
// BYTE abOnline[20]; // Online identification
// } XNADDR;
// IN_ADDR ina; // IP address (zero if not
// static/DHCP) IN_ADDR inaOnline; // Online IP address
// (zero if not online) WORD wPortOnline; // Online
// port BYTE abEnet[6]; // Ethernet MAC address BYTE
// abOnline[20]; // Online identification } XNADDR;
typedef int XNADDR;
typedef uint64 XUID;
typedef struct {
BYTE ab[8]; // xbox to xbox key identifier
BYTE ab[8]; // xbox to xbox key identifier
} XNKID;
typedef struct {
BYTE ab[16]; // xbox to xbox key exchange key
BYTE ab[16]; // xbox to xbox key exchange key
} XNKEY;
typedef struct _XSESSION_INFO
{
XNKID sessionID; // 8 bytes
XNADDR hostAddress; // 36 bytes
XNKEY keyExchangeKey; // 16 bytes
typedef struct _XSESSION_INFO {
XNKID sessionID; // 8 bytes
XNADDR hostAddress; // 36 bytes
XNKEY keyExchangeKey; // 16 bytes
} XSESSION_INFO, *PXSESSION_INFO;
typedef struct _XSESSION_REGISTRANT
{
uint64 qwMachineID;
DWORD bTrustworthiness;
DWORD bNumUsers;
XUID *rgUsers;
typedef struct _XSESSION_REGISTRANT {
uint64 qwMachineID;
DWORD bTrustworthiness;
DWORD bNumUsers;
XUID* rgUsers;
} XSESSION_REGISTRANT;
typedef struct _XSESSION_REGISTRATION_RESULTS
{
DWORD wNumRegistrants;
XSESSION_REGISTRANT *rgRegistrants;
typedef struct _XSESSION_REGISTRATION_RESULTS {
DWORD wNumRegistrants;
XSESSION_REGISTRANT* rgRegistrants;
} XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS;
#define XSESSION_CREATE_HOST 0
#define XUSER_DATA_TYPE_INT32 0
#define XSESSION_CREATE_USES_ARBITRATION 0
#define XNET_QOS_LISTEN_ENABLE 0
#define XNET_QOS_LISTEN_DISABLE 0
#define XNET_QOS_LISTEN_SET_DATA 0
#define XSESSION_CREATE_HOST 0
#define XUSER_DATA_TYPE_INT32 0
#define XSESSION_CREATE_USES_ARBITRATION 0
#define XNET_QOS_LISTEN_ENABLE 0
#define XNET_QOS_LISTEN_DISABLE 0
#define XNET_QOS_LISTEN_SET_DATA 0
FORCEINLINE void XBX_ProcessEvents() {}
FORCEINLINE unsigned int XBX_GetSystemTime() { return 0; }
FORCEINLINE int XBX_GetPrimaryUserId() { return 0; }
FORCEINLINE void XBX_SetPrimaryUserId( DWORD idx ) {}
FORCEINLINE int XBX_GetStorageDeviceId() { return 0; }
FORCEINLINE void XBX_SetStorageDeviceId( DWORD idx ) {}
FORCEINLINE const char *XBX_GetLanguageString() { return ""; }
FORCEINLINE bool XBX_IsLocalized() { return false; }
FORCEINLINE void XBX_ProcessEvents() {}
FORCEINLINE unsigned int XBX_GetSystemTime() { return 0; }
FORCEINLINE int XBX_GetPrimaryUserId() { return 0; }
FORCEINLINE void XBX_SetPrimaryUserId(DWORD idx) {}
FORCEINLINE int XBX_GetStorageDeviceId() { return 0; }
FORCEINLINE void XBX_SetStorageDeviceId(DWORD idx) {}
FORCEINLINE const char* XBX_GetLanguageString() { return ""; }
FORCEINLINE bool XBX_IsLocalized() { return false; }
#define XBX_INVALID_STORAGE_ID ((DWORD) -1)
#define XBX_STORAGE_DECLINED ((DWORD) -2)
#define XBX_INVALID_STORAGE_ID ((DWORD) - 1)
#define XBX_STORAGE_DECLINED ((DWORD) - 2)
#endif // XBOXSTUBS_H
#endif // XBOXSTUBS_H

View file

@ -18,13 +18,18 @@ void PIXSetMarkerDeprecated(int a, const char* b, ...) {}
#include "../Xbox/Network/NetworkPlayerXbox.h"
NetworkPlayerXbox::NetworkPlayerXbox(IQNetPlayer* p) : m_qnetPlayer(p), m_pSocket(nullptr) {}
NetworkPlayerXbox::NetworkPlayerXbox(IQNetPlayer* p)
: m_qnetPlayer(p), m_pSocket(nullptr) {}
IQNetPlayer* NetworkPlayerXbox::GetQNetPlayer() { return m_qnetPlayer; }
unsigned char NetworkPlayerXbox::GetSmallId() { return 0; }
void NetworkPlayerXbox::SendData(INetworkPlayer*, const void*, int, bool) {}
bool NetworkPlayerXbox::IsSameSystem(INetworkPlayer*) { return false; }
int NetworkPlayerXbox::GetSendQueueSizeBytes(INetworkPlayer*, bool) { return 0; }
int NetworkPlayerXbox::GetSendQueueSizeMessages(INetworkPlayer*, bool) { return 0; }
int NetworkPlayerXbox::GetSendQueueSizeBytes(INetworkPlayer*, bool) {
return 0;
}
int NetworkPlayerXbox::GetSendQueueSizeMessages(INetworkPlayer*, bool) {
return 0;
}
int NetworkPlayerXbox::GetCurrentRtt() { return 0; }
bool NetworkPlayerXbox::IsHost() { return false; }
bool NetworkPlayerXbox::IsGuest() { return false; }

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