mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
chore: format Minecraft.Client
This commit is contained in:
parent
33d0737d1d
commit
e8424f2000
|
|
@ -1,4 +1,6 @@
|
||||||
#include "Platform/stdafx.h"
|
#include "Platform/stdafx.h"
|
||||||
#include "ClientConstants.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;
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
class ClientConstants {
|
||||||
class ClientConstants
|
|
||||||
{
|
|
||||||
|
|
||||||
// This file holds global constants used by the client.
|
// This file holds global constants used by the client.
|
||||||
// The file should be replaced at compile-time with the
|
// The file should be replaced at compile-time with the
|
||||||
// proper settings for the given compilation. For example,
|
// proper settings for the given compilation. For example,
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,10 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
|
||||||
#include "TeleportCommand.h"
|
#include "TeleportCommand.h"
|
||||||
|
|
||||||
EGameCommand TeleportCommand::getId()
|
EGameCommand TeleportCommand::getId() { return eGameCommand_Teleport; }
|
||||||
{
|
|
||||||
return eGameCommand_Teleport;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray commandData)
|
void TeleportCommand::execute(std::shared_ptr<CommandSender> source,
|
||||||
{
|
byteArray commandData) {
|
||||||
ByteArrayInputStream bais(commandData);
|
ByteArrayInputStream bais(commandData);
|
||||||
DataInputStream dis(&bais);
|
DataInputStream dis(&bais);
|
||||||
|
|
||||||
|
|
@ -27,22 +24,28 @@ void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray c
|
||||||
PlayerList* players = MinecraftServer::getInstance()->getPlayerList();
|
PlayerList* players = MinecraftServer::getInstance()->getPlayerList();
|
||||||
|
|
||||||
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
|
std::shared_ptr<ServerPlayer> subject = players->getPlayer(subjectID);
|
||||||
std::shared_ptr<ServerPlayer> destination = players->getPlayer(destinationID);
|
std::shared_ptr<ServerPlayer> destination =
|
||||||
|
players->getPlayer(destinationID);
|
||||||
|
|
||||||
if(subject != NULL && destination != NULL && subject->level->dimension->id == destination->level->dimension->id && subject->isAlive() )
|
if (subject != NULL && destination != NULL &&
|
||||||
{
|
subject->level->dimension->id == destination->level->dimension->id &&
|
||||||
|
subject->isAlive()) {
|
||||||
subject->ride(nullptr);
|
subject->ride(nullptr);
|
||||||
subject->connection->teleport(destination->x, destination->y, destination->z, destination->yRot, destination->xRot);
|
subject->connection->teleport(destination->x, destination->y,
|
||||||
//logAdminAction(source, "commands.tp.success", subject->getAName(), destination->getAName());
|
destination->z, destination->yRot,
|
||||||
logAdminAction(source, ChatPacket::e_ChatCommandTeleportSuccess, subject->getName(), eTYPE_SERVERPLAYER, destination->getName());
|
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)
|
if (subject == source) {
|
||||||
{
|
destination->sendMessage(subject->getName(),
|
||||||
destination->sendMessage(subject->getName(), ChatPacket::e_ChatCommandTeleportToMe);
|
ChatPacket::e_ChatCommandTeleportToMe);
|
||||||
}
|
} else {
|
||||||
else
|
subject->sendMessage(destination->getName(),
|
||||||
{
|
ChatPacket::e_ChatCommandTeleportMe);
|
||||||
subject->sendMessage(destination->getName(), ChatPacket::e_ChatCommandTeleportMe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,30 +64,35 @@ void TeleportCommand::execute(std::shared_ptr<CommandSender> source, byteArray c
|
||||||
// if (victim.level != null) {
|
// if (victim.level != null) {
|
||||||
// int pos = args.length - 3;
|
// int pos = args.length - 3;
|
||||||
// int maxPos = Level.MAX_LEVEL_SIZE;
|
// int maxPos = Level.MAX_LEVEL_SIZE;
|
||||||
// int x = convertArgToInt(source, args[pos++], -maxPos, maxPos);
|
// int x = convertArgToInt(source, args[pos++], -maxPos,
|
||||||
// int y = convertArgToInt(source, args[pos++], Level.minBuildHeight, Level.maxBuildHeight);
|
//maxPos); int y = convertArgToInt(source, args[pos++],
|
||||||
// int z = convertArgToInt(source, args[pos++], -maxPos, maxPos);
|
//Level.minBuildHeight, Level.maxBuildHeight); int z =
|
||||||
|
//convertArgToInt(source, args[pos++], -maxPos, maxPos);
|
||||||
|
|
||||||
// victim.teleportTo(x + 0.5f, y, z + 0.5f);
|
// victim.teleportTo(x + 0.5f, y, z + 0.5f);
|
||||||
// logAdminAction(source, "commands.tp.coordinates", victim.getAName(), x, y, z);
|
// logAdminAction(source, "commands.tp.coordinates",
|
||||||
|
//victim.getAName(), x, y, z);
|
||||||
// }
|
// }
|
||||||
// } else if (args.length == 1 || args.length == 2) {
|
// } else if (args.length == 1 || args.length == 2) {
|
||||||
// ServerPlayer destination = server.getPlayers().getPlayer(args[args.length - 1]);
|
// ServerPlayer destination =
|
||||||
// if (destination == null) throw new PlayerNotFoundException();
|
//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);
|
// victim.connection.teleport(destination.x, destination.y,
|
||||||
// logAdminAction(source, "commands.tp.success", victim.getAName(), destination.getAName());
|
//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)
|
std::shared_ptr<GameCommandPacket> TeleportCommand::preparePacket(
|
||||||
{
|
PlayerUID subject, PlayerUID destination) {
|
||||||
ByteArrayOutputStream baos;
|
ByteArrayOutputStream baos;
|
||||||
DataOutputStream dos(&baos);
|
DataOutputStream dos(&baos);
|
||||||
|
|
||||||
dos.writePlayerUID(subject);
|
dos.writePlayerUID(subject);
|
||||||
dos.writePlayerUID(destination);
|
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()));
|
||||||
}
|
}
|
||||||
|
|
@ -2,11 +2,12 @@
|
||||||
|
|
||||||
#include "../../Minecraft.World/Commands/Command.h"
|
#include "../../Minecraft.World/Commands/Command.h"
|
||||||
|
|
||||||
class TeleportCommand : public Command
|
class TeleportCommand : public Command {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual EGameCommand getId();
|
virtual EGameCommand getId();
|
||||||
virtual void execute(std::shared_ptr<CommandSender> source, byteArray commandData);
|
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);
|
||||||
};
|
};
|
||||||
|
|
@ -10,64 +10,57 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.h"
|
||||||
|
|
||||||
CreativeMode::CreativeMode(Minecraft *minecraft) : GameMode(minecraft)
|
CreativeMode::CreativeMode(Minecraft* minecraft) : GameMode(minecraft) {
|
||||||
{
|
|
||||||
destroyDelay = 0;
|
destroyDelay = 0;
|
||||||
instaBuild = true;
|
instaBuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::init()
|
void CreativeMode::init() {
|
||||||
{
|
|
||||||
// initPlayer();
|
// initPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player)
|
void CreativeMode::enableCreativeForPlayer(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
// please check ServerPlayerGameMode.java if you change these
|
// please check ServerPlayerGameMode.java if you change these
|
||||||
player->abilities.mayfly = true;
|
player->abilities.mayfly = true;
|
||||||
player->abilities.instabuild = true;
|
player->abilities.instabuild = true;
|
||||||
player->abilities.invulnerable = true;
|
player->abilities.invulnerable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player)
|
void CreativeMode::disableCreativeForPlayer(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
player->abilities.mayfly = false;
|
player->abilities.mayfly = false;
|
||||||
player->abilities.flying = false;
|
player->abilities.flying = false;
|
||||||
player->abilities.instabuild = false;
|
player->abilities.instabuild = false;
|
||||||
player->abilities.invulnerable = false;
|
player->abilities.invulnerable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player)
|
void CreativeMode::adjustPlayer(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
enableCreativeForPlayer(player);
|
enableCreativeForPlayer(player);
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++) {
|
||||||
{
|
if (player->inventory->items[i] == NULL) {
|
||||||
if (player->inventory->items[i] == NULL)
|
player->inventory->items[i] = std::shared_ptr<ItemInstance>(
|
||||||
{
|
new ItemInstance(User::allowedTiles[i]));
|
||||||
player->inventory->items[i] = std::shared_ptr<ItemInstance>( new ItemInstance(User::allowedTiles[i]) );
|
} else {
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 4J-PB - this line is commented out in 1.0.1
|
// 4J-PB - this line is commented out in 1.0.1
|
||||||
// player->inventory->items[i]->count = 1;
|
// player->inventory->items[i]->count = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::creativeDestroyBlock(Minecraft *minecraft, GameMode *gameMode, int x, int y, int z, int face)
|
void CreativeMode::creativeDestroyBlock(Minecraft* minecraft,
|
||||||
{
|
GameMode* gameMode, int x, int y, int z,
|
||||||
if(!minecraft->level->extinguishFire(minecraft->player, x, y, z, face))
|
int face) {
|
||||||
{
|
if (!minecraft->level->extinguishFire(minecraft->player, x, y, z, face)) {
|
||||||
gameMode->destroyBlock(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)
|
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);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0)
|
if (t > 0) {
|
||||||
{
|
|
||||||
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;
|
if (item == NULL) return false;
|
||||||
|
|
@ -79,52 +72,29 @@ bool CreativeMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::startDestroyBlock(int x, int y, int z, int face)
|
void CreativeMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face)
|
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
destroyDelay--;
|
destroyDelay--;
|
||||||
if (destroyDelay <= 0)
|
if (destroyDelay <= 0) {
|
||||||
{
|
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreativeMode::stopDestroyBlock()
|
void CreativeMode::stopDestroyBlock() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreativeMode::canHurtPlayer()
|
bool CreativeMode::canHurtPlayer() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreativeMode::initLevel(Level *level)
|
void CreativeMode::initLevel(Level* level) { GameMode::initLevel(level); }
|
||||||
{
|
|
||||||
GameMode::initLevel(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
float CreativeMode::getPickRange()
|
float CreativeMode::getPickRange() { return 5.0f; }
|
||||||
{
|
|
||||||
return 5.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreativeMode::hasMissTime()
|
bool CreativeMode::hasMissTime() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreativeMode::hasInfiniteItems()
|
bool CreativeMode::hasInfiniteItems() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CreativeMode::hasFarPickRange()
|
bool CreativeMode::hasFarPickRange() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "GameMode.h"
|
#include "GameMode.h"
|
||||||
|
|
||||||
class CreativeMode : public GameMode
|
class CreativeMode : public GameMode {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
int destroyDelay;
|
int destroyDelay;
|
||||||
|
|
||||||
|
|
@ -12,8 +11,12 @@ public:
|
||||||
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
|
static void enableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||||
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
|
static void disableCreativeForPlayer(std::shared_ptr<Player> player);
|
||||||
virtual void adjustPlayer(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);
|
static void creativeDestroyBlock(Minecraft* minecraft, GameMode* gameMode,
|
||||||
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);
|
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 startDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual void stopDestroyBlock();
|
virtual void stopDestroyBlock();
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,12 @@
|
||||||
#include "DemoMode.h"
|
#include "DemoMode.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
|
|
||||||
DemoMode::DemoMode(Minecraft *minecraft) : SurvivalMode(minecraft)
|
DemoMode::DemoMode(Minecraft* minecraft) : SurvivalMode(minecraft) {
|
||||||
{
|
|
||||||
demoHasEnded = false;
|
demoHasEnded = false;
|
||||||
demoEndedReminder = 0;
|
demoEndedReminder = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoMode::tick()
|
void DemoMode::tick() {
|
||||||
{
|
|
||||||
SurvivalMode::tick();
|
SurvivalMode::tick();
|
||||||
|
|
||||||
/* 4J - TODO - seems unlikely we need this demo mode anyway
|
/* 4J - TODO - seems unlikely we need this demo mode anyway
|
||||||
|
|
@ -26,7 +24,8 @@ void DemoMode::tick()
|
||||||
{
|
{
|
||||||
if (day <= (DEMO_DAYS + 1))
|
if (day <= (DEMO_DAYS + 1))
|
||||||
{
|
{
|
||||||
minecraft->gui->displayClientMessage(L"demo.day." + _toString<__int64>(day));
|
minecraft->gui->displayClientMessage(L"demo.day." +
|
||||||
|
_toString<__int64>(day));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (day == 1)
|
else if (day == 1)
|
||||||
|
|
@ -37,14 +36,18 @@ void DemoMode::tick()
|
||||||
if (time == 100) {
|
if (time == 100) {
|
||||||
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
minecraft.gui.addMessage("Seed: " + minecraft.level.getSeed());
|
||||||
message = language.getElement("demo.help.movement");
|
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),
|
message = String.format(message,
|
||||||
|
Keyboard.getKeyName(options.keyUp.key),
|
||||||
|
Keyboard.getKeyName(options.keyLeft.key),
|
||||||
|
Keyboard.getKeyName(options.keyDown.key),
|
||||||
Keyboard.getKeyName(options.keyRight.key));
|
Keyboard.getKeyName(options.keyRight.key));
|
||||||
} else if (time == 175) {
|
} else if (time == 175) {
|
||||||
message = language.getElement("demo.help.jump");
|
message = language.getElement("demo.help.jump");
|
||||||
message = String.format(message, Keyboard.getKeyName(options.keyJump.key));
|
message = String.format(message,
|
||||||
} else if (time == 250) {
|
Keyboard.getKeyName(options.keyJump.key)); } else if (time == 250) {
|
||||||
message = language.getElement("demo.help.inventory");
|
message = language.getElement("demo.help.inventory");
|
||||||
message = String.format(message, Keyboard.getKeyName(options.keyBuild.key));
|
message = String.format(message,
|
||||||
|
Keyboard.getKeyName(options.keyBuild.key));
|
||||||
}
|
}
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
minecraft.gui.addMessage(message);
|
minecraft.gui.addMessage(message);
|
||||||
|
|
@ -57,8 +60,7 @@ void DemoMode::tick()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoMode::outputDemoReminder()
|
void DemoMode::outputDemoReminder() {
|
||||||
{
|
|
||||||
/* 4J - TODO
|
/* 4J - TODO
|
||||||
if (demoEndedReminder > 100) {
|
if (demoEndedReminder > 100) {
|
||||||
minecraft.gui.displayClientMessage("demo.reminder");
|
minecraft.gui.displayClientMessage("demo.reminder");
|
||||||
|
|
@ -67,46 +69,40 @@ void DemoMode::outputDemoReminder()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoMode::startDestroyBlock(int x, int y, int z, int face)
|
void DemoMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
if (demoHasEnded) {
|
||||||
if (demoHasEnded)
|
|
||||||
{
|
|
||||||
outputDemoReminder();
|
outputDemoReminder();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SurvivalMode::startDestroyBlock(x, y, z, face);
|
SurvivalMode::startDestroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoMode::continueDestroyBlock(int x, int y, int z, int face)
|
void DemoMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
if (demoHasEnded) {
|
||||||
if (demoHasEnded)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SurvivalMode::continueDestroyBlock(x, y, z, face);
|
SurvivalMode::continueDestroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemoMode::destroyBlock(int x, int y, int z, int face)
|
bool DemoMode::destroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
if (demoHasEnded) {
|
||||||
if (demoHasEnded)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return SurvivalMode::destroyBlock(x, y, z, face);
|
return SurvivalMode::destroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DemoMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item)
|
bool DemoMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
{
|
std::shared_ptr<ItemInstance> item) {
|
||||||
if (demoHasEnded)
|
if (demoHasEnded) {
|
||||||
{
|
|
||||||
outputDemoReminder();
|
outputDemoReminder();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return SurvivalMode::useItem(player, level, item);
|
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) {
|
if (demoHasEnded) {
|
||||||
outputDemoReminder();
|
outputDemoReminder();
|
||||||
return false;
|
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);
|
return SurvivalMode::useItemOn(player, level, item, x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
void DemoMode::attack(std::shared_ptr<Player> player,
|
||||||
{
|
std::shared_ptr<Entity> entity) {
|
||||||
if (demoHasEnded)
|
if (demoHasEnded) {
|
||||||
{
|
|
||||||
outputDemoReminder();
|
outputDemoReminder();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "SurvivalMode.h"
|
#include "SurvivalMode.h"
|
||||||
|
|
||||||
class DemoMode : public SurvivalMode
|
class DemoMode : public SurvivalMode {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int DEMO_DAYS = 5;
|
static const int DEMO_DAYS = 5;
|
||||||
|
|
||||||
|
|
@ -12,8 +11,10 @@ private:
|
||||||
public:
|
public:
|
||||||
DemoMode(Minecraft* minecraft);
|
DemoMode(Minecraft* minecraft);
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void outputDemoReminder();
|
void outputDemoReminder();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using GameMode::useItem;
|
using GameMode::useItem;
|
||||||
using SurvivalMode::useItemOn;
|
using SurvivalMode::useItemOn;
|
||||||
|
|
@ -21,7 +22,11 @@ public:
|
||||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual void continueDestroyBlock(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 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 useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face);
|
std::shared_ptr<ItemInstance> item);
|
||||||
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
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);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
#include "../Platform/stdafx.h"
|
#include "../Platform/stdafx.h"
|
||||||
#include "DemoUser.h"
|
#include "DemoUser.h"
|
||||||
|
|
||||||
DemoUser::DemoUser() : User(L"DemoUser", L"n/a")
|
DemoUser::DemoUser() : User(L"DemoUser", L"n/a") {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../Player/User.h"
|
#include "../Player/User.h"
|
||||||
|
|
||||||
class DemoUser : public User
|
class DemoUser : public User {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DemoUser();
|
DemoUser();
|
||||||
};
|
};
|
||||||
|
|
@ -11,60 +11,55 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.player.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
||||||
|
|
||||||
GameMode::GameMode(Minecraft *minecraft)
|
GameMode::GameMode(Minecraft* minecraft) {
|
||||||
{
|
|
||||||
instaBuild = false; // 4J - added
|
instaBuild = false; // 4J - added
|
||||||
this->minecraft = minecraft;
|
this->minecraft = minecraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::initLevel(Level *level)
|
void GameMode::initLevel(Level* level) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameMode::destroyBlock(int x, int y, int z, int face)
|
bool GameMode::destroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
Level* level = minecraft->level;
|
Level* level = minecraft->level;
|
||||||
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
|
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
|
||||||
if (oldTile == NULL) return false;
|
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.
|
// 4J - Let the rendering side of thing know we are about to destroy the
|
||||||
minecraft->levelRenderer->destroyedTileManager->destroyingTileAt(level, x, y, z);
|
// tile, so we can synchronise collision with async render data upates.
|
||||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
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);
|
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
|
// 4J - before we remove the tile, recalc the heightmap - setTile depends on
|
||||||
// a quick update of skylighting when the block is removed, and there are cases with falling tiles where this can get out of sync
|
// 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();
|
level->getChunkAt(x, z)->recalcHeightmapOnly();
|
||||||
bool changed = level->setTile(x, y, z, 0);
|
bool changed = level->setTile(x, y, z, 0);
|
||||||
|
|
||||||
if (oldTile != NULL && changed)
|
if (oldTile != NULL && changed) {
|
||||||
{
|
|
||||||
oldTile->destroy(level, x, y, z, data);
|
oldTile->destroy(level, x, y, z, data);
|
||||||
}
|
}
|
||||||
return changed;
|
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)
|
bool GameMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
{
|
std::shared_ptr<ItemInstance> item, bool bTestUseOnly) {
|
||||||
return false;
|
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
|
// // 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||||
// int t = level->getTile(x, y, z);
|
// int t = level->getTile(x, y, z);
|
||||||
|
|
@ -76,7 +71,8 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||||
// {
|
// {
|
||||||
// case Tile::recordPlayer_Id:
|
// case Tile::recordPlayer_Id:
|
||||||
// case Tile::bed_Id: // special case for a bed
|
// 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;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
@ -93,7 +89,8 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||||
// }
|
// }
|
||||||
// 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;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
@ -101,84 +98,62 @@ void GameMode::adjustPlayer(std::shared_ptr<Player> player)
|
||||||
// return item->useOn(player, level, x, y, z, face, bTestUseOnOnly);
|
// return item->useOn(player, level, x, y, z, face, bTestUseOnOnly);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
std::shared_ptr<Player> GameMode::createPlayer(Level* level) {
|
||||||
std::shared_ptr<Player> GameMode::createPlayer(Level *level)
|
return std::shared_ptr<Player>(new LocalPlayer(
|
||||||
{
|
minecraft, level, minecraft->user, level->dimension->id));
|
||||||
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)
|
bool GameMode::interact(std::shared_ptr<Player> player,
|
||||||
{
|
std::shared_ptr<Entity> entity) {
|
||||||
return player->interact(entity);
|
return player->interact(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
void GameMode::attack(std::shared_ptr<Player> player,
|
||||||
{
|
std::shared_ptr<Entity> entity) {
|
||||||
player->attack(entity);
|
player->attack(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
|
std::shared_ptr<ItemInstance> GameMode::handleInventoryMouseClick(
|
||||||
{
|
int containerId, int slotNum, int buttonNum, bool quickKeyHeld,
|
||||||
|
std::shared_ptr<Player> player) {
|
||||||
return nullptr;
|
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);
|
player->containerMenu->removed(player);
|
||||||
delete player->containerMenu;
|
delete player->containerMenu;
|
||||||
player->containerMenu = player->inventoryMenu;
|
player->containerMenu = player->inventoryMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMode::handleInventoryButtonClick(int containerId, int buttonId)
|
void GameMode::handleInventoryButtonClick(int containerId, int buttonId) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
bool GameMode::isCutScene() { return false; }
|
||||||
|
|
||||||
bool GameMode::isCutScene()
|
void GameMode::releaseUsingItem(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameMode::releaseUsingItem(std::shared_ptr<Player> player)
|
|
||||||
{
|
|
||||||
player->releaseUsingItem();
|
player->releaseUsingItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameMode::hasExperience()
|
bool GameMode::hasExperience() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameMode::hasMissTime()
|
bool GameMode::hasMissTime() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameMode::hasInfiniteItems()
|
bool GameMode::hasInfiniteItems() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameMode::hasFarPickRange()
|
bool GameMode::hasFarPickRange() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i)
|
void GameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked,
|
||||||
{
|
int i) {}
|
||||||
}
|
|
||||||
|
|
||||||
void GameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
|
void GameMode::handleCreativeModeItemDrop(
|
||||||
{
|
std::shared_ptr<ItemInstance> clicked) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
|
bool GameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J-PB
|
// 4J-PB
|
||||||
void GameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
|
void GameMode::handleDebugOptions(unsigned int uiVal,
|
||||||
{
|
std::shared_ptr<Player> player) {
|
||||||
player->SetDebugOptions(uiVal);
|
player->SetDebugOptions(uiVal);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ class Entity;
|
||||||
|
|
||||||
class Tutorial;
|
class Tutorial;
|
||||||
|
|
||||||
class GameMode
|
class GameMode {
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
Minecraft* minecraft;
|
Minecraft* minecraft;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool instaBuild;
|
bool instaBuild;
|
||||||
|
|
||||||
|
|
@ -29,14 +29,24 @@ public:
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
virtual bool canHurtPlayer() = 0;
|
virtual bool canHurtPlayer() = 0;
|
||||||
virtual void adjustPlayer(std::shared_ptr<Player> player);
|
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 useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
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;
|
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 std::shared_ptr<Player> createPlayer(Level* level);
|
||||||
virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
virtual bool interact(std::shared_ptr<Player> player,
|
||||||
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
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 attack(std::shared_ptr<Player> player,
|
||||||
virtual void handleCloseInventory(int containerId, 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 void handleInventoryButtonClick(int containerId, int buttonId);
|
||||||
|
|
||||||
virtual bool isCutScene();
|
virtual bool isCutScene();
|
||||||
|
|
@ -45,12 +55,15 @@ public:
|
||||||
virtual bool hasMissTime();
|
virtual bool hasMissTime();
|
||||||
virtual bool hasInfiniteItems();
|
virtual bool hasInfiniteItems();
|
||||||
virtual bool hasFarPickRange();
|
virtual bool hasFarPickRange();
|
||||||
virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int i);
|
virtual void handleCreativeModeItemAdd(
|
||||||
virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
|
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
|
// 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 bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
||||||
virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
|
virtual void handleDebugOptions(unsigned int uiVal,
|
||||||
|
std::shared_ptr<Player> player);
|
||||||
|
|
||||||
// 4J Stu - Added for tutorial checks
|
// 4J Stu - Added for tutorial checks
|
||||||
virtual bool isInputAllowed(int mapping) { return true; }
|
virtual bool isInputAllowed(int mapping) { return true; }
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@
|
||||||
#include "../../Minecraft.World/IO/Streams/DataOutputStream.h"
|
#include "../../Minecraft.World/IO/Streams/DataOutputStream.h"
|
||||||
#include "../../Minecraft.World/Util/StringHelpers.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
|
// 4J - the Option sub-class used to be an java enumerated type, trying to
|
||||||
const Options::Option Options::Option::options[17] =
|
// emulate that functionality here
|
||||||
{
|
const Options::Option Options::Option::options[17] = {
|
||||||
Options::Option(L"options.music", true, false),
|
Options::Option(L"options.music", true, false),
|
||||||
Options::Option(L"options.sound", true, false),
|
Options::Option(L"options.sound", true, false),
|
||||||
Options::Option(L"options.invertMouse", false, true),
|
Options::Option(L"options.invertMouse", false, true),
|
||||||
|
|
@ -38,76 +38,66 @@ const Options::Option Options::Option::options[17] =
|
||||||
|
|
||||||
const Options::Option* Options::Option::MUSIC = &Options::Option::options[0];
|
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::SOUND = &Options::Option::options[1];
|
||||||
const Options::Option *Options::Option::INVERT_MOUSE = &Options::Option::options[2];
|
const Options::Option* Options::Option::INVERT_MOUSE =
|
||||||
const Options::Option *Options::Option::SENSITIVITY = &Options::Option::options[3];
|
&Options::Option::options[2];
|
||||||
const Options::Option *Options::Option::RENDER_DISTANCE = &Options::Option::options[4];
|
const Options::Option* Options::Option::SENSITIVITY =
|
||||||
const Options::Option *Options::Option::VIEW_BOBBING = &Options::Option::options[5];
|
&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::ANAGLYPH = &Options::Option::options[6];
|
||||||
const Options::Option *Options::Option::ADVANCED_OPENGL = &Options::Option::options[7];
|
const Options::Option* Options::Option::ADVANCED_OPENGL =
|
||||||
const Options::Option *Options::Option::FRAMERATE_LIMIT = &Options::Option::options[8];
|
&Options::Option::options[7];
|
||||||
const Options::Option *Options::Option::DIFFICULTY = &Options::Option::options[9];
|
const Options::Option* Options::Option::FRAMERATE_LIMIT =
|
||||||
const Options::Option *Options::Option::GRAPHICS = &Options::Option::options[10];
|
&Options::Option::options[8];
|
||||||
const Options::Option *Options::Option::AMBIENT_OCCLUSION = &Options::Option::options[11];
|
const Options::Option* Options::Option::DIFFICULTY =
|
||||||
const Options::Option *Options::Option::GUI_SCALE = &Options::Option::options[12];
|
&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::FOV = &Options::Option::options[13];
|
||||||
const Options::Option* Options::Option::GAMMA = &Options::Option::options[14];
|
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::RENDER_CLOUDS =
|
||||||
const Options::Option *Options::Option::PARTICLES = &Options::Option::options[16];
|
&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)
|
Options::Option::Option(const std::wstring& captionId, bool hasProgress,
|
||||||
{
|
bool isBoolean)
|
||||||
return &options[id];
|
: _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
|
bool Options::Option::isBoolean() const { return _isBoolean; }
|
||||||
{
|
|
||||||
return _isProgress;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Options::Option::isBoolean() const
|
int Options::Option::getId() const { return (int)(this - options); }
|
||||||
{
|
|
||||||
return _isBoolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Options::Option::getId() const
|
std::wstring Options::Option::getCaptionId() const { return captionId; }
|
||||||
{
|
|
||||||
return (int)(this-options);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring Options::Option::getCaptionId() const
|
const std::wstring Options::RENDER_DISTANCE_NAMES[] = {
|
||||||
{
|
L"options.renderDistance.far", L"options.renderDistance.normal",
|
||||||
return captionId;
|
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[] =
|
const std::wstring Options::PARTICLES[] = {L"options.particles.all",
|
||||||
{
|
L"options.particles.decreased",
|
||||||
L"options.renderDistance.far", L"options.renderDistance.normal", L"options.renderDistance.short", L"options.renderDistance.tiny"
|
L"options.particles.minimal"};
|
||||||
};
|
|
||||||
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"
|
|
||||||
};
|
|
||||||
|
|
||||||
// 4J added
|
// 4J added
|
||||||
void Options::init()
|
void Options::init() {
|
||||||
{
|
|
||||||
music = 1;
|
music = 1;
|
||||||
sound = 1;
|
sound = 1;
|
||||||
sensitivity = 0.5f;
|
sensitivity = 0.5f;
|
||||||
|
|
@ -178,26 +168,20 @@ void Options::init()
|
||||||
gamma = 0;
|
gamma = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Options::Options(Minecraft *minecraft, File workingDirectory)
|
Options::Options(Minecraft* minecraft, File workingDirectory) {
|
||||||
{
|
|
||||||
init();
|
init();
|
||||||
this->minecraft = minecraft;
|
this->minecraft = minecraft;
|
||||||
optionsFile = File(workingDirectory, L"options.txt");
|
optionsFile = File(workingDirectory, L"options.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
Options::Options()
|
Options::Options() { init(); }
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring Options::getKeyDescription(int i)
|
std::wstring Options::getKeyDescription(int i) {
|
||||||
{
|
|
||||||
Language* language = Language::getInstance();
|
Language* language = Language::getInstance();
|
||||||
return language->getElement(keyMappings[i]->name);
|
return language->getElement(keyMappings[i]->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring Options::getKeyMessage(int i)
|
std::wstring Options::getKeyMessage(int i) {
|
||||||
{
|
|
||||||
int key = keyMappings[i]->key;
|
int key = keyMappings[i]->key;
|
||||||
if (key < 0) {
|
if (key < 0) {
|
||||||
return I18n::get(L"key.mouseButton", key + 101);
|
return I18n::get(L"key.mouseButton", key + 101);
|
||||||
|
|
@ -206,16 +190,13 @@ std::wstring Options::getKeyMessage(int i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::setKey(int i, int key)
|
void Options::setKey(int i, int key) {
|
||||||
{
|
|
||||||
keyMappings[i]->key = key;
|
keyMappings[i]->key = key;
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::set(const Options::Option *item, float fVal)
|
void Options::set(const Options::Option* item, float fVal) {
|
||||||
{
|
if (item == Option::MUSIC) {
|
||||||
if (item == Option::MUSIC)
|
|
||||||
{
|
|
||||||
music = fVal;
|
music = fVal;
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
minecraft->soundEngine->updateMusicVolume(fVal * 2.0f);
|
minecraft->soundEngine->updateMusicVolume(fVal * 2.0f);
|
||||||
|
|
@ -223,8 +204,7 @@ void Options::set(const Options::Option *item, float fVal)
|
||||||
minecraft->soundEngine->updateMusicVolume(fVal);
|
minecraft->soundEngine->updateMusicVolume(fVal);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (item == Option::SOUND)
|
if (item == Option::SOUND) {
|
||||||
{
|
|
||||||
sound = fVal;
|
sound = fVal;
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
minecraft->soundEngine->updateSoundEffectVolume(fVal * 2.0f);
|
minecraft->soundEngine->updateSoundEffectVolume(fVal * 2.0f);
|
||||||
|
|
@ -232,42 +212,39 @@ void Options::set(const Options::Option *item, float fVal)
|
||||||
minecraft->soundEngine->updateSoundEffectVolume(fVal);
|
minecraft->soundEngine->updateSoundEffectVolume(fVal);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (item == Option::SENSITIVITY)
|
if (item == Option::SENSITIVITY) {
|
||||||
{
|
|
||||||
sensitivity = fVal;
|
sensitivity = fVal;
|
||||||
}
|
}
|
||||||
if (item == Option::FOV)
|
if (item == Option::FOV) {
|
||||||
{
|
|
||||||
fov = fVal;
|
fov = fVal;
|
||||||
}
|
}
|
||||||
if (item == Option::GAMMA)
|
if (item == Option::GAMMA) {
|
||||||
{
|
|
||||||
gamma = fVal;
|
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::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::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
|
// 4J-PB - changing
|
||||||
// if (option == Option::VIEW_BOBBING) bobView = !bobView;
|
// if (option == Option::VIEW_BOBBING) bobView = !bobView;
|
||||||
if (option == Option::VIEW_BOBBING) ((dir==0)?bobView=false: bobView=true);
|
if (option == Option::VIEW_BOBBING)
|
||||||
|
((dir == 0) ? bobView = false : bobView = true);
|
||||||
if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds;
|
if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds;
|
||||||
if (option == Option::ADVANCED_OPENGL)
|
if (option == Option::ADVANCED_OPENGL) {
|
||||||
{
|
|
||||||
advancedOpengl = !advancedOpengl;
|
advancedOpengl = !advancedOpengl;
|
||||||
minecraft->levelRenderer->allChanged();
|
minecraft->levelRenderer->allChanged();
|
||||||
}
|
}
|
||||||
if (option == Option::ANAGLYPH)
|
if (option == Option::ANAGLYPH) {
|
||||||
{
|
|
||||||
anaglyph3d = !anaglyph3d;
|
anaglyph3d = !anaglyph3d;
|
||||||
minecraft->textures->reloadAll();
|
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
|
// 4J-PB - Change for Xbox
|
||||||
// if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3;
|
// if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3;
|
||||||
|
|
@ -275,24 +252,20 @@ void Options::toggle(const Options::Option *option, int dir)
|
||||||
|
|
||||||
app.DebugPrintf("Option::DIFFICULTY = %d", difficulty);
|
app.DebugPrintf("Option::DIFFICULTY = %d", difficulty);
|
||||||
|
|
||||||
if (option == Option::GRAPHICS)
|
if (option == Option::GRAPHICS) {
|
||||||
{
|
|
||||||
fancyGraphics = !fancyGraphics;
|
fancyGraphics = !fancyGraphics;
|
||||||
minecraft->levelRenderer->allChanged();
|
minecraft->levelRenderer->allChanged();
|
||||||
}
|
}
|
||||||
if (option == Option::AMBIENT_OCCLUSION)
|
if (option == Option::AMBIENT_OCCLUSION) {
|
||||||
{
|
|
||||||
ambientOcclusion = !ambientOcclusion;
|
ambientOcclusion = !ambientOcclusion;
|
||||||
minecraft->levelRenderer->allChanged();
|
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();
|
// save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Options::getProgressValue(const Options::Option *item)
|
float Options::getProgressValue(const Options::Option* item) {
|
||||||
{
|
|
||||||
if (item == Option::FOV) return fov;
|
if (item == Option::FOV) return fov;
|
||||||
if (item == Option::GAMMA) return gamma;
|
if (item == Option::GAMMA) return gamma;
|
||||||
if (item == Option::MUSIC) return music;
|
if (item == Option::MUSIC) return music;
|
||||||
|
|
@ -301,9 +274,9 @@ float Options::getProgressValue(const Options::Option *item)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Options::getBooleanValue(const Options::Option *item)
|
bool Options::getBooleanValue(const Options::Option* item) {
|
||||||
{
|
// 4J - was a switch statement which we can't do with our Option:: pointer
|
||||||
// 4J - was a switch statement which we can't do with our Option:: pointer types
|
// types
|
||||||
if (item == Option::INVERT_MOUSE) return invertYMouse;
|
if (item == Option::INVERT_MOUSE) return invertYMouse;
|
||||||
if (item == Option::VIEW_BOBBING) return bobView;
|
if (item == Option::VIEW_BOBBING) return bobView;
|
||||||
if (item == Option::ANAGLYPH) return anaglyph3d;
|
if (item == Option::ANAGLYPH) return anaglyph3d;
|
||||||
|
|
@ -313,124 +286,96 @@ bool Options::getBooleanValue(const Options::Option *item)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring Options::getMessage(const Options::Option *item)
|
std::wstring Options::getMessage(const Options::Option* item) {
|
||||||
{
|
|
||||||
// 4J TODO, should these std::wstrings append rather than add?
|
// 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": ";
|
std::wstring caption = language->getElement(item->getCaptionId()) + L": ";
|
||||||
|
|
||||||
if (item->isProgress())
|
if (item->isProgress()) {
|
||||||
{
|
|
||||||
float progressValue = getProgressValue(item);
|
float progressValue = getProgressValue(item);
|
||||||
|
|
||||||
if (item == Option::SENSITIVITY)
|
if (item == Option::SENSITIVITY) {
|
||||||
{
|
if (progressValue == 0) {
|
||||||
if (progressValue == 0)
|
return caption +
|
||||||
{
|
language->getElement(L"options.sensitivity.min");
|
||||||
return caption + language->getElement(L"options.sensitivity.min");
|
|
||||||
}
|
}
|
||||||
if (progressValue == 1)
|
if (progressValue == 1) {
|
||||||
{
|
return caption +
|
||||||
return caption + language->getElement(L"options.sensitivity.max");
|
language->getElement(L"options.sensitivity.max");
|
||||||
}
|
}
|
||||||
return caption + _toString<int>((int)(progressValue * 200)) + L"%";
|
return caption + _toString<int>((int)(progressValue * 200)) + L"%";
|
||||||
} else if (item == Option::FOV)
|
} else if (item == Option::FOV) {
|
||||||
{
|
if (progressValue == 0) {
|
||||||
if (progressValue == 0)
|
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.fov.min");
|
return caption + language->getElement(L"options.fov.min");
|
||||||
}
|
}
|
||||||
if (progressValue == 1)
|
if (progressValue == 1) {
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.fov.max");
|
return caption + language->getElement(L"options.fov.max");
|
||||||
}
|
}
|
||||||
return caption + _toString<int>((int)(70 + progressValue * 40));
|
return caption + _toString<int>((int)(70 + progressValue * 40));
|
||||||
} else if (item == Option::GAMMA)
|
} else if (item == Option::GAMMA) {
|
||||||
{
|
if (progressValue == 0) {
|
||||||
if (progressValue == 0)
|
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.gamma.min");
|
return caption + language->getElement(L"options.gamma.min");
|
||||||
}
|
}
|
||||||
if (progressValue == 1)
|
if (progressValue == 1) {
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.gamma.max");
|
return caption + language->getElement(L"options.gamma.max");
|
||||||
}
|
}
|
||||||
return caption + L"+" + _toString<int>((int) (progressValue * 100)) + L"%";
|
return caption + L"+" + _toString<int>((int)(progressValue * 100)) +
|
||||||
}
|
L"%";
|
||||||
else
|
} else {
|
||||||
{
|
if (progressValue == 0) {
|
||||||
if (progressValue == 0)
|
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.off");
|
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);
|
bool booleanValue = getBooleanValue(item);
|
||||||
if (booleanValue)
|
if (booleanValue) {
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.on");
|
return caption + language->getElement(L"options.on");
|
||||||
}
|
}
|
||||||
return caption + language->getElement(L"options.off");
|
return caption + language->getElement(L"options.off");
|
||||||
}
|
} else if (item == Option::RENDER_DISTANCE) {
|
||||||
else if (item == Option::RENDER_DISTANCE)
|
return caption +
|
||||||
{
|
language->getElement(RENDER_DISTANCE_NAMES[viewDistance]);
|
||||||
return caption + language->getElement(RENDER_DISTANCE_NAMES[viewDistance]);
|
} else if (item == Option::DIFFICULTY) {
|
||||||
}
|
|
||||||
else if (item == Option::DIFFICULTY)
|
|
||||||
{
|
|
||||||
return caption + language->getElement(DIFFICULTY_NAMES[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]);
|
return caption + language->getElement(GUI_SCALE[guiScale]);
|
||||||
}
|
} else if (item == Option::PARTICLES) {
|
||||||
else if (item == Option::PARTICLES)
|
|
||||||
{
|
|
||||||
return caption + language->getElement(PARTICLES[particles]);
|
return caption + language->getElement(PARTICLES[particles]);
|
||||||
}
|
} else if (item == Option::FRAMERATE_LIMIT) {
|
||||||
else if (item == Option::FRAMERATE_LIMIT)
|
|
||||||
{
|
|
||||||
return caption + I18n::get(FRAMERATE_LIMITS[framerateLimit]);
|
return caption + I18n::get(FRAMERATE_LIMITS[framerateLimit]);
|
||||||
}
|
} else if (item == Option::GRAPHICS) {
|
||||||
else if (item == Option::GRAPHICS)
|
if (fancyGraphics) {
|
||||||
{
|
|
||||||
if (fancyGraphics)
|
|
||||||
{
|
|
||||||
return caption + language->getElement(L"options.graphics.fancy");
|
return caption + language->getElement(L"options.graphics.fancy");
|
||||||
}
|
}
|
||||||
return caption + language->getElement(L"options.graphics.fast");
|
return caption + language->getElement(L"options.graphics.fast");
|
||||||
}
|
}
|
||||||
|
|
||||||
return caption;
|
return caption;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::load()
|
void Options::load() {
|
||||||
{
|
|
||||||
// 4J - removed try/catch
|
// 4J - removed try/catch
|
||||||
// try {
|
// try {
|
||||||
if (!optionsFile.exists()) return;
|
if (!optionsFile.exists()) return;
|
||||||
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
// 4J - was new BufferedReader(new FileReader(optionsFile));
|
||||||
BufferedReader *br = new BufferedReader(new InputStreamReader( new FileInputStream( optionsFile ) ) );
|
BufferedReader* br = new BufferedReader(
|
||||||
|
new InputStreamReader(new FileInputStream(optionsFile)));
|
||||||
|
|
||||||
std::wstring line = L"";
|
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?
|
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
|
// 4J - removed try/catch
|
||||||
// try {
|
// try {
|
||||||
std::wstring cmds[2];
|
std::wstring cmds[2];
|
||||||
int splitpos = (int)line.find(L":");
|
int splitpos = (int)line.find(L":");
|
||||||
if( splitpos == std::wstring::npos )
|
if (splitpos == std::wstring::npos) {
|
||||||
{
|
|
||||||
cmds[0] = line;
|
cmds[0] = line;
|
||||||
cmds[1] = L"";
|
cmds[1] = L"";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
cmds[0] = line.substr(0, splitpos);
|
cmds[0] = line.substr(0, splitpos);
|
||||||
cmds[1] = line.substr(splitpos, line.length() - splitpos);
|
cmds[1] = line.substr(splitpos, line.length() - splitpos);
|
||||||
}
|
}
|
||||||
|
|
@ -441,7 +386,8 @@ void Options::load()
|
||||||
if (cmds[0] == L"fov") fov = 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"gamma") gamma = readFloat(cmds[1]);
|
||||||
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1] == L"true";
|
if (cmds[0] == L"invertYMouse") invertYMouse = cmds[1] == L"true";
|
||||||
if (cmds[0] == L"viewDistance") viewDistance = _fromString<int>(cmds[1]);
|
if (cmds[0] == L"viewDistance")
|
||||||
|
viewDistance = _fromString<int>(cmds[1]);
|
||||||
if (cmds[0] == L"guiScale") guiScale = _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"particles") particles = _fromString<int>(cmds[1]);
|
||||||
if (cmds[0] == L"bobView") bobView = cmds[1] == L"true";
|
if (cmds[0] == L"bobView") bobView = cmds[1] == L"true";
|
||||||
|
|
@ -455,10 +401,8 @@ void Options::load()
|
||||||
if (cmds[0] == L"skin") skin = cmds[1];
|
if (cmds[0] == L"skin") skin = cmds[1];
|
||||||
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
|
if (cmds[0] == L"lastServer") lastMpIp = cmds[1];
|
||||||
|
|
||||||
for (int i = 0; i < keyMappings_length; i++)
|
for (int i = 0; i < keyMappings_length; i++) {
|
||||||
{
|
if (cmds[0] == (L"key_" + keyMappings[i]->name)) {
|
||||||
if (cmds[0] == (L"key_" + keyMappings[i]->name))
|
|
||||||
{
|
|
||||||
keyMappings[i]->key = _fromString<int>(cmds[1]);
|
keyMappings[i]->key = _fromString<int>(cmds[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -472,29 +416,28 @@ void Options::load()
|
||||||
// System.out.println("Failed to load options");
|
// System.out.println("Failed to load options");
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Options::readFloat(std::wstring string)
|
float Options::readFloat(std::wstring string) {
|
||||||
{
|
|
||||||
if (string == L"true") return 1;
|
if (string == L"true") return 1;
|
||||||
if (string == L"false") return 0;
|
if (string == L"false") return 0;
|
||||||
return _fromString<float>(string);
|
return _fromString<float>(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Options::save()
|
void Options::save() {
|
||||||
{
|
|
||||||
// 4J - try/catch removed
|
// 4J - try/catch removed
|
||||||
// try {
|
// try {
|
||||||
|
|
||||||
// 4J - original used a PrintWriter & FileWriter, but seems a bit much implementing these just to do this
|
// 4J - original used a PrintWriter & FileWriter, but seems a bit much
|
||||||
|
// implementing these just to do this
|
||||||
FileOutputStream fos = FileOutputStream(optionsFile);
|
FileOutputStream fos = FileOutputStream(optionsFile);
|
||||||
DataOutputStream dos = DataOutputStream(&fos);
|
DataOutputStream dos = DataOutputStream(&fos);
|
||||||
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
|
// PrintWriter pw = new PrintWriter(new FileWriter(optionsFile));
|
||||||
|
|
||||||
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
dos.writeChars(L"music:" + _toString<float>(music) + L"\n");
|
||||||
dos.writeChars(L"sound:" + _toString<float>(sound) + 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"invertYMouse:" +
|
||||||
|
std::wstring(invertYMouse ? L"true" : L"false") + L"\n");
|
||||||
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
dos.writeChars(L"mouseSensitivity:" + _toString<float>(sensitivity));
|
||||||
dos.writeChars(L"fov:" + _toString<float>(fov));
|
dos.writeChars(L"fov:" + _toString<float>(fov));
|
||||||
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
dos.writeChars(L"gamma:" + _toString<float>(gamma));
|
||||||
|
|
@ -502,19 +445,23 @@ void Options::save()
|
||||||
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
dos.writeChars(L"guiScale:" + _toString<int>(guiScale));
|
||||||
dos.writeChars(L"particles:" + _toString<int>(particles));
|
dos.writeChars(L"particles:" + _toString<int>(particles));
|
||||||
dos.writeChars(L"bobView:" + std::wstring(bobView ? L"true" : L"false"));
|
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"anaglyph3d:" +
|
||||||
dos.writeChars(L"advancedOpengl:" + std::wstring(advancedOpengl ? L"true" : L"false"));
|
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"fpsLimit:" + _toString<int>(framerateLimit));
|
||||||
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
dos.writeChars(L"difficulty:" + _toString<int>(difficulty));
|
||||||
dos.writeChars(L"fancyGraphics:" + std::wstring(fancyGraphics ? L"true" : L"false"));
|
dos.writeChars(L"fancyGraphics:" +
|
||||||
dos.writeChars(L"ao:" + std::wstring(ambientOcclusion ? L"true" : L"false"));
|
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"clouds:" + _toString<bool>(renderClouds));
|
||||||
dos.writeChars(L"skin:" + skin);
|
dos.writeChars(L"skin:" + skin);
|
||||||
dos.writeChars(L"lastServer:" + lastMpIp);
|
dos.writeChars(L"lastServer:" + lastMpIp);
|
||||||
|
|
||||||
for (int i = 0; i < keyMappings_length; i++)
|
for (int i = 0; i < keyMappings_length; i++) {
|
||||||
{
|
dos.writeChars(L"key_" + keyMappings[i]->name + L":" +
|
||||||
dos.writeChars(L"key_" + keyMappings[i]->name + L":" + _toString<int>(keyMappings[i]->key));
|
_toString<int>(keyMappings[i]->key));
|
||||||
}
|
}
|
||||||
|
|
||||||
dos.close();
|
dos.close();
|
||||||
|
|
@ -522,10 +469,6 @@ void Options::save()
|
||||||
// System.out.println("Failed to save options");
|
// System.out.println("Failed to save options");
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Options::isCloudsOn()
|
bool Options::isCloudsOn() { return viewDistance < 2 && renderClouds; }
|
||||||
{
|
|
||||||
return viewDistance < 2 && renderClouds;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,14 @@ class Minecraft;
|
||||||
class KeyMapping;
|
class KeyMapping;
|
||||||
#include "../../Minecraft.World/IO/Files/File.h"
|
#include "../../Minecraft.World/IO/Files/File.h"
|
||||||
|
|
||||||
class Options
|
class Options {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const int AO_OFF = 0;
|
static const int AO_OFF = 0;
|
||||||
static const int AO_MIN = 1;
|
static const int AO_MIN = 1;
|
||||||
static const int AO_MAX = 2;
|
static const int AO_MAX = 2;
|
||||||
|
|
||||||
// 4J - this used to be an enum
|
// 4J - this used to be an enum
|
||||||
class Option
|
class Option {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const Option options[17];
|
static const Option options[17];
|
||||||
static const Option* MUSIC;
|
static const Option* MUSIC;
|
||||||
|
|
@ -91,6 +89,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Minecraft* minecraft;
|
Minecraft* minecraft;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File optionsFile;
|
File optionsFile;
|
||||||
|
|
||||||
|
|
@ -123,8 +122,10 @@ public:
|
||||||
bool getBooleanValue(const Options::Option* item);
|
bool getBooleanValue(const Options::Option* item);
|
||||||
std::wstring getMessage(const Options::Option* item);
|
std::wstring getMessage(const Options::Option* item);
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float readFloat(std::wstring string);
|
float readFloat(std::wstring string);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,42 +3,31 @@
|
||||||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||||
|
|
||||||
// 4J - TODO - serialise/deserialise from file
|
// 4J - TODO - serialise/deserialise from file
|
||||||
Settings::Settings(File *file)
|
Settings::Settings(File* file) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::generateNewProperties()
|
void Settings::generateNewProperties() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void Settings::saveProperties()
|
void Settings::saveProperties() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring Settings::getString(const std::wstring& key, const std::wstring& defaultValue)
|
std::wstring Settings::getString(const std::wstring& key,
|
||||||
{
|
const std::wstring& defaultValue) {
|
||||||
if(properties.find(key) == properties.end())
|
if (properties.find(key) == properties.end()) {
|
||||||
{
|
|
||||||
properties[key] = defaultValue;
|
properties[key] = defaultValue;
|
||||||
saveProperties();
|
saveProperties();
|
||||||
}
|
}
|
||||||
return properties[key];
|
return properties[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Settings::getInt(const std::wstring& key, int defaultValue)
|
int Settings::getInt(const std::wstring& key, int defaultValue) {
|
||||||
{
|
if (properties.find(key) == properties.end()) {
|
||||||
if(properties.find(key) == properties.end())
|
|
||||||
{
|
|
||||||
properties[key] = _toString<int>(defaultValue);
|
properties[key] = _toString<int>(defaultValue);
|
||||||
saveProperties();
|
saveProperties();
|
||||||
}
|
}
|
||||||
return _fromString<int>(properties[key]);
|
return _fromString<int>(properties[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::getBoolean(const std::wstring& key, bool defaultValue)
|
bool Settings::getBoolean(const std::wstring& key, bool defaultValue) {
|
||||||
{
|
if (properties.find(key) == properties.end()) {
|
||||||
if(properties.find(key) == properties.end())
|
|
||||||
{
|
|
||||||
properties[key] = _toString<bool>(defaultValue);
|
properties[key] = _toString<bool>(defaultValue);
|
||||||
saveProperties();
|
saveProperties();
|
||||||
}
|
}
|
||||||
|
|
@ -48,8 +37,7 @@ bool Settings::getBoolean(const std::wstring& key, bool defaultValue)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setBooleanAndSave(const std::wstring& key, bool value)
|
void Settings::setBooleanAndSave(const std::wstring& key, bool value) {
|
||||||
{
|
|
||||||
properties[key] = _toString<bool>(value);
|
properties[key] = _toString<bool>(value);
|
||||||
saveProperties();
|
saveProperties();
|
||||||
}
|
}
|
||||||
|
|
@ -1,20 +1,21 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
class File;
|
class File;
|
||||||
|
|
||||||
|
class Settings {
|
||||||
class Settings
|
|
||||||
{
|
|
||||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
// private Properties properties = new Properties();
|
// private Properties properties = new Properties();
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::wstring,std::wstring> properties; // 4J - TODO was Properties type, will need to implement something we can serialise/deserialise too
|
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;
|
// File *file;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Settings(File* file);
|
Settings(File* file);
|
||||||
void generateNewProperties();
|
void generateNewProperties();
|
||||||
void saveProperties();
|
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);
|
int getInt(const std::wstring& key, int defaultValue);
|
||||||
bool getBoolean(const std::wstring& key, bool defaultValue);
|
bool getBoolean(const std::wstring& key, bool defaultValue);
|
||||||
void setBooleanAndSave(const std::wstring& key, bool value);
|
void setBooleanAndSave(const std::wstring& key, bool value);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -5,13 +5,9 @@ class Achievement;
|
||||||
class StatsSyncher;
|
class StatsSyncher;
|
||||||
class User;
|
class User;
|
||||||
|
|
||||||
|
class StatsCounter {
|
||||||
class StatsCounter
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
|
enum eDifficulty {
|
||||||
enum eDifficulty
|
|
||||||
{
|
|
||||||
eDifficulty_Peaceful = 0,
|
eDifficulty_Peaceful = 0,
|
||||||
eDifficulty_Easy,
|
eDifficulty_Easy,
|
||||||
eDifficulty_Normal,
|
eDifficulty_Normal,
|
||||||
|
|
@ -19,13 +15,12 @@ private:
|
||||||
eDifficulty_Max
|
eDifficulty_Max
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StatContainer
|
struct StatContainer {
|
||||||
{
|
|
||||||
unsigned int stats[eDifficulty_Max];
|
unsigned int stats[eDifficulty_Max];
|
||||||
|
|
||||||
StatContainer()
|
StatContainer() {
|
||||||
{
|
stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] =
|
||||||
stats[eDifficulty_Peaceful] = stats[eDifficulty_Easy] = stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0;
|
stats[eDifficulty_Normal] = stats[eDifficulty_Hard] = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -96,7 +91,8 @@ private:
|
||||||
void dumpStatsToTTY();
|
void dumpStatsToTTY();
|
||||||
|
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id, unsigned int value);
|
static void setLeaderboardProperty(XUSER_PROPERTY* prop, std::uint32_t id,
|
||||||
|
unsigned int value);
|
||||||
static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value);
|
static void setLeaderboardRating(XUSER_PROPERTY* prop, LONGLONG value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ class User;
|
||||||
class File;
|
class File;
|
||||||
class Stat;
|
class Stat;
|
||||||
|
|
||||||
|
class StatsSyncher {
|
||||||
class StatsSyncher
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int SAVE_INTERVAL = 20 * 5;
|
static const int SAVE_INTERVAL = 20 * 5;
|
||||||
static const int SEND_INTERVAL = 20 * 60;
|
static const int SEND_INTERVAL = 20 * 60;
|
||||||
|
|
@ -27,18 +25,24 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatsSyncher(User* user, StatsCounter* statsCounter, File* dir);
|
StatsSyncher(User* user, StatsCounter* statsCounter, File* dir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void attemptRename(File* dir, const std::wstring& name, File* to);
|
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, File* tmp,
|
||||||
|
File* old);
|
||||||
std::unordered_map<Stat*, int>* loadStatsFromDisk(File* file);
|
std::unordered_map<Stat*, int>* loadStatsFromDisk(File* file);
|
||||||
void doSend(std::unordered_map<Stat*, int>* stats);
|
void doSend(std::unordered_map<Stat*, int>* stats);
|
||||||
void doSave(std::unordered_map<Stat *, int> *stats, File *file, File *tmp, File *old);
|
void doSave(std::unordered_map<Stat*, int>* stats, File* file, File* tmp,
|
||||||
|
File* old);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unordered_map<Stat*, int>* doGetStats();
|
std::unordered_map<Stat*, int>* doGetStats();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void getStatsFromServer();
|
void getStatsFromServer();
|
||||||
void saveUnsent(std::unordered_map<Stat*, int>* stats);
|
void saveUnsent(std::unordered_map<Stat*, int>* stats);
|
||||||
void sendUnsent(std::unordered_map<Stat *, int> *stats, std::unordered_map<Stat *, int> *fullStats);
|
void sendUnsent(std::unordered_map<Stat*, int>* stats,
|
||||||
|
std::unordered_map<Stat*, int>* fullStats);
|
||||||
void forceSendUnsent(std::unordered_map<Stat*, int>* stats);
|
void forceSendUnsent(std::unordered_map<Stat*, int>* stats);
|
||||||
void forceSaveUnsent(std::unordered_map<Stat*, int>* stats);
|
void forceSaveUnsent(std::unordered_map<Stat*, int>* stats);
|
||||||
bool maySave();
|
bool maySave();
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,7 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||||
#include "../ClientConstants.h"
|
#include "../ClientConstants.h"
|
||||||
|
|
||||||
SurvivalMode::SurvivalMode(Minecraft *minecraft) : GameMode(minecraft)
|
SurvivalMode::SurvivalMode(Minecraft* minecraft) : GameMode(minecraft) {
|
||||||
{
|
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
xDestroyBlock = -1;
|
xDestroyBlock = -1;
|
||||||
yDestroyBlock = -1;
|
yDestroyBlock = -1;
|
||||||
|
|
@ -22,20 +21,18 @@ SurvivalMode::SurvivalMode(Minecraft *minecraft) : GameMode(minecraft)
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
destroyDelay = 0;
|
destroyDelay = 0;
|
||||||
|
|
||||||
if (ClientConstants::IS_DEMO_VERSION)
|
if (ClientConstants::IS_DEMO_VERSION) {
|
||||||
{
|
if (dynamic_cast<DemoMode*>(this) == NULL) {
|
||||||
if( dynamic_cast<DemoMode *>(this) == NULL )
|
|
||||||
{
|
|
||||||
assert(false);
|
assert(false);
|
||||||
// throw new IllegalStateException("Invalid game mode"); // 4J - removed
|
// 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
|
// 4J Stu - Added this ctor so we can exit the tutorial and replace it with a
|
||||||
// survival mode
|
// standard survival mode
|
||||||
SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
|
SurvivalMode::SurvivalMode(SurvivalMode* copy) : GameMode(copy->minecraft) {
|
||||||
{
|
|
||||||
xDestroyBlock = copy->xDestroyBlock;
|
xDestroyBlock = copy->xDestroyBlock;
|
||||||
yDestroyBlock = copy->yDestroyBlock;
|
yDestroyBlock = copy->yDestroyBlock;
|
||||||
zDestroyBlock = copy->zDestroyBlock;
|
zDestroyBlock = copy->zDestroyBlock;
|
||||||
|
|
@ -45,71 +42,56 @@ SurvivalMode::SurvivalMode(SurvivalMode *copy) : GameMode( copy->minecraft )
|
||||||
destroyDelay = copy->destroyDelay;
|
destroyDelay = copy->destroyDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::initPlayer(std::shared_ptr<Player> player)
|
void SurvivalMode::initPlayer(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
player->yRot = -180;
|
player->yRot = -180;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::init()
|
void SurvivalMode::init() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SurvivalMode::canHurtPlayer()
|
bool SurvivalMode::canHurtPlayer() { return true; }
|
||||||
{
|
|
||||||
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 t = minecraft->level->getTile(x, y, z);
|
||||||
int data = minecraft->level->getData(x, y, z);
|
int data = minecraft->level->getData(x, y, z);
|
||||||
bool changed = GameMode::destroyBlock(x, y, z, face);
|
bool changed = GameMode::destroyBlock(x, y, z, face);
|
||||||
|
|
||||||
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
||||||
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
|
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
|
||||||
if (item != NULL)
|
if (item != NULL) {
|
||||||
{
|
|
||||||
item->mineBlock(minecraft->level, t, x, y, z, minecraft->player);
|
item->mineBlock(minecraft->level, t, x, y, z, minecraft->player);
|
||||||
if (item->count == 0)
|
if (item->count == 0) {
|
||||||
{
|
|
||||||
minecraft->player->removeSelectedItem();
|
minecraft->player->removeSelectedItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed && couldDestroy)
|
if (changed && couldDestroy) {
|
||||||
{
|
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y,
|
||||||
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y, z, data);
|
z, data);
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::startDestroyBlock(int x, int y, int z, int face)
|
void SurvivalMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
if (!minecraft->player->mayBuild(x, y, z)) return;
|
if (!minecraft->player->mayBuild(x, y, z)) return;
|
||||||
minecraft->level->extinguishFire(minecraft->player, x, y, z, face);
|
minecraft->level->extinguishFire(minecraft->player, x, y, z, face);
|
||||||
int t = minecraft->level->getTile(x, y, z);
|
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 && destroyProgress == 0)
|
||||||
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1)
|
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);
|
destroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::stopDestroyBlock()
|
void SurvivalMode::stopDestroyBlock() {
|
||||||
{
|
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
destroyDelay = 0;
|
destroyDelay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
|
void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
if (destroyDelay > 0) {
|
||||||
if (destroyDelay > 0)
|
|
||||||
{
|
|
||||||
destroyDelay--;
|
destroyDelay--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock)
|
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
|
||||||
{
|
|
||||||
int t = minecraft->level->getTile(x, y, z);
|
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;
|
if (t == 0) return;
|
||||||
|
|
@ -117,27 +99,25 @@ void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
|
||||||
|
|
||||||
destroyProgress += tile->getDestroyProgress(minecraft->player);
|
destroyProgress += tile->getDestroyProgress(minecraft->player);
|
||||||
|
|
||||||
if (destroyTicks % 4 == 0)
|
if (destroyTicks % 4 == 0) {
|
||||||
{
|
if (tile != NULL) {
|
||||||
if (tile != NULL)
|
minecraft->soundEngine->play(
|
||||||
{
|
tile->soundType->getStepSound(), x + 0.5f, y + 0.5f,
|
||||||
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);
|
z + 0.5f, (tile->soundType->getVolume() + 1) / 8,
|
||||||
|
tile->soundType->getPitch() * 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyTicks++;
|
destroyTicks++;
|
||||||
|
|
||||||
if (destroyProgress >= 1)
|
if (destroyProgress >= 1) {
|
||||||
{
|
|
||||||
destroyBlock(x, y, z, face);
|
destroyBlock(x, y, z, face);
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
oDestroyProgress = 0;
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
oDestroyProgress = 0;
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
|
|
@ -145,36 +125,24 @@ void SurvivalMode::continueDestroyBlock(int x, int y, int z, int face)
|
||||||
yDestroyBlock = y;
|
yDestroyBlock = y;
|
||||||
zDestroyBlock = z;
|
zDestroyBlock = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::render(float a)
|
void SurvivalMode::render(float a) {
|
||||||
{
|
if (destroyProgress <= 0) {
|
||||||
if (destroyProgress <= 0)
|
|
||||||
{
|
|
||||||
minecraft->gui->progress = 0;
|
minecraft->gui->progress = 0;
|
||||||
minecraft->levelRenderer->destroyProgress = 0;
|
minecraft->levelRenderer->destroyProgress = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
float dp = oDestroyProgress + (destroyProgress - oDestroyProgress) * a;
|
float dp = oDestroyProgress + (destroyProgress - oDestroyProgress) * a;
|
||||||
minecraft->gui->progress = dp;
|
minecraft->gui->progress = dp;
|
||||||
minecraft->levelRenderer->destroyProgress = dp;
|
minecraft->levelRenderer->destroyProgress = dp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float SurvivalMode::getPickRange()
|
float SurvivalMode::getPickRange() { return 4.0f; }
|
||||||
{
|
|
||||||
return 4.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SurvivalMode::initLevel(Level *level)
|
void SurvivalMode::initLevel(Level* level) { GameMode::initLevel(level); }
|
||||||
{
|
|
||||||
GameMode::initLevel(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
|
std::shared_ptr<Player> SurvivalMode::createPlayer(Level* level) {
|
||||||
{
|
|
||||||
std::shared_ptr<Player> player = GameMode::createPlayer(level);
|
std::shared_ptr<Player> player = GameMode::createPlayer(level);
|
||||||
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
|
// player.inventory.add(new ItemInstance(Item.pickAxe_diamond));
|
||||||
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
|
// player.inventory.add(new ItemInstance(Item.hatchet_diamond));
|
||||||
|
|
@ -185,24 +153,21 @@ std::shared_ptr<Player> SurvivalMode::createPlayer(Level *level)
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurvivalMode::tick()
|
void SurvivalMode::tick() {
|
||||||
{
|
|
||||||
oDestroyProgress = destroyProgress;
|
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)
|
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);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0)
|
if (t > 0) {
|
||||||
{
|
|
||||||
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;
|
if (item == NULL) return false;
|
||||||
return item->useOn(player, level, x, y, z, face);
|
return item->useOn(player, level, x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SurvivalMode::hasExperience()
|
bool SurvivalMode::hasExperience() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "GameMode.h"
|
#include "GameMode.h"
|
||||||
|
|
||||||
class SurvivalMode : public GameMode
|
class SurvivalMode : public GameMode {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
int xDestroyBlock;
|
int xDestroyBlock;
|
||||||
int yDestroyBlock;
|
int yDestroyBlock;
|
||||||
|
|
@ -27,6 +26,9 @@ public:
|
||||||
virtual void initLevel(Level* level);
|
virtual void initLevel(Level* level);
|
||||||
virtual std::shared_ptr<Player> createPlayer(Level* level);
|
virtual std::shared_ptr<Player> createPlayer(Level* level);
|
||||||
virtual void tick();
|
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 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 hasExperience();
|
||||||
};
|
};
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#include "../Platform/stdafx.h"
|
#include "../Platform/stdafx.h"
|
||||||
#include "ConsoleInput.h"
|
#include "ConsoleInput.h"
|
||||||
|
|
||||||
ConsoleInput::ConsoleInput(const std::wstring& msg, ConsoleInputSource *source)
|
ConsoleInput::ConsoleInput(const std::wstring& msg,
|
||||||
{
|
ConsoleInputSource* source) {
|
||||||
this->msg = msg;
|
this->msg = msg;
|
||||||
this->source = source;
|
this->source = source;
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ConsoleInputSource.h"
|
#include "ConsoleInputSource.h"
|
||||||
|
|
||||||
|
class ConsoleInput {
|
||||||
class ConsoleInput
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
std::wstring msg;
|
std::wstring msg;
|
||||||
ConsoleInputSource* source;
|
ConsoleInputSource* source;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class ConsoleInputSource
|
class ConsoleInputSource {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~ConsoleInputSource() {}
|
virtual ~ConsoleInputSource() {}
|
||||||
virtual void info(const std::wstring& string) = 0;
|
virtual void info(const std::wstring& string) = 0;
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@
|
||||||
#include "../Player/LocalPlayer.h"
|
#include "../Player/LocalPlayer.h"
|
||||||
#include "../GameState/Options.h"
|
#include "../GameState/Options.h"
|
||||||
|
|
||||||
Input::Input()
|
Input::Input() {
|
||||||
{
|
|
||||||
xa = 0;
|
xa = 0;
|
||||||
ya = 0;
|
ya = 0;
|
||||||
wasJumping = false;
|
wasJumping = false;
|
||||||
|
|
@ -21,54 +20,57 @@ Input::Input()
|
||||||
rReset = false;
|
rReset = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::tick(LocalPlayer *player)
|
void Input::tick(LocalPlayer* player) {
|
||||||
{
|
// 4J Stu - Assume that we only need one input class, even though the java
|
||||||
// 4J Stu - Assume that we only need one input class, even though the java has subclasses for keyboard/controller
|
// has subclasses for keyboard/controller This function is based on the
|
||||||
// This function is based on the ControllerInput class in the Java, and will probably need changed
|
// ControllerInput class in the Java, and will probably need changed
|
||||||
// OutputDebugString("INPUT: Beginning input tick\n");
|
// OutputDebugString("INPUT: Beginning input tick\n");
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
int iPad = player->GetXboxPad();
|
int iPad = player->GetXboxPad();
|
||||||
|
|
||||||
// 4J-PB minecraft movement seems to be the wrong way round, so invert x!
|
// 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) )
|
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
|
MINECRAFT_ACTION_LEFT) ||
|
||||||
|
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
|
MINECRAFT_ACTION_RIGHT))
|
||||||
xa = -InputManager.GetJoypadStick_LX(iPad);
|
xa = -InputManager.GetJoypadStick_LX(iPad);
|
||||||
else
|
else
|
||||||
xa = 0.0f;
|
xa = 0.0f;
|
||||||
|
|
||||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_FORWARD) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_BACKWARD) )
|
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
|
MINECRAFT_ACTION_FORWARD) ||
|
||||||
|
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
|
MINECRAFT_ACTION_BACKWARD))
|
||||||
ya = InputManager.GetJoypadStick_LY(iPad);
|
ya = InputManager.GetJoypadStick_LY(iPad);
|
||||||
else
|
else
|
||||||
ya = 0.0f;
|
ya = 0.0f;
|
||||||
|
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
if (app.GetFreezePlayers())
|
if (app.GetFreezePlayers()) {
|
||||||
{
|
|
||||||
xa = ya = 0.0f;
|
xa = ya = 0.0f;
|
||||||
player->abilities.flying = true;
|
player->abilities.flying = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!lReset)
|
if (!lReset) {
|
||||||
{
|
if (xa * xa + ya * ya == 0.0f) {
|
||||||
if (xa*xa+ya*ya==0.0f)
|
|
||||||
{
|
|
||||||
lReset = true;
|
lReset = true;
|
||||||
}
|
}
|
||||||
xa = ya = 0.0f;
|
xa = ya = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - in flying mode, don't actually toggle sneaking
|
// 4J - in flying mode, don't actually toggle sneaking
|
||||||
if(!player->abilities.flying)
|
if (!player->abilities.flying) {
|
||||||
{
|
if ((player->ullButtonsPressed &
|
||||||
if((player->ullButtonsPressed&(1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE)) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SNEAK_TOGGLE))
|
(1LL << MINECRAFT_ACTION_SNEAK_TOGGLE)) &&
|
||||||
{
|
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
|
MINECRAFT_ACTION_SNEAK_TOGGLE)) {
|
||||||
sneaking = !sneaking;
|
sneaking = !sneaking;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sneaking)
|
if (sneaking) {
|
||||||
{
|
|
||||||
xa *= 0.3f;
|
xa *= 0.3f;
|
||||||
ya *= 0.3f;
|
ya *= 0.3f;
|
||||||
}
|
}
|
||||||
|
|
@ -77,25 +79,34 @@ void Input::tick(LocalPlayer *player)
|
||||||
|
|
||||||
float tx = 0.0f;
|
float tx = 0.0f;
|
||||||
float ty = 0.0f;
|
float ty = 0.0f;
|
||||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_LEFT) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_RIGHT) )
|
if (pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
tx = InputManager.GetJoypadStick_RX(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
|
MINECRAFT_ACTION_LOOK_LEFT) ||
|
||||||
if( pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_UP) || pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_LOOK_DOWN) )
|
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
ty = InputManager.GetJoypadStick_RY(iPad)*(((float)app.GetGameSettings(iPad,eGameSetting_Sensitivity_InGame))/100.0f); // apply sensitivity to look
|
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
|
#ifndef _CONTENT_PACKAGE
|
||||||
if (app.GetFreezePlayers()) tx = ty = 0.0f;
|
if (app.GetFreezePlayers()) tx = ty = 0.0f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 4J: WESTY : Invert look Y if required.
|
// 4J: WESTY : Invert look Y if required.
|
||||||
if ( app.GetGameSettings(iPad,eGameSetting_ControlInvertLook) )
|
if (app.GetGameSettings(iPad, eGameSetting_ControlInvertLook)) {
|
||||||
{
|
|
||||||
ty = -ty;
|
ty = -ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rReset)
|
if (!rReset) {
|
||||||
{
|
if (tx * tx + ty * ty == 0.0f) {
|
||||||
if (tx*tx+ty*ty==0.0f)
|
|
||||||
{
|
|
||||||
rReset = true;
|
rReset = true;
|
||||||
}
|
}
|
||||||
tx = ty = 0.0f;
|
tx = ty = 0.0f;
|
||||||
|
|
@ -104,8 +115,12 @@ void Input::tick(LocalPlayer *player)
|
||||||
|
|
||||||
// jumping = controller.isButtonPressed(0);
|
// jumping = controller.isButtonPressed(0);
|
||||||
|
|
||||||
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SPRINT);
|
sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) &&
|
||||||
jumping = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
|
pMinecraft->localgameModes[iPad]->isInputAllowed(
|
||||||
|
MINECRAFT_ACTION_SPRINT);
|
||||||
|
jumping =
|
||||||
|
InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) &&
|
||||||
|
pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP);
|
||||||
|
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
if (app.GetFreezePlayers()) jumping = false;
|
if (app.GetFreezePlayers()) jumping = false;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
class Input
|
class Input {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
float xa;
|
float xa;
|
||||||
float ya;
|
float ya;
|
||||||
|
|
@ -18,7 +17,6 @@ public:
|
||||||
virtual void tick(LocalPlayer* player);
|
virtual void tick(LocalPlayer* player);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool lReset;
|
bool lReset;
|
||||||
bool rReset;
|
bool rReset;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#include "../Platform/stdafx.h"
|
#include "../Platform/stdafx.h"
|
||||||
#include "KeyMapping.h"
|
#include "KeyMapping.h"
|
||||||
|
|
||||||
KeyMapping::KeyMapping(const std::wstring& name, int key)
|
KeyMapping::KeyMapping(const std::wstring& name, int key) {
|
||||||
{
|
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->key = key;
|
this->key = key;
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// 4J Stu - Not updated to 1.8.2 as we don't use this
|
// 4J Stu - Not updated to 1.8.2 as we don't use this
|
||||||
class KeyMapping
|
class KeyMapping {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
std::wstring name;
|
std::wstring name;
|
||||||
int key;
|
int key;
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,17 @@
|
||||||
#include "DemoLevel.h"
|
#include "DemoLevel.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.storage.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.storage.h"
|
||||||
|
|
||||||
LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS = LevelSettings(
|
LevelSettings DemoLevel::DEMO_LEVEL_SETTINGS =
|
||||||
DemoLevel::DEMO_LEVEL_SEED,
|
LevelSettings(DemoLevel::DEMO_LEVEL_SEED, GameType::SURVIVAL, false, false,
|
||||||
GameType::SURVIVAL,
|
false, LevelType::lvl_normal_1_1, LEVEL_MAX_WIDTH, 1.0);
|
||||||
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()
|
void DemoLevel::setInitialSpawn() {
|
||||||
{
|
|
||||||
levelData->setSpawn(DEMO_SPAWN_X, DEMO_SPAWN_Y, DEMO_SPAWN_Z);
|
levelData->setSpawn(DEMO_SPAWN_X, DEMO_SPAWN_Y, DEMO_SPAWN_Z);
|
||||||
}
|
}
|
||||||
|
|
@ -1,17 +1,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
|
|
||||||
class DemoLevel : public Level
|
class DemoLevel : public Level {
|
||||||
{
|
|
||||||
private:
|
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_X = 796;
|
||||||
static const int DEMO_SPAWN_Y = 72;
|
static const int DEMO_SPAWN_Y = 72;
|
||||||
static const int DEMO_SPAWN_Z = -731;
|
static const int DEMO_SPAWN_Z = -731;
|
||||||
static LevelSettings DEMO_LEVEL_SETTINGS;
|
static LevelSettings DEMO_LEVEL_SETTINGS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DemoLevel(std::shared_ptr<LevelStorage> levelStorage, const std::wstring& levelName);
|
DemoLevel(std::shared_ptr<LevelStorage> levelStorage,
|
||||||
|
const std::wstring& levelName);
|
||||||
DemoLevel(Level* level, Dimension* dimension);
|
DemoLevel(Level* level, Dimension* dimension);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setInitialSpawn();
|
virtual void setInitialSpawn();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@
|
||||||
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
|
#include "../../Minecraft.World/Level/Storage/SavedDataStorage.h"
|
||||||
#include "../../Minecraft.World/Level/DerivedLevelData.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)
|
DerivedServerLevel::DerivedServerLevel(
|
||||||
: ServerLevel(server, levelStorage, levelName, dimension, levelSettings)
|
MinecraftServer* server, std::shared_ptr<LevelStorage> levelStorage,
|
||||||
{
|
const std::wstring& levelName, int dimension, LevelSettings* levelSettings,
|
||||||
// 4J-PB - we're going to override the savedDataStorage, so we need to delete the current one
|
ServerLevel* wrapped)
|
||||||
if(this->savedDataStorage)
|
: 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;
|
delete this->savedDataStorage;
|
||||||
this->savedDataStorage = NULL;
|
this->savedDataStorage = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -16,14 +18,13 @@ DerivedServerLevel::DerivedServerLevel(MinecraftServer *server, std::shared_ptr<
|
||||||
levelData = new DerivedLevelData(wrapped->getLevelData());
|
levelData = new DerivedLevelData(wrapped->getLevelData());
|
||||||
}
|
}
|
||||||
|
|
||||||
DerivedServerLevel::~DerivedServerLevel()
|
DerivedServerLevel::~DerivedServerLevel() {
|
||||||
{
|
// we didn't allocate savedDataStorage here, so we don't want the level
|
||||||
// we didn't allocate savedDataStorage here, so we don't want the level destructor to delete it
|
// destructor to delete it
|
||||||
this->savedDataStorage = NULL;
|
this->savedDataStorage = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DerivedServerLevel::saveLevelData()
|
void DerivedServerLevel::saveLevelData() {
|
||||||
{
|
|
||||||
// Do nothing?
|
// Do nothing?
|
||||||
// Do nothing!
|
// Do nothing!
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "ServerLevel.h"
|
#include "ServerLevel.h"
|
||||||
|
|
||||||
class DerivedServerLevel : public ServerLevel
|
class DerivedServerLevel : public ServerLevel {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
DerivedServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings, ServerLevel *wrapped);
|
DerivedServerLevel(MinecraftServer* server,
|
||||||
|
std::shared_ptr<LevelStorage> levelStorage,
|
||||||
|
const std::wstring& levelName, int dimension,
|
||||||
|
LevelSettings* levelSettings, ServerLevel* wrapped);
|
||||||
~DerivedServerLevel();
|
~DerivedServerLevel();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -8,73 +8,85 @@
|
||||||
class ClientConnection;
|
class ClientConnection;
|
||||||
class MultiPlayerChunkCache;
|
class MultiPlayerChunkCache;
|
||||||
|
|
||||||
|
class MultiPlayerLevel : public Level {
|
||||||
|
|
||||||
class MultiPlayerLevel : public Level
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int TICKS_BEFORE_RESET = 20 * 4;
|
static const int TICKS_BEFORE_RESET = 20 * 4;
|
||||||
|
|
||||||
class ResetInfo
|
class ResetInfo {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
int x, y, z, ticks, tile, data;
|
int x, y, z, ticks, tile, data;
|
||||||
ResetInfo(int x, int y, int z, int tile, int 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
|
std::vector<ResetInfo> updatesToReset; // 4J - was linked list but vector
|
||||||
|
// seems more appropriate
|
||||||
bool m_bEnableResetChanges; // 4J Added
|
bool m_bEnableResetChanges; // 4J Added
|
||||||
public:
|
public:
|
||||||
void unshareChunkAt(int x, int z); // 4J - added
|
void unshareChunkAt(int x, int z); // 4J - added
|
||||||
void shareChunkAt(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:
|
private:
|
||||||
int unshareCheckX; // 4J - added
|
int unshareCheckX; // 4J - added
|
||||||
int unshareCheckZ; // 4J - added
|
int unshareCheckZ; // 4J - added
|
||||||
int compressCheckX; // 4J - added
|
int compressCheckX; // 4J - added
|
||||||
int compressCheckZ; // 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
|
std::vector<ClientConnection*>
|
||||||
|
connections; // 4J Stu - Made this a vector as we can have more than
|
||||||
|
// one local connection
|
||||||
MultiPlayerChunkCache* chunkCache;
|
MultiPlayerChunkCache* chunkCache;
|
||||||
Minecraft* minecraft;
|
Minecraft* minecraft;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiPlayerLevel(ClientConnection *connection, LevelSettings *levelSettings, int dimension, int difficulty);
|
MultiPlayerLevel(ClientConnection* connection, LevelSettings* levelSettings,
|
||||||
|
int dimension, int difficulty);
|
||||||
virtual ~MultiPlayerLevel();
|
virtual ~MultiPlayerLevel();
|
||||||
virtual void tick();
|
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:
|
protected:
|
||||||
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
ChunkSource*
|
||||||
|
createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||||
public:
|
public:
|
||||||
virtual void validateSpawn();
|
virtual void validateSpawn();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void tickTiles();
|
virtual void tickTiles();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setChunkVisible(int x, int z, bool visible);
|
void setChunkVisible(int x, int z, bool visible);
|
||||||
|
|
||||||
private:
|
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> > forced;
|
||||||
std::unordered_set<std::shared_ptr<Entity> > reEntries;
|
std::unordered_set<std::shared_ptr<Entity> > reEntries;
|
||||||
|
|
||||||
public:
|
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);
|
virtual void removeEntity(std::shared_ptr<Entity> e);
|
||||||
|
|
||||||
protected:
|
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);
|
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||||
|
|
||||||
public:
|
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> getEntity(int id);
|
||||||
std::shared_ptr<Entity> removeEntity(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 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);
|
virtual bool setTileNoUpdate(int x, int y, int z, int tile);
|
||||||
bool doSetTileAndData(int x, int y, int z, int tile, int data);
|
bool doSetTileAndData(int x, int y, int z, int tile, int data);
|
||||||
virtual void disconnect(bool sendDisconnect = true);
|
virtual void disconnect(bool sendDisconnect = true);
|
||||||
void animateTick(int xt, int yt, int zt);
|
void animateTick(int xt, int yt, int zt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void tickWeather();
|
virtual void tickWeather();
|
||||||
|
|
||||||
|
|
@ -87,9 +99,12 @@ public:
|
||||||
public:
|
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
|
// 4J Stu - Added so we can have multiple local connections
|
||||||
void addClientConnection(ClientConnection* c) { connections.push_back(c); }
|
void addClientConnection(ClientConnection* c) { connections.push_back(c); }
|
||||||
|
|
@ -98,5 +113,6 @@ public:
|
||||||
void tickAllConnections();
|
void tickAllConnections();
|
||||||
|
|
||||||
void dataReceivedForChunk(int x, int z); // 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
|
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
|
|
@ -7,9 +7,7 @@ class Node;
|
||||||
class EntityTracker;
|
class EntityTracker;
|
||||||
class PlayerChunkMap;
|
class PlayerChunkMap;
|
||||||
|
|
||||||
|
class ServerLevel : public Level {
|
||||||
class ServerLevel : public Level
|
|
||||||
{
|
|
||||||
private:
|
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;
|
||||||
|
|
||||||
|
|
@ -18,8 +16,11 @@ private:
|
||||||
PlayerChunkMap* chunkMap;
|
PlayerChunkMap* chunkMap;
|
||||||
|
|
||||||
CRITICAL_SECTION m_tickNextTickCS; // 4J added
|
CRITICAL_SECTION m_tickNextTickCS; // 4J added
|
||||||
std::set<TickNextTickData, TickNextTickDataKeyCompare> tickNextTickList; // 4J Was TreeSet
|
std::set<TickNextTickData, TickNextTickDataKeyCompare>
|
||||||
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash, TickNextTickDataKeyEq> tickNextTickSet; // 4J Was HashSet
|
tickNextTickList; // 4J Was TreeSet
|
||||||
|
std::unordered_set<TickNextTickData, TickNextTickDataKeyHash,
|
||||||
|
TickNextTickDataKeyEq>
|
||||||
|
tickNextTickSet; // 4J Was HashSet
|
||||||
|
|
||||||
std::vector<Pos*> m_queuedSendTileUpdates; // 4J added
|
std::vector<Pos*> m_queuedSendTileUpdates; // 4J added
|
||||||
CRITICAL_SECTION m_csQueueSendTileUpdates;
|
CRITICAL_SECTION m_csQueueSendTileUpdates;
|
||||||
|
|
@ -31,21 +32,29 @@ public:
|
||||||
ServerChunkCache* cache;
|
ServerChunkCache* cache;
|
||||||
bool canEditSpawn;
|
bool canEditSpawn;
|
||||||
bool noSave;
|
bool noSave;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool allPlayersSleeping;
|
bool allPlayersSleeping;
|
||||||
int emptyTime;
|
int emptyTime;
|
||||||
bool m_bAtLeastOnePlayerSleeping; // 4J Added
|
bool m_bAtLeastOnePlayerSleeping; // 4J Added
|
||||||
static WeighedTreasureArray RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
|
static WeighedTreasureArray
|
||||||
|
RANDOM_BONUS_ITEMS; // 4J - brought forward from 1.3.2
|
||||||
|
|
||||||
std::vector<TileEventData> tileEvents[2];
|
std::vector<TileEventData> tileEvents[2];
|
||||||
int activeTileEventsList;
|
int activeTileEventsList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void staticCtor();
|
static void staticCtor();
|
||||||
ServerLevel(MinecraftServer *server, std::shared_ptr<LevelStorage>levelStorage, const std::wstring& levelName, int dimension, LevelSettings *levelSettings);
|
ServerLevel(MinecraftServer* server,
|
||||||
|
std::shared_ptr<LevelStorage> levelStorage,
|
||||||
|
const std::wstring& levelName, int dimension,
|
||||||
|
LevelSettings* levelSettings);
|
||||||
~ServerLevel();
|
~ServerLevel();
|
||||||
void tick();
|
void tick();
|
||||||
Biome::MobSpawnerData *getRandomMobSpawnAt(MobCategory *mobCategory, int x, int y, int z);
|
Biome::MobSpawnerData* getRandomMobSpawnAt(MobCategory* mobCategory, int x,
|
||||||
|
int y, int z);
|
||||||
void updateSleepingPlayerList();
|
void updateSleepingPlayerList();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void awakenAllPlayers();
|
void awakenAllPlayers();
|
||||||
|
|
||||||
|
|
@ -64,16 +73,24 @@ public:
|
||||||
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
void forceAddTileTick(int x, int y, int z, int tileId, int tickDelay);
|
||||||
void tickEntities();
|
void tickEntities();
|
||||||
bool tickPendingTicks(bool force);
|
bool tickPendingTicks(bool force);
|
||||||
std::vector<TickNextTickData> *fetchTicksInChunk(LevelChunk *chunk, bool remove);
|
std::vector<TickNextTickData>* fetchTicksInChunk(LevelChunk* chunk,
|
||||||
|
bool remove);
|
||||||
virtual void tick(std::shared_ptr<Entity> e, bool actual);
|
virtual void tick(std::shared_ptr<Entity> e, bool actual);
|
||||||
void forceTick(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 AllPlayersAreSleeping() {
|
||||||
|
return allPlayersSleeping;
|
||||||
|
} // 4J added for a message to other players
|
||||||
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping; }
|
bool isAtLeastOnePlayerSleeping() { return m_bAtLeastOnePlayerSleeping; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ChunkSource *createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
ChunkSource*
|
||||||
|
createChunkSource(); // 4J - was virtual, but was called from parent ctor
|
||||||
public:
|
public:
|
||||||
std::vector<std::shared_ptr<TileEntity> > *getTileEntitiesInRegion(int x0, int y0, int z0, int x1, int y1, int z1);
|
std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion(
|
||||||
virtual bool mayInteract(std::shared_ptr<Player> player, int xt, int yt, int zt, int id);
|
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:
|
protected:
|
||||||
virtual void initializeLevel(LevelSettings* settings);
|
virtual void initializeLevel(LevelSettings* settings);
|
||||||
virtual void setInitialSpawn(LevelSettings* settings);
|
virtual void setInitialSpawn(LevelSettings* settings);
|
||||||
|
|
@ -84,22 +101,31 @@ public:
|
||||||
|
|
||||||
void Suspend(); // 4j Added for XboxOne PLM
|
void Suspend(); // 4j Added for XboxOne PLM
|
||||||
|
|
||||||
void save(bool force, ProgressListener *progressListener, bool bAutosave=false);
|
void save(bool force, ProgressListener* progressListener,
|
||||||
void saveToDisc(ProgressListener *progressListener, bool autosave); // 4J Added
|
bool bAutosave = false);
|
||||||
|
void saveToDisc(ProgressListener* progressListener,
|
||||||
|
bool autosave); // 4J Added
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void saveLevelData();
|
void saveLevelData();
|
||||||
|
|
||||||
typedef std::unordered_map<int, std::shared_ptr<Entity> , IntKeyHash2, IntKeyEq> intEntityMap;
|
typedef std::unordered_map<int, std::shared_ptr<Entity>, IntKeyHash2,
|
||||||
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing function as this uses
|
IntKeyEq>
|
||||||
|
intEntityMap;
|
||||||
|
intEntityMap entitiesById; // 4J - was IntHashMap, using same hashing
|
||||||
|
// function as this uses
|
||||||
protected:
|
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);
|
virtual void entityRemoved(std::shared_ptr<Entity> e);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<Entity> getEntity(int id);
|
std::shared_ptr<Entity> getEntity(int id);
|
||||||
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
|
virtual bool addGlobalEntity(std::shared_ptr<Entity> e);
|
||||||
void broadcastEntityEvent(std::shared_ptr<Entity> e, uint8_t event);
|
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);
|
virtual void tileEvent(int x, int y, int z, int tile, int b0, int b1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -108,6 +134,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void closeLevelStorage();
|
void closeLevelStorage();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void tickWeather();
|
virtual void tickWeather();
|
||||||
|
|
||||||
|
|
@ -121,9 +148,9 @@ public:
|
||||||
private:
|
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:
|
public:
|
||||||
|
|
||||||
static const int MAX_HANGING_ENTITIES = 400;
|
static const int MAX_HANGING_ENTITIES = 400;
|
||||||
static const int MAX_ITEM_ENTITIES = 200;
|
static const int MAX_ITEM_ENTITIES = 200;
|
||||||
static const int MAX_ARROW_ENTITIES = 200;
|
static const int MAX_ARROW_ENTITIES = 200;
|
||||||
|
|
@ -146,12 +173,14 @@ public:
|
||||||
virtual bool newPrimedTntAllowed();
|
virtual bool newPrimedTntAllowed();
|
||||||
virtual bool newFallingTileAllowed();
|
virtual bool newFallingTileAllowed();
|
||||||
|
|
||||||
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
void flagEntitiesToBeRemoved(unsigned int* flags,
|
||||||
|
bool* removedFound); // 4J added
|
||||||
|
|
||||||
// 4J added
|
// 4J added
|
||||||
static const int MAX_UPDATES = 256;
|
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
|
// 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 Level* m_level[3];
|
||||||
static int m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
static int m_updateChunkX[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
||||||
static int m_updateChunkZ[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
static int m_updateChunkZ[3][LEVEL_CHUNKS_TO_UPDATE_MAX];
|
||||||
|
|
@ -167,5 +196,4 @@ public:
|
||||||
|
|
||||||
static C4JThread* m_updateThread;
|
static C4JThread* m_updateThread;
|
||||||
static int runUpdate(void* lpParam);
|
static int runUpdate(void* lpParam);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,116 +11,120 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.network.packet.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.network.packet.h"
|
||||||
#include "../../Minecraft.World/Level/LevelData.h"
|
#include "../../Minecraft.World/Level/LevelData.h"
|
||||||
|
|
||||||
|
ServerLevelListener::ServerLevelListener(MinecraftServer* server,
|
||||||
ServerLevelListener::ServerLevelListener(MinecraftServer *server, ServerLevel *level)
|
ServerLevel* level) {
|
||||||
{
|
|
||||||
this->server = server;
|
this->server = server;
|
||||||
this->level = level;
|
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::allChanged() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity)
|
void ServerLevelListener::entityAdded(std::shared_ptr<Entity> entity) {
|
||||||
{
|
|
||||||
MemSect(10);
|
MemSect(10);
|
||||||
level->getTracker()->addEntity(entity);
|
level->getTracker()->addEntity(entity);
|
||||||
MemSect(0);
|
MemSect(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity)
|
void ServerLevelListener::entityRemoved(std::shared_ptr<Entity> entity) {
|
||||||
{
|
|
||||||
level->getTracker()->removeEntity(entity);
|
level->getTracker()->removeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J added
|
// 4J added
|
||||||
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity)
|
void ServerLevelListener::playerRemoved(std::shared_ptr<Entity> entity) {
|
||||||
{
|
std::shared_ptr<ServerPlayer> player =
|
||||||
std::shared_ptr<ServerPlayer> player = std::dynamic_pointer_cast<ServerPlayer>(entity);
|
std::dynamic_pointer_cast<ServerPlayer>(entity);
|
||||||
player->getLevel()->getTracker()->removePlayer(entity);
|
player->getLevel()->getTracker()->removePlayer(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist)
|
void ServerLevelListener::playSound(int iSound, double x, double y, double z,
|
||||||
{
|
float volume, float pitch,
|
||||||
if(iSound < 0)
|
float fClipSoundDist) {
|
||||||
{
|
if (iSound < 0) {
|
||||||
app.DebugPrintf("ServerLevelListener received request for sound less than 0, so ignoring\n");
|
app.DebugPrintf(
|
||||||
}
|
"ServerLevelListener received request for sound less than 0, so "
|
||||||
else
|
"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.
|
// 4J-PB - I don't want to broadcast player sounds to my local machine,
|
||||||
// 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
|
// since we're already playing these in the LevelRenderer::playSound.
|
||||||
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)));
|
// 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)
|
void ServerLevelListener::playSound(std::shared_ptr<Entity> entity, int iSound,
|
||||||
{
|
double x, double y, double z, float volume,
|
||||||
if(iSound < 0)
|
float pitch, float fClipSoundDist) {
|
||||||
{
|
if (iSound < 0) {
|
||||||
app.DebugPrintf("ServerLevelListener received request for sound less than 0, so ignoring\n");
|
app.DebugPrintf(
|
||||||
}
|
"ServerLevelListener received request for sound less than 0, so "
|
||||||
else
|
"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.
|
// 4J-PB - I don't want to broadcast player sounds to my local machine,
|
||||||
// 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
|
// since we're already playing these in the LevelRenderer::playSound.
|
||||||
std::shared_ptr<Player> player= std::dynamic_pointer_cast<Player>(entity);
|
// The PC version does seem to do this and the result is I can stop
|
||||||
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)));
|
// 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::skyColorChanged() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerLevelListener::tileChanged(int x, int y, int z)
|
void ServerLevelListener::tileChanged(int x, int y, int z) {
|
||||||
{
|
|
||||||
level->getChunkMap()->tileChanged(x, y, z);
|
level->getChunkMap()->tileChanged(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerLevelListener::tileLightChanged(int x, int y, int 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::playStreamingMusic(const std::wstring& name, int x, int y, int z)
|
void ServerLevelListener::destroyTileProgress(int id, int x, int y, int z,
|
||||||
{
|
int progress) {
|
||||||
}
|
|
||||||
|
|
||||||
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 (ServerPlayer p : server->getPlayers()->players)
|
||||||
for(AUTO_VAR(it, server->getPlayers()->players.begin()); it != server->getPlayers()->players.end(); ++it)
|
for (AUTO_VAR(it, server->getPlayers()->players.begin());
|
||||||
{
|
it != server->getPlayers()->players.end(); ++it) {
|
||||||
std::shared_ptr<ServerPlayer> p = *it;
|
std::shared_ptr<ServerPlayer> p = *it;
|
||||||
if (p == NULL || p->level != level || p->entityId == id) continue;
|
if (p == NULL || p->level != level || p->entityId == id) continue;
|
||||||
double xd = (double)x - p->x;
|
double xd = (double)x - p->x;
|
||||||
double yd = (double)y - p->y;
|
double yd = (double)y - p->y;
|
||||||
double zd = (double)z - p->z;
|
double zd = (double)z - p->z;
|
||||||
|
|
||||||
if (xd * xd + yd * yd + zd * zd < 32 * 32)
|
if (xd * xd + yd * yd + zd * zd < 32 * 32) {
|
||||||
{
|
p->connection->send(std::shared_ptr<TileDestructionPacket>(
|
||||||
p->connection->send(std::shared_ptr<TileDestructionPacket>(new TileDestructionPacket(id, x, y, z, progress)));
|
new TileDestructionPacket(id, x, y, z, progress)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,27 +7,37 @@ class MinecraftServer;
|
||||||
class ServerLevel;
|
class ServerLevel;
|
||||||
|
|
||||||
// 4J - renamed class to ServerLevelListener to avoid clash with LevelListener
|
// 4J - renamed class to ServerLevelListener to avoid clash with LevelListener
|
||||||
class ServerLevelListener : public LevelListener
|
class ServerLevelListener : public LevelListener {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
MinecraftServer* server;
|
MinecraftServer* server;
|
||||||
ServerLevel* level;
|
ServerLevel* level;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerLevelListener(MinecraftServer* server, ServerLevel* level);
|
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);
|
// 4J removed - virtual void addParticle(const std::wstring& name, double x,
|
||||||
virtual void addParticle(ePARTICLE_TYPE name, double x, double y, double z, double xa, double ya, double za); // 4J added
|
// 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 allChanged();
|
||||||
virtual void entityAdded(std::shared_ptr<Entity> entity);
|
virtual void entityAdded(std::shared_ptr<Entity> entity);
|
||||||
virtual void entityRemoved(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 playerRemoved(
|
||||||
virtual void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
std::shared_ptr<Entity>
|
||||||
virtual void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fClipSoundDist);
|
entity); // 4J added - for when a player is removed from the
|
||||||
virtual void setTilesDirty(int x0, int y0, int z0, int x1, int y1, int z1, Level *level); // 4J - added level param
|
// 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 skyColorChanged();
|
||||||
virtual void tileChanged(int x, int y, int z);
|
virtual void tileChanged(int x, int y, int z);
|
||||||
virtual void tileLightChanged(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 playStreamingMusic(const std::wstring& name, int x, int y,
|
||||||
virtual void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
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 destroyTileProgress(int id, int x, int y, int z, int progress);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -46,13 +46,12 @@ class PsPlusUpsellWrapper;
|
||||||
#undef linux
|
#undef linux
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
class Minecraft {
|
||||||
|
|
||||||
class Minecraft
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const std::wstring VERSION_STRING;
|
static const std::wstring VERSION_STRING;
|
||||||
Minecraft(Component *mouseComponent, Canvas *parent, MinecraftApplet *minecraftApplet, int width, int height, bool fullscreen);
|
Minecraft(Component* mouseComponent, Canvas* parent,
|
||||||
|
MinecraftApplet* minecraftApplet, int width, int height,
|
||||||
|
bool fullscreen);
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// 4J - removed
|
// 4J - removed
|
||||||
|
|
@ -82,11 +81,13 @@ public:
|
||||||
private:
|
private:
|
||||||
Timer* timer;
|
Timer* timer;
|
||||||
bool reloadTextures;
|
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)
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
public:
|
||||||
MultiPlayerLevel* level;
|
MultiPlayerLevel* level;
|
||||||
LevelRenderer* levelRenderer;
|
LevelRenderer* levelRenderer;
|
||||||
std::shared_ptr<MultiplayerLocalPlayer> player;
|
std::shared_ptr<MultiplayerLocalPlayer> player;
|
||||||
|
|
@ -102,14 +103,23 @@ public:
|
||||||
|
|
||||||
// 4J Stu - Added these so that we can show a Xui scene while connecting
|
// 4J Stu - Added these so that we can show a Xui scene while connecting
|
||||||
bool m_connectionFailed[XUSER_MAX_COUNT];
|
bool m_connectionFailed[XUSER_MAX_COUNT];
|
||||||
DisconnectPacket::eDisconnectReason m_connectionFailedReason[XUSER_MAX_COUNT];
|
DisconnectPacket::eDisconnectReason
|
||||||
|
m_connectionFailedReason[XUSER_MAX_COUNT];
|
||||||
ClientConnection* m_pendingLocalConnections[XUSER_MAX_COUNT];
|
ClientConnection* m_pendingLocalConnections[XUSER_MAX_COUNT];
|
||||||
|
|
||||||
bool addLocalPlayer(int idx); // Re-arrange the screen and start the connection
|
bool addLocalPlayer(
|
||||||
|
int idx); // Re-arrange the screen and start the connection
|
||||||
void addPendingLocalConnection(int idx, ClientConnection* connection);
|
void addPendingLocalConnection(int idx, ClientConnection* connection);
|
||||||
void connectionDisconnected(int idx, DisconnectPacket::eDisconnectReason reason) { m_connectionFailed[idx] = true; m_connectionFailedReason[idx] = reason; }
|
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);
|
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);
|
void createPrimaryLocalPlayer(int iPad);
|
||||||
bool setLocalPlayerIdx(int idx);
|
bool setLocalPlayerIdx(int idx);
|
||||||
int getLocalPlayerIdx();
|
int getLocalPlayerIdx();
|
||||||
|
|
@ -133,6 +143,7 @@ public:
|
||||||
Screen* screen;
|
Screen* screen;
|
||||||
ProgressRenderer* progressRenderer;
|
ProgressRenderer* progressRenderer;
|
||||||
GameRenderer* gameRenderer;
|
GameRenderer* gameRenderer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BackgroundDownloader* bgLoader;
|
BackgroundDownloader* bgLoader;
|
||||||
|
|
||||||
|
|
@ -142,8 +153,10 @@ private:
|
||||||
// int missTime;
|
// int missTime;
|
||||||
|
|
||||||
int orgWidth, orgHeight;
|
int orgWidth, orgHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AchievementPopup* achievementPopup;
|
AchievementPopup* achievementPopup;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Gui* gui;
|
Gui* gui;
|
||||||
// 4J - move to the per player structure?
|
// 4J - move to the per player structure?
|
||||||
|
|
@ -152,16 +165,21 @@ public:
|
||||||
HumanoidModel* humanoidModel;
|
HumanoidModel* humanoidModel;
|
||||||
HitResult* hitResult;
|
HitResult* hitResult;
|
||||||
Options* options;
|
Options* options;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MinecraftApplet* minecraftApplet;
|
MinecraftApplet* minecraftApplet;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundEngine* soundEngine;
|
SoundEngine* soundEngine;
|
||||||
MouseHandler* mouseHandler;
|
MouseHandler* mouseHandler;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TexturePackRepository* skins;
|
TexturePackRepository* skins;
|
||||||
File workingDirectory;
|
File workingDirectory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LevelStorageSource* levelSource;
|
LevelStorageSource* levelSource;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int frameTimes_length = 512;
|
static const int frameTimes_length = 512;
|
||||||
static __int64 frameTimes[frameTimes_length];
|
static __int64 frameTimes[frameTimes_length];
|
||||||
|
|
@ -169,8 +187,10 @@ public:
|
||||||
static __int64 tickTimes[tickTimes_length];
|
static __int64 tickTimes[tickTimes_length];
|
||||||
static int frameTimePos;
|
static int frameTimePos;
|
||||||
static __int64 warezTime;
|
static __int64 warezTime;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int rightClickDelay;
|
int rightClickDelay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 4J- this should really be in localplayer
|
// 4J- this should really be in localplayer
|
||||||
StatsCounter* stats[4];
|
StatsCounter* stats[4];
|
||||||
|
|
@ -195,9 +215,11 @@ private:
|
||||||
public:
|
public:
|
||||||
static File getWorkingDirectory();
|
static File getWorkingDirectory();
|
||||||
static File getWorkingDirectory(const std::wstring& applicationName);
|
static File getWorkingDirectory(const std::wstring& applicationName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LevelStorageSource* getLevelSource();
|
LevelStorageSource* getLevelSource();
|
||||||
void setScreen(Screen* screen);
|
void setScreen(Screen* screen);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkGlError(const std::wstring& string);
|
void checkGlError(const std::wstring& string);
|
||||||
|
|
||||||
|
|
@ -210,7 +232,8 @@ public:
|
||||||
volatile bool running;
|
volatile bool running;
|
||||||
std::wstring fpsString;
|
std::wstring fpsString;
|
||||||
void run();
|
void run();
|
||||||
// 4J-PB - split the run into 3 parts so we can run it from our xbox game loop
|
// 4J-PB - split the run into 3 parts so we can run it from our xbox game
|
||||||
|
// loop
|
||||||
static Minecraft* GetInstance();
|
static Minecraft* GetInstance();
|
||||||
void run_middle();
|
void run_middle();
|
||||||
void run_end();
|
void run_end();
|
||||||
|
|
@ -221,12 +244,14 @@ public:
|
||||||
// bool wasDown ;
|
// bool wasDown ;
|
||||||
private:
|
private:
|
||||||
// void checkScreenshot(); // 4J - removed
|
// void checkScreenshot(); // 4J - removed
|
||||||
// String grabHugeScreenshot(File workDir2, int width, int height, int ssWidth, int ssHeight); // 4J - removed
|
// String grabHugeScreenshot(File workDir2, int width, int height, int
|
||||||
|
// ssWidth, int ssHeight); // 4J - removed
|
||||||
|
|
||||||
// 4J - per player thing?
|
// 4J - per player thing?
|
||||||
__int64 lastTimer;
|
__int64 lastTimer;
|
||||||
|
|
||||||
void renderFpsMeter(__int64 tickTime);
|
void renderFpsMeter(__int64 tickTime);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void stop();
|
void stop();
|
||||||
// 4J removed
|
// 4J removed
|
||||||
|
|
@ -255,23 +280,34 @@ private:
|
||||||
void verify();
|
void verify();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 4J - added bFirst parameter, which is true for the first active viewport in splitscreen
|
// 4J - added bFirst parameter, which is true for the first active viewport
|
||||||
// 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
|
// 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);
|
void tick(bool bFirst, bool bUpdateTextures);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reloadSound();
|
void reloadSound();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isClientSide();
|
bool isClientSide();
|
||||||
void selectLevel(ConsoleSaveFile *saveFile, const std::wstring& levelId, const std::wstring& levelName, LevelSettings *levelSettings);
|
void selectLevel(ConsoleSaveFile* saveFile, const std::wstring& levelId,
|
||||||
|
const std::wstring& levelName,
|
||||||
|
LevelSettings* levelSettings);
|
||||||
// void toggleDimension(int targetDimension);
|
// void toggleDimension(int targetDimension);
|
||||||
bool saveSlot(int slot, const std::wstring& name);
|
bool saveSlot(int slot, const std::wstring& name);
|
||||||
bool loadSlot(const std::wstring& userName, int slot);
|
bool loadSlot(const std::wstring& userName, int slot);
|
||||||
void releaseLevel(int message);
|
void releaseLevel(int message);
|
||||||
// 4J Stu - Added the doForceStatsSave param
|
// 4J Stu - Added the doForceStatsSave param
|
||||||
// void setLevel(Level *level, bool doForceStatsSave = true);
|
// void setLevel(Level *level, bool doForceStatsSave = true);
|
||||||
//void setLevel(Level *level, const std::wstring& message, bool doForceStatsSave = true);
|
// void setLevel(Level *level, const std::wstring& message, bool
|
||||||
void setLevel(MultiPlayerLevel *level, int message = -1, std::shared_ptr<Player> forceInsertPlayer = nullptr, bool doForceStatsSave = true,bool bPrimaryPlayerSignedOut=false);
|
// doForceStatsSave = true);
|
||||||
// 4J-PB - added to force in the 'other' level when the main player creates the level at game load time
|
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 forceaddLevel(MultiPlayerLevel* level);
|
||||||
void prepareLevel(int title); // 4J - changed to public
|
void prepareLevel(int title); // 4J - changed to public
|
||||||
void fileDownloaded(const std::wstring& name, File* file);
|
void fileDownloaded(const std::wstring& name, File* file);
|
||||||
|
|
@ -284,7 +320,9 @@ public:
|
||||||
|
|
||||||
void respawnPlayer(int iPad, int dimension, int newEntityId);
|
void respawnPlayer(int iPad, int dimension, int newEntityId);
|
||||||
static void start(const std::wstring& name, const std::wstring& sid);
|
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);
|
static void startAndConnectTo(const std::wstring& name,
|
||||||
|
const std::wstring& sid,
|
||||||
|
const std::wstring& url);
|
||||||
ClientConnection* getConnection(int iPad); // 4J Stu added iPad param
|
ClientConnection* getConnection(int iPad); // 4J Stu added iPad param
|
||||||
static void main();
|
static void main();
|
||||||
static bool renderNames();
|
static bool renderNames();
|
||||||
|
|
@ -298,7 +336,9 @@ public:
|
||||||
static __int64 currentTimeMillis();
|
static __int64 currentTimeMillis();
|
||||||
|
|
||||||
#ifdef _DURANGO
|
#ifdef _DURANGO
|
||||||
static void inGameSignInCheckAllPrivilegesCallback(void *lpParam, bool hasPrivileges, int iPad);
|
static void inGameSignInCheckAllPrivilegesCallback(void* lpParam,
|
||||||
|
bool hasPrivileges,
|
||||||
|
int iPad);
|
||||||
#endif
|
#endif
|
||||||
static int InGame_SignInReturned(void* pParam, bool bContinue, int iPad);
|
static int InGame_SignInReturned(void* pParam, bool bContinue, int iPad);
|
||||||
// 4J-PB
|
// 4J-PB
|
||||||
|
|
@ -308,9 +348,12 @@ public:
|
||||||
void forceStatsSave(int idx);
|
void forceStatsSave(int idx);
|
||||||
|
|
||||||
CRITICAL_SECTION m_setLevelCS;
|
CRITICAL_SECTION m_setLevelCS;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// A bit field that store whether a particular quadrant is in the full tutorial or not
|
// A bit field that store whether a particular quadrant is in the full
|
||||||
|
// tutorial or not
|
||||||
std::uint8_t m_inFullTutorialBits;
|
std::uint8_t m_inFullTutorialBits;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isTutorial();
|
bool isTutorial();
|
||||||
void playerStartedTutorial(int iPad);
|
void playerStartedTutorial(int iPad);
|
||||||
|
|
@ -323,22 +366,29 @@ public:
|
||||||
|
|
||||||
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
|
// 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_pendingTextureRequests;
|
||||||
std::vector<std::wstring> m_pendingGeometryRequests; // additional skin box geometry
|
std::vector<std::wstring>
|
||||||
|
m_pendingGeometryRequests; // additional skin box geometry
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
bool addPendingClientTextureRequest(const std::wstring& textureName);
|
bool addPendingClientTextureRequest(const std::wstring& textureName);
|
||||||
void handleClientTextureReceived(const std::wstring& textureName);
|
void handleClientTextureReceived(const std::wstring& textureName);
|
||||||
void clearPendingClientTextureRequests() { m_pendingTextureRequests.clear(); }
|
void clearPendingClientTextureRequests() {
|
||||||
|
m_pendingTextureRequests.clear();
|
||||||
|
}
|
||||||
bool addPendingClientGeometryRequest(const std::wstring& textureName);
|
bool addPendingClientGeometryRequest(const std::wstring& textureName);
|
||||||
void handleClientGeometryReceived(const std::wstring& textureName);
|
void handleClientGeometryReceived(const std::wstring& textureName);
|
||||||
void clearPendingClientGeometryRequests() { m_pendingGeometryRequests.clear(); }
|
void clearPendingClientGeometryRequests() {
|
||||||
|
m_pendingGeometryRequests.clear();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int getCurrentTexturePackId();
|
unsigned int getCurrentTexturePackId();
|
||||||
ColourTable* getColourTable();
|
ColourTable* getColourTable();
|
||||||
|
|
||||||
#if defined __ORBIS__
|
#if defined __ORBIS__
|
||||||
static int MustSignInReturnedPSN(void *pParam, int iPad, C4JStorage::EMessageResult result);
|
static int MustSignInReturnedPSN(void* pParam, int iPad,
|
||||||
|
C4JStorage::EMessageResult result);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -22,16 +22,16 @@ class CommandDispatcher;
|
||||||
|
|
||||||
#define MINECRAFT_SERVER_SLOW_QUEUE_DELAY 250
|
#define MINECRAFT_SERVER_SLOW_QUEUE_DELAY 250
|
||||||
|
|
||||||
typedef struct _LoadSaveDataThreadParam
|
typedef struct _LoadSaveDataThreadParam {
|
||||||
{
|
|
||||||
void* data;
|
void* data;
|
||||||
__int64 fileSize;
|
__int64 fileSize;
|
||||||
const std::wstring saveName;
|
const std::wstring saveName;
|
||||||
_LoadSaveDataThreadParam(void *data, __int64 filesize, const std::wstring &saveName) : data( data ), fileSize( filesize ), saveName( saveName ) {}
|
_LoadSaveDataThreadParam(void* data, __int64 filesize,
|
||||||
|
const std::wstring& saveName)
|
||||||
|
: data(data), fileSize(filesize), saveName(saveName) {}
|
||||||
} LoadSaveDataThreadParam;
|
} LoadSaveDataThreadParam;
|
||||||
|
|
||||||
typedef struct _NetworkGameInitData
|
typedef struct _NetworkGameInitData {
|
||||||
{
|
|
||||||
__int64 seed;
|
__int64 seed;
|
||||||
LoadSaveDataThreadParam* saveData;
|
LoadSaveDataThreadParam* saveData;
|
||||||
std::uint32_t settings;
|
std::uint32_t settings;
|
||||||
|
|
@ -42,8 +42,7 @@ typedef struct _NetworkGameInitData
|
||||||
unsigned char hellScale;
|
unsigned char hellScale;
|
||||||
ESavePlatform savePlatform;
|
ESavePlatform savePlatform;
|
||||||
|
|
||||||
_NetworkGameInitData()
|
_NetworkGameInitData() {
|
||||||
{
|
|
||||||
seed = 0;
|
seed = 0;
|
||||||
saveData = NULL;
|
saveData = NULL;
|
||||||
settings = 0;
|
settings = 0;
|
||||||
|
|
@ -56,11 +55,10 @@ typedef struct _NetworkGameInitData
|
||||||
}
|
}
|
||||||
} NetworkGameInitData;
|
} 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
|
||||||
// 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
|
// implementing here
|
||||||
class MinecraftServer : public ConsoleInputSource
|
class MinecraftServer : public ConsoleInputSource {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const std::wstring VERSION;
|
static const std::wstring VERSION;
|
||||||
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
|
static const int TICK_STATS_SPAN = SharedConstants::TICKS_PER_SECOND * 5;
|
||||||
|
|
@ -90,6 +88,7 @@ private:
|
||||||
ConsoleCommands* commands;
|
ConsoleCommands* commands;
|
||||||
bool running;
|
bool running;
|
||||||
bool m_bLoaded;
|
bool m_bLoaded;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool stopped;
|
bool stopped;
|
||||||
int tickCount;
|
int tickCount;
|
||||||
|
|
@ -97,10 +96,13 @@ public:
|
||||||
public:
|
public:
|
||||||
std::wstring progressStatus;
|
std::wstring progressStatus;
|
||||||
int progress;
|
int progress;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J - removed
|
// std::vector<Tickable *> tickables = new ArrayList<Tickable>(); // 4J -
|
||||||
|
//removed
|
||||||
CommandDispatcher* commandDispatcher;
|
CommandDispatcher* commandDispatcher;
|
||||||
std::vector<ConsoleInput *> consoleInput; // 4J - was synchronizedList - TODO - investigate
|
std::vector<ConsoleInput*>
|
||||||
|
consoleInput; // 4J - was synchronizedList - TODO - investigate
|
||||||
public:
|
public:
|
||||||
bool onlineMode;
|
bool onlineMode;
|
||||||
bool animals;
|
bool animals;
|
||||||
|
|
@ -115,21 +117,27 @@ private:
|
||||||
// int m_lastSentDifficulty;
|
// int m_lastSentDifficulty;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 4J Stu - This value should be incremented every time the list of players with friends-only UGC settings changes
|
// 4J Stu - This value should be incremented every time the list of players
|
||||||
// It is sent with PreLoginPacket and compared when it comes back in the LoginPacket
|
// 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;
|
std::uint32_t m_ugcPlayersVersion;
|
||||||
|
|
||||||
// This value is used to store the texture pack id for the currently loaded world
|
// This value is used to store the texture pack id for the currently loaded
|
||||||
|
// world
|
||||||
std::uint32_t m_texturePackId;
|
std::uint32_t m_texturePackId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MinecraftServer();
|
MinecraftServer();
|
||||||
~MinecraftServer();
|
~MinecraftServer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 4J Added - LoadSaveDataThreadParam
|
// 4J Added - LoadSaveDataThreadParam
|
||||||
bool initServer(__int64 seed, NetworkGameInitData *initData, std::uint32_t initSettings, bool findSeed);
|
bool initServer(__int64 seed, NetworkGameInitData* initData,
|
||||||
|
std::uint32_t initSettings, bool findSeed);
|
||||||
void postProcessTerminate(ProgressRenderer* mcprogress);
|
void postProcessTerminate(ProgressRenderer* mcprogress);
|
||||||
bool loadLevel(LevelStorageSource *storageSource, const std::wstring& name, __int64 levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
|
bool loadLevel(LevelStorageSource* storageSource, const std::wstring& name,
|
||||||
|
__int64 levelSeed, LevelType* pLevelType,
|
||||||
|
NetworkGameInitData* initData);
|
||||||
void setProgress(const std::wstring& status, int progress);
|
void setProgress(const std::wstring& status, int progress);
|
||||||
void endProgress();
|
void endProgress();
|
||||||
void saveAllChunks();
|
void saveAllChunks();
|
||||||
|
|
@ -163,8 +171,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void handleConsoleInput(const std::wstring& msg, ConsoleInputSource *source);
|
void handleConsoleInput(const std::wstring& msg,
|
||||||
|
ConsoleInputSource* source);
|
||||||
void handleConsoleInputs();
|
void handleConsoleInputs();
|
||||||
// void addTickable(Tickable tickable); // 4J removed
|
// void addTickable(Tickable tickable); // 4J removed
|
||||||
static void main(__int64 seed, void* lpParameter);
|
static void main(__int64 seed, void* lpParameter);
|
||||||
|
|
@ -179,7 +189,10 @@ public:
|
||||||
static MinecraftServer* getInstance() { return server; } // 4J added
|
static MinecraftServer* getInstance() { return server; } // 4J added
|
||||||
static bool serverHalted() { return s_bServerHalted; }
|
static bool serverHalted() { return s_bServerHalted; }
|
||||||
static bool saveOnExitAnswered() { return s_bSaveOnExitAnswered; }
|
static bool saveOnExitAnswered() { return s_bSaveOnExitAnswered; }
|
||||||
static void resetFlags() { s_bServerHalted = false; s_bSaveOnExitAnswered = false; }
|
static void resetFlags() {
|
||||||
|
s_bServerHalted = false;
|
||||||
|
s_bSaveOnExitAnswered = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool flagEntitiesToBeRemoved(unsigned int* flags); // 4J added
|
bool flagEntitiesToBeRemoved(unsigned int* flags); // 4J added
|
||||||
private:
|
private:
|
||||||
|
|
@ -191,39 +204,61 @@ private:
|
||||||
static bool setTimeAtEndOfTick;
|
static bool setTimeAtEndOfTick;
|
||||||
static __int64 setTime;
|
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
|
||||||
static bool s_bServerHalted; // 4J Stu Added so that we can halt the server even before it's been created properly
|
m_bPrimaryPlayerSignedOut; // 4J-PB added to tell the stopserver not to
|
||||||
static bool s_bSaveOnExitAnswered; // 4J Stu Added so that we only ask this question once when we exit
|
// 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
|
// 4J - added so that we can have a separate thread for post processing
|
||||||
|
// chunks on level creation
|
||||||
static int runPostUpdate(void* lpParam);
|
static int runPostUpdate(void* lpParam);
|
||||||
C4JThread* m_postUpdateThread;
|
C4JThread* m_postUpdateThread;
|
||||||
bool m_postUpdateTerminate;
|
bool m_postUpdateTerminate;
|
||||||
class postProcessRequest
|
class postProcessRequest {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
int x, z;
|
int x, z;
|
||||||
ChunkSource* chunkSource;
|
ChunkSource* chunkSource;
|
||||||
postProcessRequest(int x, int z, ChunkSource *chunkSource) : x(x), z(z), chunkSource(chunkSource) {}
|
postProcessRequest(int x, int z, ChunkSource* chunkSource)
|
||||||
|
: x(x), z(z), chunkSource(chunkSource) {}
|
||||||
};
|
};
|
||||||
std::vector<postProcessRequest> m_postProcessRequests;
|
std::vector<postProcessRequest> m_postProcessRequests;
|
||||||
CRITICAL_SECTION m_postProcessCS;
|
CRITICAL_SECTION m_postProcessCS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addPostProcessRequest(ChunkSource* chunkSource, int x, int z);
|
void addPostProcessRequest(ChunkSource* chunkSource, int x, int z);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static PlayerList *getPlayerList() { if( server != NULL ) return server->players; else return NULL; }
|
static PlayerList* getPlayerList() {
|
||||||
static void SetTimeOfDay(__int64 time) { setTimeOfDayAtEndOfTick = true; setTimeOfDay = time; }
|
if (server != NULL)
|
||||||
static void SetTime(__int64 time) { setTimeAtEndOfTick = true; setTime = time; }
|
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;
|
C4JThread::Event* m_serverPausedEvent;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 4J Added
|
// 4J Added
|
||||||
bool m_isServerPaused;
|
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
|
// 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_slowQueuePlayerIndex;
|
||||||
static int s_slowQueueLastTime;
|
static int s_slowQueueLastTime;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool s_slowQueuePacketSent;
|
static bool s_slowQueuePacketSent;
|
||||||
|
|
||||||
|
|
@ -239,9 +274,13 @@ public:
|
||||||
static bool canSendOnSlowQueue(INetworkPlayer* player);
|
static bool canSendOnSlowQueue(INetworkPlayer* player);
|
||||||
static void cycleSlowQueueIndex();
|
static void cycleSlowQueueIndex();
|
||||||
|
|
||||||
void setSaveOnExit(bool save) { m_saveOnExit = save; s_bSaveOnExitAnswered = true; }
|
void setSaveOnExit(bool save) {
|
||||||
|
m_saveOnExit = save;
|
||||||
|
s_bSaveOnExitAnswered = true;
|
||||||
|
}
|
||||||
void Suspend();
|
void Suspend();
|
||||||
bool IsSuspending();
|
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
|
// 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
|
|
@ -6,20 +6,20 @@ class SavedDataStorage;
|
||||||
class Socket;
|
class Socket;
|
||||||
class MultiplayerLocalPlayer;
|
class MultiplayerLocalPlayer;
|
||||||
|
|
||||||
class ClientConnection : public PacketListener
|
class ClientConnection : public PacketListener {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
enum eClientConnectionConnectingState
|
enum eClientConnectionConnectingState {
|
||||||
{
|
|
||||||
eCCPreLoginSent = 0,
|
eCCPreLoginSent = 0,
|
||||||
eCCPreLoginReceived,
|
eCCPreLoginReceived,
|
||||||
eCCLoginSent,
|
eCCLoginSent,
|
||||||
eCCLoginReceived,
|
eCCLoginReceived,
|
||||||
eCCConnected
|
eCCConnected
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool done;
|
bool done;
|
||||||
Connection* connection;
|
Connection* connection;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::wstring message;
|
std::wstring message;
|
||||||
bool createdOk; // 4J added
|
bool createdOk; // 4J added
|
||||||
|
|
@ -28,8 +28,10 @@ private:
|
||||||
MultiPlayerLevel* level;
|
MultiPlayerLevel* level;
|
||||||
bool started;
|
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
|
// 4J Stu - I don't think we are interested in the PlayerInfo data, so I'm
|
||||||
//Map<String, PlayerInfo> playerInfoMap = new HashMap<String, PlayerInfo>();
|
// not going to use it at the moment
|
||||||
|
// Map<String, PlayerInfo> playerInfoMap = new HashMap<String,
|
||||||
|
// PlayerInfo>();
|
||||||
public:
|
public:
|
||||||
// List<PlayerInfo> playerInfos = new ArrayList<PlayerInfo>();
|
// List<PlayerInfo> playerInfos = new ArrayList<PlayerInfo>();
|
||||||
|
|
||||||
|
|
@ -51,36 +53,50 @@ public:
|
||||||
INetworkPlayer* getNetworkPlayer();
|
INetworkPlayer* getNetworkPlayer();
|
||||||
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
||||||
virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
|
virtual void handleAddEntity(std::shared_ptr<AddEntityPacket> packet);
|
||||||
virtual void handleAddExperienceOrb(std::shared_ptr<AddExperienceOrbPacket> packet);
|
virtual void handleAddExperienceOrb(
|
||||||
virtual void handleAddGlobalEntity(std::shared_ptr<AddGlobalEntityPacket> packet);
|
std::shared_ptr<AddExperienceOrbPacket> packet);
|
||||||
|
virtual void handleAddGlobalEntity(
|
||||||
|
std::shared_ptr<AddGlobalEntityPacket> packet);
|
||||||
virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
|
virtual void handleAddPainting(std::shared_ptr<AddPaintingPacket> packet);
|
||||||
virtual void handleSetEntityMotion(std::shared_ptr<SetEntityMotionPacket> packet);
|
virtual void handleSetEntityMotion(
|
||||||
virtual void handleSetEntityData(std::shared_ptr<SetEntityDataPacket> packet);
|
std::shared_ptr<SetEntityMotionPacket> packet);
|
||||||
|
virtual void handleSetEntityData(
|
||||||
|
std::shared_ptr<SetEntityDataPacket> packet);
|
||||||
virtual void handleAddPlayer(std::shared_ptr<AddPlayerPacket> 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 handleMoveEntity(std::shared_ptr<MoveEntityPacket> packet);
|
||||||
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
|
virtual void handleRotateMob(std::shared_ptr<RotateHeadPacket> packet);
|
||||||
virtual void handleMoveEntitySmall(std::shared_ptr<MoveEntityPacketSmall> packet);
|
virtual void handleMoveEntitySmall(
|
||||||
virtual void handleRemoveEntity(std::shared_ptr<RemoveEntitiesPacket> packet);
|
std::shared_ptr<MoveEntityPacketSmall> packet);
|
||||||
|
virtual void handleRemoveEntity(
|
||||||
|
std::shared_ptr<RemoveEntitiesPacket> packet);
|
||||||
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
virtual void handleMovePlayer(std::shared_ptr<MovePlayerPacket> packet);
|
||||||
|
|
||||||
Random* random;
|
Random* random;
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void handleChunkVisibilityArea(std::shared_ptr<ChunkVisibilityAreaPacket> packet);
|
virtual void handleChunkVisibilityArea(
|
||||||
|
std::shared_ptr<ChunkVisibilityAreaPacket> packet);
|
||||||
|
|
||||||
virtual void handleChunkVisibility(std::shared_ptr<ChunkVisibilityPacket> packet);
|
virtual void handleChunkVisibility(
|
||||||
virtual void handleChunkTilesUpdate(std::shared_ptr<ChunkTilesUpdatePacket> packet);
|
std::shared_ptr<ChunkVisibilityPacket> packet);
|
||||||
virtual void handleBlockRegionUpdate(std::shared_ptr<BlockRegionUpdatePacket> 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 handleTileUpdate(std::shared_ptr<TileUpdatePacket> packet);
|
||||||
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> 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 sendAndDisconnect(std::shared_ptr<Packet> packet);
|
||||||
void send(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 handleChat(std::shared_ptr<ChatPacket> packet);
|
||||||
virtual void handleAnimate(std::shared_ptr<AnimatePacket> 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);
|
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
||||||
void close();
|
void close();
|
||||||
virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
|
virtual void handleAddMob(std::shared_ptr<AddMobPacket> packet);
|
||||||
|
|
@ -88,53 +104,79 @@ public:
|
||||||
virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
|
virtual void handleSetSpawn(std::shared_ptr<SetSpawnPositionPacket> packet);
|
||||||
virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
|
virtual void handleRidePacket(std::shared_ptr<SetRidingPacket> packet);
|
||||||
virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
|
virtual void handleEntityEvent(std::shared_ptr<EntityEventPacket> packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Entity> getEntity(int entityId);
|
std::shared_ptr<Entity> getEntity(int entityId);
|
||||||
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
std::wstring GetDisplayNameByGamertag(std::wstring gamertag);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void handleSetHealth(std::shared_ptr<SetHealthPacket> packet);
|
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 handleRespawn(std::shared_ptr<RespawnPacket> packet);
|
||||||
virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
|
virtual void handleExplosion(std::shared_ptr<ExplodePacket> packet);
|
||||||
virtual void handleContainerOpen(std::shared_ptr<ContainerOpenPacket> packet);
|
virtual void handleContainerOpen(
|
||||||
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
|
std::shared_ptr<ContainerOpenPacket> packet);
|
||||||
|
virtual void handleContainerSetSlot(
|
||||||
|
std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||||
virtual void handleContainerAck(std::shared_ptr<ContainerAckPacket> 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 handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
||||||
virtual void handleTileEntityData(std::shared_ptr<TileEntityDataPacket> packet);
|
virtual void handleTileEntityData(
|
||||||
virtual void handleContainerSetData(std::shared_ptr<ContainerSetDataPacket> packet);
|
std::shared_ptr<TileEntityDataPacket> packet);
|
||||||
virtual void handleSetEquippedItem(std::shared_ptr<SetEquippedItemPacket> packet);
|
virtual void handleContainerSetData(
|
||||||
virtual void handleContainerClose(std::shared_ptr<ContainerClosePacket> packet);
|
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 handleTileEvent(std::shared_ptr<TileEventPacket> packet);
|
||||||
virtual void handleTileDestruction(std::shared_ptr<TileDestructionPacket> packet);
|
virtual void handleTileDestruction(
|
||||||
|
std::shared_ptr<TileDestructionPacket> packet);
|
||||||
virtual bool canHandleAsyncPackets();
|
virtual bool canHandleAsyncPackets();
|
||||||
virtual void handleGameEvent(std::shared_ptr<GameEventPacket> gameEventPacket);
|
virtual void handleGameEvent(
|
||||||
virtual void handleComplexItemData(std::shared_ptr<ComplexItemDataPacket> packet);
|
std::shared_ptr<GameEventPacket> gameEventPacket);
|
||||||
|
virtual void handleComplexItemData(
|
||||||
|
std::shared_ptr<ComplexItemDataPacket> packet);
|
||||||
virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
|
virtual void handleLevelEvent(std::shared_ptr<LevelEventPacket> packet);
|
||||||
virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
|
virtual void handleAwardStat(std::shared_ptr<AwardStatPacket> packet);
|
||||||
virtual void handleUpdateMobEffect(std::shared_ptr<UpdateMobEffectPacket> packet);
|
virtual void handleUpdateMobEffect(
|
||||||
virtual void handleRemoveMobEffect(std::shared_ptr<RemoveMobEffectPacket> packet);
|
std::shared_ptr<UpdateMobEffectPacket> packet);
|
||||||
|
virtual void handleRemoveMobEffect(
|
||||||
|
std::shared_ptr<RemoveMobEffectPacket> packet);
|
||||||
virtual bool isServerPacketListener();
|
virtual bool isServerPacketListener();
|
||||||
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
|
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet);
|
||||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||||
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
virtual void handlePlayerAbilities(
|
||||||
|
std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||||
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
|
virtual void handleSoundEvent(std::shared_ptr<LevelSoundPacket> packet);
|
||||||
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
virtual void handleCustomPayload(
|
||||||
|
std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||||
virtual Connection* getConnection();
|
virtual Connection* getConnection();
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
virtual void handleServerSettingsChanged(
|
||||||
|
std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||||
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||||
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
|
virtual void handleTextureAndGeometry(
|
||||||
virtual void handleUpdateProgress(std::shared_ptr<UpdateProgressPacket> packet);
|
std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||||
|
virtual void handleUpdateProgress(
|
||||||
|
std::shared_ptr<UpdateProgressPacket> packet);
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
static int HostDisconnectReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
static int HostDisconnectReturned(void* pParam, int iPad,
|
||||||
static int ExitGameAndSaveReturned(void *pParam,int iPad,C4JStorage::EMessageResult result);
|
C4JStorage::EMessageResult result);
|
||||||
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
|
static int ExitGameAndSaveReturned(void* pParam, int iPad,
|
||||||
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
C4JStorage::EMessageResult result);
|
||||||
virtual void handleUpdateGameRuleProgressPacket(std::shared_ptr<UpdateGameRuleProgressPacket> packet);
|
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);
|
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);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,44 +10,43 @@
|
||||||
#include "../../Minecraft.World/Blocks/Tile.h"
|
#include "../../Minecraft.World/Blocks/Tile.h"
|
||||||
#include "../../Minecraft.World/Level/WaterLevelChunk.h"
|
#include "../../Minecraft.World/Level/WaterLevelChunk.h"
|
||||||
|
|
||||||
MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
|
MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
|
||||||
{
|
|
||||||
XZSIZE = level->dimension->getXZSize(); // 4J Added
|
XZSIZE = level->dimension->getXZSize(); // 4J Added
|
||||||
XZOFFSET = XZSIZE / 2; // 4J Added
|
XZOFFSET = XZSIZE / 2; // 4J Added
|
||||||
m_XZSize = XZSIZE;
|
m_XZSize = XZSIZE;
|
||||||
hasData = new bool[XZSIZE * XZSIZE];
|
hasData = new bool[XZSIZE * XZSIZE];
|
||||||
memset(hasData, 0, sizeof(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
|
// For normal world dimension, create a chunk that can be used to create the
|
||||||
if( level->dimension->id == 0 )
|
// illusion of infinite water at the edge of the world
|
||||||
{
|
if (level->dimension->id == 0) {
|
||||||
byteArray bytes = byteArray(16 * 16 * 128);
|
byteArray bytes = byteArray(16 * 16 * 128);
|
||||||
|
|
||||||
// Superflat.... make grass, not water...
|
// Superflat.... make grass, not water...
|
||||||
if(level->getLevelData()->getGenerator() == LevelType::lvl_flat)
|
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
|
||||||
{
|
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
for (int y = 0; y < 128; y++)
|
for (int y = 0; y < 128; y++)
|
||||||
for( int z = 0; z < 16; z++ )
|
for (int z = 0; z < 16; z++) {
|
||||||
{
|
|
||||||
unsigned char tileId = 0;
|
unsigned char tileId = 0;
|
||||||
if( y == 3 ) tileId = Tile::grass_Id;
|
if (y == 3)
|
||||||
else if( y <= 2 ) tileId = Tile::dirt_Id;
|
tileId = Tile::grass_Id;
|
||||||
|
else if (y <= 2)
|
||||||
|
tileId = Tile::dirt_Id;
|
||||||
|
|
||||||
bytes[x << 11 | z << 7 | y] = tileId;
|
bytes[x << 11 | z << 7 | y] = tileId;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
for (int y = 0; y < 128; y++)
|
for (int y = 0; y < 128; y++)
|
||||||
for( int z = 0; z < 16; z++ )
|
for (int z = 0; z < 16; z++) {
|
||||||
{
|
|
||||||
unsigned char tileId = 0;
|
unsigned char tileId = 0;
|
||||||
if( y <= ( level->getSeaLevel() - 10 ) ) tileId = Tile::rock_Id;
|
if (y <= (level->getSeaLevel() - 10))
|
||||||
else if( y < level->getSeaLevel() ) tileId = Tile::calmWater_Id;
|
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;
|
||||||
}
|
}
|
||||||
|
|
@ -57,37 +56,32 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
|
||||||
|
|
||||||
delete[] bytes.data;
|
delete[] bytes.data;
|
||||||
|
|
||||||
if(level->getLevelData()->getGenerator() == LevelType::lvl_flat)
|
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
|
||||||
{
|
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
for (int y = 0; y < 128; y++)
|
for (int y = 0; y < 128; y++)
|
||||||
for( int z = 0; z < 16; z++ )
|
for (int z = 0; z < 16; z++) {
|
||||||
{
|
if (y >= 3) {
|
||||||
if( y >= 3 )
|
((WaterLevelChunk*)waterChunk)
|
||||||
{
|
->setLevelChunkBrightness(LightLayer::Sky, x, y,
|
||||||
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15);
|
z, 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
for (int y = 0; y < 128; y++)
|
for (int y = 0; y < 128; y++)
|
||||||
for( int z = 0; z < 16; z++ )
|
for (int z = 0; z < 16; z++) {
|
||||||
{
|
if (y >= (level->getSeaLevel() - 1)) {
|
||||||
if( y >= ( level->getSeaLevel() - 1 ) )
|
((WaterLevelChunk*)waterChunk)
|
||||||
{
|
->setLevelChunkBrightness(LightLayer::Sky, x, y,
|
||||||
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,15);
|
z, 15);
|
||||||
}
|
} else {
|
||||||
else
|
((WaterLevelChunk*)waterChunk)
|
||||||
{
|
->setLevelChunkBrightness(LightLayer::Sky, x, y,
|
||||||
((WaterLevelChunk *)waterChunk)->setLevelChunkBrightness(LightLayer::Sky,x,y,z,2);
|
z, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
waterChunk = NULL;
|
waterChunk = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,103 +92,111 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level *level)
|
||||||
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate, 4000);
|
InitializeCriticalSectionAndSpinCount(&m_csLoadCreate, 4000);
|
||||||
}
|
}
|
||||||
|
|
||||||
MultiPlayerChunkCache::~MultiPlayerChunkCache()
|
MultiPlayerChunkCache::~MultiPlayerChunkCache() {
|
||||||
{
|
|
||||||
delete emptyChunk;
|
delete emptyChunk;
|
||||||
delete waterChunk;
|
delete waterChunk;
|
||||||
delete cache;
|
delete cache;
|
||||||
delete hasData;
|
delete hasData;
|
||||||
|
|
||||||
AUTO_VAR(itEnd, loadedChunkList.end());
|
AUTO_VAR(itEnd, loadedChunkList.end());
|
||||||
for (AUTO_VAR(it, loadedChunkList.begin()); it != itEnd; it++)
|
for (AUTO_VAR(it, loadedChunkList.begin()); it != itEnd; it++) delete *it;
|
||||||
delete *it;
|
|
||||||
|
|
||||||
DeleteCriticalSection(&m_csLoadCreate);
|
DeleteCriticalSection(&m_csLoadCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MultiPlayerChunkCache::hasChunk(int x, int z) {
|
||||||
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
|
||||||
// This cache always claims to have chunks, although it might actually just return empty data if it doesn't have anything
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J added - find out if we actually really do have a chunk in our cache
|
// 4J added - find out if we actually really do have a chunk in our cache
|
||||||
bool MultiPlayerChunkCache::reallyHasChunk(int x, int z)
|
bool MultiPlayerChunkCache::reallyHasChunk(int x, int z) {
|
||||||
{
|
|
||||||
int ix = x + XZOFFSET;
|
int ix = x + XZOFFSET;
|
||||||
int iz = z + 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
|
// 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 ((ix < 0) || (ix >= XZSIZE)) return true;
|
||||||
if ((iz < 0) || (iz >= XZSIZE)) return true;
|
if ((iz < 0) || (iz >= XZSIZE)) return true;
|
||||||
int idx = ix * XZSIZE + iz;
|
int idx = ix * XZSIZE + iz;
|
||||||
|
|
||||||
LevelChunk* chunk = cache[idx];
|
LevelChunk* chunk = cache[idx];
|
||||||
if( chunk == NULL )
|
if (chunk == NULL) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return hasData[idx];
|
return hasData[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerChunkCache::drop(int x, int z)
|
void MultiPlayerChunkCache::drop(int x, int z) {
|
||||||
{
|
// 4J Stu - We do want to drop any entities in the chunks, especially for
|
||||||
// 4J Stu - We do want to drop any entities in the chunks, especially for the case when a player is dead as they will
|
// the case when a player is dead as they will not get the RemoveEntity
|
||||||
// not get the RemoveEntity packet if an entity is removed.
|
// packet if an entity is removed.
|
||||||
LevelChunk* chunk = getChunk(x, z);
|
LevelChunk* chunk = getChunk(x, z);
|
||||||
if (!chunk->isEmpty())
|
if (!chunk->isEmpty()) {
|
||||||
{
|
// Added parameter here specifies that we don't want to delete tile
|
||||||
// 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
|
// entities, as they won't get recreated unless they've got update
|
||||||
// The tile entities are in general only created on the client by virtue of the chunk rebuild
|
// packets The tile entities are in general only created on the client
|
||||||
|
// by virtue of the chunk rebuild
|
||||||
chunk->unload(false);
|
chunk->unload(false);
|
||||||
|
|
||||||
// 4J - We just want to clear out the entities in the chunk, but everything else should be valid
|
// 4J - We just want to clear out the entities in the chunk, but
|
||||||
|
// everything else should be valid
|
||||||
chunk->loaded = true;
|
chunk->loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelChunk *MultiPlayerChunkCache::create(int x, int z)
|
LevelChunk* MultiPlayerChunkCache::create(int x, int z) {
|
||||||
{
|
|
||||||
int ix = x + XZOFFSET;
|
int ix = x + XZOFFSET;
|
||||||
int iz = z + XZOFFSET;
|
int iz = z + XZOFFSET;
|
||||||
// Check we're in range of the stored level
|
// Check we're in range of the stored level
|
||||||
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
if ((ix < 0) || (ix >= XZSIZE))
|
||||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
return (waterChunk ? waterChunk : emptyChunk);
|
||||||
|
if ((iz < 0) || (iz >= XZSIZE))
|
||||||
|
return (waterChunk ? waterChunk : emptyChunk);
|
||||||
int idx = ix * XZSIZE + iz;
|
int idx = ix * XZSIZE + iz;
|
||||||
LevelChunk* chunk = cache[idx];
|
LevelChunk* chunk = cache[idx];
|
||||||
LevelChunk* lastChunk = chunk;
|
LevelChunk* lastChunk = chunk;
|
||||||
|
|
||||||
if( chunk == NULL )
|
if (chunk == NULL) {
|
||||||
{
|
|
||||||
EnterCriticalSection(&m_csLoadCreate);
|
EnterCriticalSection(&m_csLoadCreate);
|
||||||
|
|
||||||
// LevelChunk *chunk;
|
// LevelChunk *chunk;
|
||||||
if (g_NetworkManager.IsHost()) // force here to disable sharing of data
|
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.
|
// 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 (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
|
#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
|
#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
|
#endif
|
||||||
chunk = new LevelChunk(level, x, z, serverChunk);
|
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
|
// Let renderer know that this chunk has been created - it might
|
||||||
level->setTilesDirty( x * 16 , 0 , z * 16 , x * 16 + 15, 127, z * 16 + 15);
|
// 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;
|
hasData[idx] = true;
|
||||||
}
|
} else {
|
||||||
else
|
// Passing an empty array into the LevelChunk ctor, which it now
|
||||||
{
|
// detects and sets up the chunk as compressed & empty
|
||||||
// Passing an empty array into the LevelChunk ctor, which it now detects and sets up the chunk as compressed & empty
|
|
||||||
byteArray bytes;
|
byteArray bytes;
|
||||||
|
|
||||||
chunk = new LevelChunk(level, bytes, x, z);
|
chunk = new LevelChunk(level, bytes, x, z);
|
||||||
|
|
||||||
// 4J - changed to use new methods for lighting
|
// 4J - changed to use new methods for lighting
|
||||||
chunk->setSkyLightDataAllBright();
|
chunk->setSkyLightDataAllBright();
|
||||||
// Arrays::fill(chunk->skyLight->data, (uint8_t) 255);
|
// Arrays::fill(chunk->skyLight->data, (uint8_t)
|
||||||
|
//255);
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk->loaded = true;
|
chunk->loaded = true;
|
||||||
|
|
@ -202,15 +204,19 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z)
|
||||||
LeaveCriticalSection(&m_csLoadCreate);
|
LeaveCriticalSection(&m_csLoadCreate);
|
||||||
|
|
||||||
#if (defined _WIN64 || defined __LP64__)
|
#if (defined _WIN64 || defined __LP64__)
|
||||||
if( InterlockedCompareExchangeRelease64((LONG64 *)&cache[idx],(LONG64)chunk,(LONG64)lastChunk) == (LONG64)lastChunk )
|
if (InterlockedCompareExchangeRelease64(
|
||||||
|
(LONG64*)&cache[idx], (LONG64)chunk, (LONG64)lastChunk) ==
|
||||||
|
(LONG64)lastChunk)
|
||||||
#else
|
#else
|
||||||
if( InterlockedCompareExchangeRelease((LONG *)&cache[idx],(LONG)chunk,(LONG)lastChunk) == (LONG)lastChunk )
|
if (InterlockedCompareExchangeRelease((LONG*)&cache[idx], (LONG)chunk,
|
||||||
|
(LONG)lastChunk) ==
|
||||||
|
(LONG)lastChunk)
|
||||||
#endif // _DURANGO
|
#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,
|
// If we're sharing with the server, we'll need to calculate our
|
||||||
// then this will be calculated when the chunk data arrives.
|
// heightmap now, which isn't shared. If we aren't sharing with the
|
||||||
if( g_NetworkManager.IsHost() )
|
// server, then this will be calculated when the chunk data arrives.
|
||||||
{
|
if (g_NetworkManager.IsHost()) {
|
||||||
chunk->recalcHeightmapOnly();
|
chunk->recalcHeightmapOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,84 +224,68 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z)
|
||||||
EnterCriticalSection(&m_csLoadCreate);
|
EnterCriticalSection(&m_csLoadCreate);
|
||||||
loadedChunkList.push_back(chunk);
|
loadedChunkList.push_back(chunk);
|
||||||
LeaveCriticalSection(&m_csLoadCreate);
|
LeaveCriticalSection(&m_csLoadCreate);
|
||||||
}
|
} else {
|
||||||
else
|
// Something else must have updated the cache. Return that chunk and
|
||||||
{
|
// discard this one. This really shouldn't be happening in
|
||||||
// Something else must have updated the cache. Return that chunk and discard this one. This really shouldn't be happening
|
// multiplayer
|
||||||
// in multiplayer
|
|
||||||
delete chunk;
|
delete chunk;
|
||||||
return cache[idx];
|
return cache[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
chunk->load();
|
chunk->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelChunk *MultiPlayerChunkCache::getChunk(int x, int z)
|
LevelChunk* MultiPlayerChunkCache::getChunk(int x, int z) {
|
||||||
{
|
|
||||||
int ix = x + XZOFFSET;
|
int ix = x + XZOFFSET;
|
||||||
int iz = z + XZOFFSET;
|
int iz = z + XZOFFSET;
|
||||||
// Check we're in range of the stored level
|
// Check we're in range of the stored level
|
||||||
if( ( ix < 0 ) || ( ix >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
if ((ix < 0) || (ix >= XZSIZE))
|
||||||
if( ( iz < 0 ) || ( iz >= XZSIZE ) ) return ( waterChunk ? waterChunk : emptyChunk );
|
return (waterChunk ? waterChunk : emptyChunk);
|
||||||
|
if ((iz < 0) || (iz >= XZSIZE))
|
||||||
|
return (waterChunk ? waterChunk : emptyChunk);
|
||||||
int idx = ix * XZSIZE + iz;
|
int idx = ix * XZSIZE + iz;
|
||||||
|
|
||||||
LevelChunk* chunk = cache[idx];
|
LevelChunk* chunk = cache[idx];
|
||||||
if( chunk == NULL )
|
if (chunk == NULL) {
|
||||||
{
|
|
||||||
return emptyChunk;
|
return emptyChunk;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerChunkCache::save(bool force, ProgressListener *progressListener)
|
bool MultiPlayerChunkCache::save(bool force,
|
||||||
{
|
ProgressListener* progressListener) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerChunkCache::tick()
|
bool MultiPlayerChunkCache::tick() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MultiPlayerChunkCache::shouldSave()
|
bool MultiPlayerChunkCache::shouldSave() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiPlayerChunkCache::postProcess(ChunkSource *parent, int x, int z)
|
void MultiPlayerChunkCache::postProcess(ChunkSource* parent, int x, int z) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Biome::MobSpawnerData *> *MultiPlayerChunkCache::getMobsAt(MobCategory *mobCategory, int x, int y, int z)
|
std::vector<Biome::MobSpawnerData*>* MultiPlayerChunkCache::getMobsAt(
|
||||||
{
|
MobCategory* mobCategory, int x, int y, int z) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TilePos *MultiPlayerChunkCache::findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z)
|
TilePos* MultiPlayerChunkCache::findNearestMapFeature(
|
||||||
{
|
Level* level, const std::wstring& featureName, int x, int y, int z) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring MultiPlayerChunkCache::gatherStats()
|
std::wstring MultiPlayerChunkCache::gatherStats() {
|
||||||
{
|
|
||||||
EnterCriticalSection(&m_csLoadCreate);
|
EnterCriticalSection(&m_csLoadCreate);
|
||||||
int size = (int)loadedChunkList.size();
|
int size = (int)loadedChunkList.size();
|
||||||
LeaveCriticalSection(&m_csLoadCreate);
|
LeaveCriticalSection(&m_csLoadCreate);
|
||||||
return L"MultiplayerChunkCache: " + _toString<int>(size);
|
return L"MultiplayerChunkCache: " + _toString<int>(size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerChunkCache::dataReceived(int x, int z)
|
void MultiPlayerChunkCache::dataReceived(int x, int z) {
|
||||||
{
|
|
||||||
int ix = x + XZOFFSET;
|
int ix = x + XZOFFSET;
|
||||||
int iz = z + XZOFFSET;
|
int iz = z + XZOFFSET;
|
||||||
// Check we're in range of the stored level
|
// Check we're in range of the stored level
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
|
||||||
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
#include "../../Minecraft.World/Level/RandomLevelSource.h"
|
||||||
|
|
||||||
|
|
||||||
class ServerChunkCache;
|
class ServerChunkCache;
|
||||||
|
|
||||||
// 4J - various alterations here to make this thread safe, and operate as a fixed sized cache
|
// 4J - various alterations here to make this thread safe, and operate as a
|
||||||
class MultiPlayerChunkCache : public ChunkSource
|
// fixed sized cache
|
||||||
{
|
class MultiPlayerChunkCache : public ChunkSource {
|
||||||
friend class LevelRenderer;
|
friend class LevelRenderer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LevelChunk* emptyChunk;
|
LevelChunk* emptyChunk;
|
||||||
LevelChunk* waterChunk;
|
LevelChunk* waterChunk;
|
||||||
|
|
@ -39,8 +39,11 @@ public:
|
||||||
virtual bool shouldSave();
|
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::wstring gatherStats();
|
||||||
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
virtual std::vector<Biome::MobSpawnerData*>* getMobsAt(
|
||||||
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
|
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 void dataReceived(int x, int z); // 4J added
|
||||||
|
|
||||||
virtual LevelChunk** getCache() { return cache; } // 4J added
|
virtual LevelChunk** getCache() { return cache; } // 4J added
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@
|
||||||
|
|
||||||
Random* PendingConnection::random = new Random();
|
Random* PendingConnection::random = new Random();
|
||||||
|
|
||||||
PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id)
|
PendingConnection::PendingConnection(MinecraftServer* server, Socket* socket,
|
||||||
{
|
const std::wstring& id) {
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
done = false;
|
done = false;
|
||||||
_tick = 0;
|
_tick = 0;
|
||||||
|
|
@ -35,35 +35,28 @@ PendingConnection::PendingConnection(MinecraftServer *server, Socket *socket, co
|
||||||
connection->fakeLag = FAKE_LAG;
|
connection->fakeLag = FAKE_LAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingConnection::~PendingConnection()
|
PendingConnection::~PendingConnection() { delete connection; }
|
||||||
{
|
|
||||||
delete connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PendingConnection::tick()
|
void PendingConnection::tick() {
|
||||||
{
|
if (acceptedLogin != NULL) {
|
||||||
if (acceptedLogin != NULL)
|
|
||||||
{
|
|
||||||
this->handleAcceptedLogin(acceptedLogin);
|
this->handleAcceptedLogin(acceptedLogin);
|
||||||
acceptedLogin = nullptr;
|
acceptedLogin = nullptr;
|
||||||
}
|
}
|
||||||
if (_tick++ == MAX_TICKS_BEFORE_LOGIN)
|
if (_tick++ == MAX_TICKS_BEFORE_LOGIN) {
|
||||||
{
|
|
||||||
disconnect(DisconnectPacket::eDisconnect_LoginTooLong);
|
disconnect(DisconnectPacket::eDisconnect_LoginTooLong);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
connection->tick();
|
connection->tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) {
|
||||||
{
|
|
||||||
// try { // 4J - removed try/catch
|
// try { // 4J - removed try/catch
|
||||||
// logger.info("Disconnecting " + getName() + ": " + reason);
|
// logger.info("Disconnecting " + getName() + ": " + reason);
|
||||||
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
|
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n",
|
||||||
|
reason, _tick);
|
||||||
app.DebugPrintf("Pending connection disconnect: %d\n", reason);
|
app.DebugPrintf("Pending connection disconnect: %d\n", reason);
|
||||||
connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
|
connection->send(
|
||||||
|
std::shared_ptr<DisconnectPacket>(new DisconnectPacket(reason)));
|
||||||
connection->sendAndQuit();
|
connection->sendAndQuit();
|
||||||
done = true;
|
done = true;
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
|
|
@ -71,28 +64,25 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet)
|
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
|
||||||
{
|
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION) {
|
||||||
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
|
app.DebugPrintf("Netcode version is %d not equal to %d\n",
|
||||||
{
|
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) {
|
||||||
if (packet->m_netcodeVersion > MINECRAFT_NET_VERSION)
|
|
||||||
{
|
|
||||||
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
|
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
|
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// printf("Server: handlePreLogin\n");
|
// 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
|
name =
|
||||||
|
packet->loginKey; // 4J Stu - Change from the login packet as we know
|
||||||
|
// better on client end during the pre-login packet
|
||||||
sendPreLoginResponse();
|
sendPreLoginResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::sendPreLoginResponse()
|
void PendingConnection::sendPreLoginResponse() {
|
||||||
{
|
|
||||||
// 4J Stu - Calculate the players with UGC privileges set
|
// 4J Stu - Calculate the players with UGC privileges set
|
||||||
PlayerUID* ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
|
PlayerUID* ugcXuids = new PlayerUID[MINECRAFT_NET_MAX_PLAYERS];
|
||||||
std::uint8_t ugcXuidCount = 0;
|
std::uint8_t ugcXuidCount = 0;
|
||||||
|
|
@ -103,24 +93,30 @@ void PendingConnection::sendPreLoginResponse()
|
||||||
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
|
StorageManager.GetSaveUniqueFilename(szUniqueMapName);
|
||||||
|
|
||||||
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
|
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
|
||||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
for (AUTO_VAR(it, playerList->players.begin());
|
||||||
{
|
it != playerList->players.end(); ++it) {
|
||||||
std::shared_ptr<ServerPlayer> player = *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 offline Xuid is invalid but the online one is not then that's
|
||||||
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
|
// 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
|
// PADDY - this is failing when a local player with chat restrictions
|
||||||
|
// joins an online game
|
||||||
|
|
||||||
if( player != NULL && player->connection->m_offlineXUID != INVALID_XUID && player->connection->m_onlineXUID != INVALID_XUID )
|
if (player != NULL &&
|
||||||
{
|
player->connection->m_offlineXUID != INVALID_XUID &&
|
||||||
if( player->connection->m_friendsOnlyUGC )
|
player->connection->m_onlineXUID != INVALID_XUID) {
|
||||||
{
|
if (player->connection->m_friendsOnlyUGC) {
|
||||||
ugcFriendsOnlyBits |= (1 << ugcXuidCount);
|
ugcFriendsOnlyBits |= (1 << ugcXuidCount);
|
||||||
}
|
}
|
||||||
// Need to use the online XUID otherwise friend checks will fail on the client
|
// Need to use the online XUID otherwise friend checks will fail on
|
||||||
|
// the client
|
||||||
ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID;
|
ugcXuids[ugcXuidCount] = player->connection->m_onlineXUID;
|
||||||
|
|
||||||
if( player->connection->getNetworkPlayer() != NULL && player->connection->getNetworkPlayer()->IsHost() ) hostIndex = ugcXuidCount;
|
if (player->connection->getNetworkPlayer() != NULL &&
|
||||||
|
player->connection->getNetworkPlayer()->IsHost())
|
||||||
|
hostIndex = ugcXuidCount;
|
||||||
|
|
||||||
++ugcXuidCount;
|
++ugcXuidCount;
|
||||||
}
|
}
|
||||||
|
|
@ -135,23 +131,25 @@ void PendingConnection::sendPreLoginResponse()
|
||||||
else
|
else
|
||||||
#endif
|
#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)
|
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet) {
|
||||||
{
|
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n",
|
||||||
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
|
packet->clientVersion);
|
||||||
// name = packet->userName;
|
// name = packet->userName;
|
||||||
if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION)
|
if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION) {
|
||||||
{
|
app.DebugPrintf("Client version is %d not equal to %d\n",
|
||||||
app.DebugPrintf("Client version is %d not equal to %d\n", packet->clientVersion, SharedConstants::NETWORK_PROTOCOL_VERSION);
|
packet->clientVersion,
|
||||||
if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION)
|
SharedConstants::NETWORK_PROTOCOL_VERSION);
|
||||||
{
|
if (packet->clientVersion > SharedConstants::NETWORK_PROTOCOL_VERSION) {
|
||||||
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
|
disconnect(DisconnectPacket::eDisconnect_OutdatedServer);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
|
disconnect(DisconnectPacket::eDisconnect_OutdatedClient);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -160,16 +158,11 @@ void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
|
||||||
// if (true)// 4J removed !server->onlineMode)
|
// if (true)// 4J removed !server->onlineMode)
|
||||||
bool sentDisconnect = false;
|
bool sentDisconnect = false;
|
||||||
|
|
||||||
if( sentDisconnect )
|
if (sentDisconnect) {
|
||||||
{
|
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
} else if (server->getPlayers()->isXuidBanned(packet->m_onlineXuid)) {
|
||||||
else if( server->getPlayers()->isXuidBanned( packet->m_onlineXuid ) )
|
|
||||||
{
|
|
||||||
disconnect(DisconnectPacket::eDisconnect_Banned);
|
disconnect(DisconnectPacket::eDisconnect_Banned);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
handleAcceptedLogin(packet);
|
handleAcceptedLogin(packet);
|
||||||
}
|
}
|
||||||
// else
|
// else
|
||||||
|
|
@ -197,13 +190,11 @@ void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
|
||||||
}.start();
|
}.start();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
|
void PendingConnection::handleAcceptedLogin(
|
||||||
{
|
std::shared_ptr<LoginPacket> packet) {
|
||||||
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
|
if (packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion) {
|
||||||
{
|
|
||||||
// Send the pre-login packet again with the new list of players
|
// Send the pre-login packet again with the new list of players
|
||||||
sendPreLoginResponse();
|
sendPreLoginResponse();
|
||||||
return;
|
return;
|
||||||
|
|
@ -213,28 +204,31 @@ void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
|
||||||
PlayerUID playerXuid = packet->m_offlineXuid;
|
PlayerUID playerXuid = packet->m_offlineXuid;
|
||||||
if (playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
if (playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
||||||
|
|
||||||
std::shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
std::shared_ptr<ServerPlayer> playerEntity =
|
||||||
if (playerEntity != NULL)
|
server->getPlayers()->getPlayerForLogin(this, name, playerXuid,
|
||||||
{
|
packet->m_onlineXuid);
|
||||||
|
if (playerEntity != NULL) {
|
||||||
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
|
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;
|
done = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects)
|
void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||||
{
|
void* reasonObjects) {
|
||||||
// logger.info(getName() + " lost connection");
|
// logger.info(getName() + " lost connection");
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
|
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet) {
|
||||||
{
|
|
||||||
// try {
|
// try {
|
||||||
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
|
// String message = server->motd + "§" + server->players->getPlayerCount() +
|
||||||
//connection->send(new DisconnectPacket(message));
|
// "§" + server->players->getMaxPlayers(); connection->send(new
|
||||||
connection->send(std::shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
|
// DisconnectPacket(message));
|
||||||
|
connection->send(std::shared_ptr<DisconnectPacket>(
|
||||||
|
new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull)));
|
||||||
connection->sendAndQuit();
|
connection->sendAndQuit();
|
||||||
server->connection->removeSpamProtection(connection->getSocket());
|
server->connection->removeSpamProtection(connection->getSocket());
|
||||||
done = true;
|
done = true;
|
||||||
|
|
@ -243,29 +237,24 @@ void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
|
void PendingConnection::handleKeepAlive(
|
||||||
{
|
std::shared_ptr<KeepAlivePacket> packet) {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
|
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet) {
|
||||||
{
|
|
||||||
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PendingConnection::send(std::shared_ptr<Packet> packet)
|
void PendingConnection::send(std::shared_ptr<Packet> packet) {
|
||||||
{
|
|
||||||
connection->send(packet);
|
connection->send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring PendingConnection::getName()
|
std::wstring PendingConnection::getName() {
|
||||||
{
|
|
||||||
return L"Unimplemented";
|
return L"Unimplemented";
|
||||||
// if (name != null) return name + " [" + connection.getRemoteAddress().toString() + "]";
|
// if (name != null) return name + " [" +
|
||||||
// return connection.getRemoteAddress().toString();
|
// connection.getRemoteAddress().toString() + "]"; return
|
||||||
|
// connection.getRemoteAddress().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PendingConnection::isServerPacketListener()
|
bool PendingConnection::isServerPacketListener() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,20 +6,22 @@ class LoginPacket;
|
||||||
class Connection;
|
class Connection;
|
||||||
class Random;
|
class Random;
|
||||||
|
|
||||||
|
class PendingConnection : public PacketListener {
|
||||||
class PendingConnection : public PacketListener
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int FAKE_LAG = 0;
|
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 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");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
static Random* random;
|
static Random* random;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Connection* connection;
|
Connection* connection;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool done;
|
bool done;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MinecraftServer* server;
|
MinecraftServer* server;
|
||||||
int _tick;
|
int _tick;
|
||||||
|
|
@ -28,14 +30,16 @@ private:
|
||||||
std::wstring loginKey;
|
std::wstring loginKey;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PendingConnection(MinecraftServer *server, Socket *socket, const std::wstring& id);
|
PendingConnection(MinecraftServer* server, Socket* socket,
|
||||||
|
const std::wstring& id);
|
||||||
~PendingConnection();
|
~PendingConnection();
|
||||||
void tick();
|
void tick();
|
||||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||||
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
virtual void handlePreLogin(std::shared_ptr<PreLoginPacket> packet);
|
||||||
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
virtual void handleLogin(std::shared_ptr<LoginPacket> packet);
|
||||||
virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
|
virtual void handleAcceptedLogin(std::shared_ptr<LoginPacket> packet);
|
||||||
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason, void *reasonObjects);
|
virtual void onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||||
|
void* reasonObjects);
|
||||||
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
|
virtual void handleGetInfo(std::shared_ptr<GetInfoPacket> packet);
|
||||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||||
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@
|
||||||
#include "../../Minecraft.World/Platform/System.h"
|
#include "../../Minecraft.World/Platform/System.h"
|
||||||
#include "PlayerList.h"
|
#include "PlayerList.h"
|
||||||
|
|
||||||
PlayerChunkMap::PlayerChunk::PlayerChunk(int x, int z, PlayerChunkMap *pcm) : pos(x,z)
|
PlayerChunkMap::PlayerChunk::PlayerChunk(int x, int z, PlayerChunkMap* pcm)
|
||||||
{
|
: pos(x, z) {
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
changes = 0;
|
changes = 0;
|
||||||
changedTiles = shortArray(MAX_CHANGES_BEFORE_RESEND);
|
changedTiles = shortArray(MAX_CHANGES_BEFORE_RESEND);
|
||||||
|
|
@ -25,48 +25,57 @@ PlayerChunkMap::PlayerChunk::PlayerChunk(int x, int z, PlayerChunkMap *pcm) : po
|
||||||
prioritised = false; // 4J added
|
prioritised = false; // 4J added
|
||||||
|
|
||||||
parent->getLevel()->cache->create(x, z);
|
parent->getLevel()->cache->create(x, z);
|
||||||
// 4J - added make sure our lights are up to date as soon as we make it. This is of particular concern for local clients, who have their data
|
// 4J - added make sure our lights are up to date as soon as we make it.
|
||||||
// shared as soon as the chunkvisibilitypacket is sent, and so could potentially create render data for this chunk before it has been properly lit.
|
// This is of particular concern for local clients, who have their data
|
||||||
while( parent->getLevel()->updateLights() )
|
// shared as soon as the chunkvisibilitypacket is sent, and so could
|
||||||
;
|
// potentially create render data for this chunk before it has been properly
|
||||||
|
// lit.
|
||||||
|
while (parent->getLevel()->updateLights());
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerChunkMap::PlayerChunk::~PlayerChunk()
|
PlayerChunkMap::PlayerChunk::~PlayerChunk() {
|
||||||
{
|
|
||||||
delete[] changedTiles.data; // 4jcraft, changed to []
|
delete[] changedTiles.data; // 4jcraft, changed to []
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J added - construct an an array of flags that indicate which entities are still waiting to have network packets sent out to say that they have been removed
|
// 4J added - construct an an array of flags that indicate which entities are
|
||||||
// If there aren't any entities to be flagged, this function does nothing. If there *are* entities to be added, uses the removedFound as an input to
|
// still waiting to have network packets sent out to say that they have been
|
||||||
// determine if the flag array has already been initialised at all - if it has been, then just adds flags to it; if it hasn't, then memsets the output
|
// removed If there aren't any entities to be flagged, this function does
|
||||||
// flag array and adds to it for this ServerPlayer.
|
// nothing. If there *are* entities to be added, uses the removedFound as an
|
||||||
void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int *flags, bool *flagToBeRemoved)
|
// input to determine if the flag array has already been initialised at all - if
|
||||||
{
|
// it has been, then just adds flags to it; if it hasn't, then memsets the
|
||||||
for(AUTO_VAR(it,players.begin()); it != players.end(); it++)
|
// output flag array and adds to it for this ServerPlayer.
|
||||||
{
|
void PlayerChunkMap::flagEntitiesToBeRemoved(unsigned int* flags,
|
||||||
|
bool* flagToBeRemoved) {
|
||||||
|
for (AUTO_VAR(it, players.begin()); it != players.end(); it++) {
|
||||||
std::shared_ptr<ServerPlayer> serverPlayer = *it;
|
std::shared_ptr<ServerPlayer> serverPlayer = *it;
|
||||||
serverPlayer->flagEntitiesToBeRemoved(flags, flagToBeRemoved);
|
serverPlayer->flagEntitiesToBeRemoved(flags, flagToBeRemoved);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::add(std::shared_ptr<ServerPlayer> player, bool sendPacket /*= true*/)
|
void PlayerChunkMap::PlayerChunk::add(std::shared_ptr<ServerPlayer> player,
|
||||||
{
|
bool sendPacket /*= true*/) {
|
||||||
// app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z);
|
// app.DebugPrintf("--- Adding player to chunk x=%d\tz=%d\n",x, z);
|
||||||
if (find(players.begin(),players.end(),player) != players.end())
|
if (find(players.begin(), players.end(), player) != players.end()) {
|
||||||
{
|
// 4J-PB - At the start of the game, lots of chunks are added, and we
|
||||||
// 4J-PB - At the start of the game, lots of chunks are added, and we can then move into an area that is outside the diameter of our starting area,
|
// can then move into an area that is outside the diameter of our
|
||||||
// but is inside the area loaded at the start.
|
// starting area, but is inside the area loaded at the start.
|
||||||
app.DebugPrintf("--- Adding player to chunk x=%d\t z=%d, but they are already in there!\n",pos.x, pos.z);
|
app.DebugPrintf(
|
||||||
|
"--- Adding player to chunk x=%d\t z=%d, but they are already in "
|
||||||
|
"there!\n",
|
||||||
|
pos.x, pos.z);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// assert(false);
|
// assert(false);
|
||||||
// 4J - was throw new IllegalStateException("Failed to add player. " + player + " already is in chunk " + x + ", " + z);
|
// 4J - was throw new IllegalStateException("Failed
|
||||||
|
// to add player. " + player + " already is in chunk " + x + ", " + z);
|
||||||
}
|
}
|
||||||
|
|
||||||
player->seenChunks.insert(pos);
|
player->seenChunks.insert(pos);
|
||||||
|
|
||||||
// 4J Added the sendPacket check. See PlayerChunkMap::add for the usage
|
// 4J Added the sendPacket check. See PlayerChunkMap::add for the usage
|
||||||
if( sendPacket ) player->connection->send( std::shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, true) ) );
|
if (sendPacket)
|
||||||
|
player->connection->send(std::shared_ptr<ChunkVisibilityPacket>(
|
||||||
|
new ChunkVisibilityPacket(pos.x, pos.z, true)));
|
||||||
|
|
||||||
players.push_back(player);
|
players.push_back(player);
|
||||||
|
|
||||||
|
|
@ -77,77 +86,79 @@ void PlayerChunkMap::PlayerChunk::add(std::shared_ptr<ServerPlayer> player, bool
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::PlayerChunk::remove(std::shared_ptr<ServerPlayer> player) {
|
||||||
{
|
|
||||||
PlayerChunkMap::PlayerChunk* toDelete = NULL;
|
PlayerChunkMap::PlayerChunk* toDelete = NULL;
|
||||||
|
|
||||||
//app.DebugPrintf("--- PlayerChunkMap::PlayerChunk::remove x=%d\tz=%d\n",x,z);
|
// app.DebugPrintf("--- PlayerChunkMap::PlayerChunk::remove
|
||||||
|
// x=%d\tz=%d\n",x,z);
|
||||||
AUTO_VAR(it, find(players.begin(), players.end(), player));
|
AUTO_VAR(it, find(players.begin(), players.end(), player));
|
||||||
if ( it == players.end())
|
if (it == players.end()) {
|
||||||
{
|
app.DebugPrintf(
|
||||||
app.DebugPrintf("--- INFO - Removing player from chunk x=%d\t z=%d, but they are not in that chunk!\n",pos.x, pos.z);
|
"--- INFO - Removing player from chunk x=%d\t z=%d, but they are "
|
||||||
|
"not in that chunk!\n",
|
||||||
|
pos.x, pos.z);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
players.erase(it);
|
players.erase(it);
|
||||||
if (players.size() == 0)
|
if (players.size() == 0) {
|
||||||
{
|
|
||||||
__int64 id = (pos.x + 0x7fffffffLL) | ((pos.z + 0x7fffffffLL) << 32);
|
__int64 id = (pos.x + 0x7fffffffLL) | ((pos.z + 0x7fffffffLL) << 32);
|
||||||
AUTO_VAR(it, parent->chunks.find(id));
|
AUTO_VAR(it, parent->chunks.find(id));
|
||||||
if( it != parent->chunks.end() )
|
if (it != parent->chunks.end()) {
|
||||||
{
|
toDelete = it->second; // Don't delete until the end of the
|
||||||
toDelete = it->second; // Don't delete until the end of the function, as this might be this instance
|
// function, as this might be this instance
|
||||||
parent->chunks.erase(it);
|
parent->chunks.erase(it);
|
||||||
}
|
}
|
||||||
if (changes > 0)
|
if (changes > 0) {
|
||||||
{
|
AUTO_VAR(it, find(parent->changedChunks.begin(),
|
||||||
AUTO_VAR(it, find(parent->changedChunks.begin(),parent->changedChunks.end(),this));
|
parent->changedChunks.end(), this));
|
||||||
parent->changedChunks.erase(it);
|
parent->changedChunks.erase(it);
|
||||||
}
|
}
|
||||||
parent->getLevel()->cache->drop(pos.x, pos.z);
|
parent->getLevel()->cache->drop(pos.x, pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
player->chunksToSend.remove(pos);
|
player->chunksToSend.remove(pos);
|
||||||
// 4J - I don't think there's any point sending these anymore, as we don't need to unload chunks with fixed sized maps
|
// 4J - I don't think there's any point sending these anymore, as we don't
|
||||||
// 4J - We do need to send these to unload entities in chunks when players are dead. If we do not and the entity is removed
|
// need to unload chunks with fixed sized maps 4J - We do need to send these
|
||||||
// while they are dead, that entity will remain in the clients world
|
// to unload entities in chunks when players are dead. If we do not and the
|
||||||
if (player->connection != NULL && player->seenChunks.find(pos) != player->seenChunks.end())
|
// entity is removed while they are dead, that entity will remain in the
|
||||||
{
|
// clients world
|
||||||
|
if (player->connection != NULL &&
|
||||||
|
player->seenChunks.find(pos) != player->seenChunks.end()) {
|
||||||
INetworkPlayer* thisNetPlayer = player->connection->getNetworkPlayer();
|
INetworkPlayer* thisNetPlayer = player->connection->getNetworkPlayer();
|
||||||
bool noOtherPlayersFound = true;
|
bool noOtherPlayersFound = true;
|
||||||
|
|
||||||
if( thisNetPlayer != NULL )
|
if (thisNetPlayer != NULL) {
|
||||||
{
|
for (AUTO_VAR(it, players.begin()); it < players.end(); ++it) {
|
||||||
for( AUTO_VAR(it, players.begin()); it < players.end(); ++it )
|
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> currPlayer = *it;
|
std::shared_ptr<ServerPlayer> currPlayer = *it;
|
||||||
INetworkPlayer *currNetPlayer = currPlayer->connection->getNetworkPlayer();
|
INetworkPlayer* currNetPlayer =
|
||||||
if( currNetPlayer != NULL && currNetPlayer->IsSameSystem( thisNetPlayer ) && currPlayer->seenChunks.find(pos) != currPlayer->seenChunks.end() )
|
currPlayer->connection->getNetworkPlayer();
|
||||||
{
|
if (currNetPlayer != NULL &&
|
||||||
|
currNetPlayer->IsSameSystem(thisNetPlayer) &&
|
||||||
|
currPlayer->seenChunks.find(pos) !=
|
||||||
|
currPlayer->seenChunks.end()) {
|
||||||
noOtherPlayersFound = false;
|
noOtherPlayersFound = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(noOtherPlayersFound)
|
if (noOtherPlayersFound) {
|
||||||
{
|
// wprintf(L"Sending ChunkVisiblity packet false for chunk
|
||||||
//wprintf(L"Sending ChunkVisiblity packet false for chunk (%d,%d) to player %ls\n", x, z, player->name.c_str() );
|
// (%d,%d) to player %ls\n", x, z, player->name.c_str() );
|
||||||
player->connection->send( std::shared_ptr<ChunkVisibilityPacket>( new ChunkVisibilityPacket(pos.x, pos.z, false) ) );
|
player->connection->send(std::shared_ptr<ChunkVisibilityPacket>(
|
||||||
|
new ChunkVisibilityPacket(pos.x, pos.z, false)));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
// app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer
|
||||||
{
|
// is NULL\n");
|
||||||
//app.DebugPrintf("PlayerChunkMap::PlayerChunk::remove - QNetPlayer is NULL\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete toDelete;
|
delete toDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::tileChanged(int x, int y, int z)
|
void PlayerChunkMap::PlayerChunk::tileChanged(int x, int y, int z) {
|
||||||
{
|
if (changes == 0) {
|
||||||
if (changes == 0)
|
|
||||||
{
|
|
||||||
parent->changedChunks.push_back(this);
|
parent->changedChunks.push_back(this);
|
||||||
xChangeMin = xChangeMax = x;
|
xChangeMin = xChangeMax = x;
|
||||||
yChangeMin = yChangeMax = y;
|
yChangeMin = yChangeMax = y;
|
||||||
|
|
@ -162,12 +173,10 @@ void PlayerChunkMap::PlayerChunk::tileChanged(int x, int y, int z)
|
||||||
if (zChangeMin > z) zChangeMin = z;
|
if (zChangeMin > z) zChangeMin = z;
|
||||||
if (zChangeMax < z) zChangeMax = z;
|
if (zChangeMax < z) zChangeMax = z;
|
||||||
|
|
||||||
if (changes < MAX_CHANGES_BEFORE_RESEND)
|
if (changes < MAX_CHANGES_BEFORE_RESEND) {
|
||||||
{
|
|
||||||
short id = (short)((x << 12) | (z << 8) | (y));
|
short id = (short)((x << 12) | (z << 8) | (y));
|
||||||
|
|
||||||
for (int i = 0; i < changes; i++)
|
for (int i = 0; i < changes; i++) {
|
||||||
{
|
|
||||||
if (changedTiles[i] == id) return;
|
if (changedTiles[i] == id) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,143 +184,140 @@ void PlayerChunkMap::PlayerChunk::tileChanged(int x, int y, int z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J added - make sure that any tile updates for the chunk at this location get prioritised for sending
|
// 4J added - make sure that any tile updates for the chunk at this location get
|
||||||
void PlayerChunkMap::PlayerChunk::prioritiseTileChanges()
|
// prioritised for sending
|
||||||
{
|
void PlayerChunkMap::PlayerChunk::prioritiseTileChanges() {
|
||||||
prioritised = true;
|
prioritised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet)
|
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<Packet> packet) {
|
||||||
{
|
|
||||||
std::vector<std::shared_ptr<ServerPlayer> > sentTo;
|
std::vector<std::shared_ptr<ServerPlayer> > sentTo;
|
||||||
for (unsigned int i = 0; i < players.size(); i++)
|
for (unsigned int i = 0; i < players.size(); i++) {
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> player = players[i];
|
std::shared_ptr<ServerPlayer> player = players[i];
|
||||||
|
|
||||||
// 4J - don't send to a player we've already sent this data to that shares the same machine. TileUpdatePacket,
|
// 4J - don't send to a player we've already sent this data to that
|
||||||
// ChunkTilesUpdatePacket and SignUpdatePacket all used to limit themselves to sending once to each machine
|
// shares the same machine. TileUpdatePacket, ChunkTilesUpdatePacket and
|
||||||
// by only sending to the primary player on each machine. This was causing trouble for split screen
|
// SignUpdatePacket all used to limit themselves to sending once to each
|
||||||
// as updates were only coming in for the region round this one player. Now these packets can be sent to any
|
// machine by only sending to the primary player on each machine. This
|
||||||
// player, but we try to restrict the network impact this has by not resending to the one machine
|
// was causing trouble for split screen as updates were only coming in
|
||||||
|
// for the region round this one player. Now these packets can be sent
|
||||||
|
// to any player, but we try to restrict the network impact this has by
|
||||||
|
// not resending to the one machine
|
||||||
bool dontSend = false;
|
bool dontSend = false;
|
||||||
if( sentTo.size() )
|
if (sentTo.size()) {
|
||||||
{
|
|
||||||
INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer();
|
INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer();
|
||||||
if( thisPlayer == NULL )
|
if (thisPlayer == NULL) {
|
||||||
{
|
|
||||||
dontSend = true;
|
dontSend = true;
|
||||||
}
|
} else {
|
||||||
else
|
for (unsigned int j = 0; j < sentTo.size(); j++) {
|
||||||
{
|
|
||||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
INetworkPlayer* otherPlayer =
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
player2->connection->getNetworkPlayer();
|
||||||
{
|
if (otherPlayer != NULL &&
|
||||||
|
thisPlayer->IsSameSystem(otherPlayer)) {
|
||||||
dontSend = true;
|
dontSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( dontSend )
|
if (dontSend) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Changed to get the flag index for the player before we send a packet. This flag is updated when we queue
|
// 4J Changed to get the flag index for the player before we send a
|
||||||
// for send the first BlockRegionUpdatePacket for this chunk to that player/players system. Therefore there is no need to
|
// packet. This flag is updated when we queue for send the first
|
||||||
// send tile updates or other updates until that has been sent
|
// BlockRegionUpdatePacket for this chunk to that player/players system.
|
||||||
int flagIndex = ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
// Therefore there is no need to send tile updates or other updates
|
||||||
if (player->seenChunks.find(pos) != player->seenChunks.end() && (player->connection->isLocal() || g_NetworkManager.SystemFlagGet(player->connection->getNetworkPlayer(),flagIndex) ))
|
// until that has been sent
|
||||||
{
|
int flagIndex =
|
||||||
|
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||||
|
if (player->seenChunks.find(pos) != player->seenChunks.end() &&
|
||||||
|
(player->connection->isLocal() ||
|
||||||
|
g_NetworkManager.SystemFlagGet(
|
||||||
|
player->connection->getNetworkPlayer(), flagIndex))) {
|
||||||
player->connection->send(packet);
|
player->connection->send(packet);
|
||||||
sentTo.push_back(player);
|
sentTo.push_back(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now also check round all the players that are involved in this game. We also want to send the packet
|
// Now also check round all the players that are involved in this game. We
|
||||||
// to them if their system hasn't received it already, but they have received the first BlockRegionUpdatePacket for this
|
// also want to send the packet to them if their system hasn't received it
|
||||||
// chunk
|
// already, but they have received the first BlockRegionUpdatePacket for
|
||||||
|
// this chunk
|
||||||
|
|
||||||
// Make sure we are only doing this for BlockRegionUpdatePacket, ChunkTilesUpdatePacket and TileUpdatePacket.
|
// Make sure we are only doing this for BlockRegionUpdatePacket,
|
||||||
// We'll be potentially sending to players who aren't on the same level as this packet is intended for,
|
// ChunkTilesUpdatePacket and TileUpdatePacket. We'll be potentially sending
|
||||||
// and only these 3 packets have so far been updated to be able to encode the level so they are robust
|
// to players who aren't on the same level as this packet is intended for,
|
||||||
// enough to cope with this
|
// and only these 3 packets have so far been updated to be able to encode
|
||||||
if(!( ( packet->getId() == 51 ) || ( packet->getId() == 52 ) || ( packet->getId() == 53 ) ) )
|
// the level so they are robust enough to cope with this
|
||||||
{
|
if (!((packet->getId() == 51) || (packet->getId() == 52) ||
|
||||||
|
(packet->getId() == 53))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < parent->level->getServer()->getPlayers()->players.size(); i++ )
|
for (int i = 0;
|
||||||
{
|
i < parent->level->getServer()->getPlayers()->players.size(); i++) {
|
||||||
std::shared_ptr<ServerPlayer> player = parent->level->getServer()->getPlayers()->players[i];
|
std::shared_ptr<ServerPlayer> player =
|
||||||
// Don't worry about local players, they get all their updates through sharing level with the server anyway
|
parent->level->getServer()->getPlayers()->players[i];
|
||||||
|
// Don't worry about local players, they get all their updates through
|
||||||
|
// sharing level with the server anyway
|
||||||
if (player->connection == NULL) continue;
|
if (player->connection == NULL) continue;
|
||||||
if (player->connection->isLocal()) continue;
|
if (player->connection->isLocal()) continue;
|
||||||
|
|
||||||
// Don't worry about this player if they haven't had this chunk yet (this flag will be the
|
// Don't worry about this player if they haven't had this chunk yet
|
||||||
// same for all players on the same system)
|
// (this flag will be the same for all players on the same system)
|
||||||
int flagIndex = ServerPlayer::getFlagIndexForChunk(pos,parent->dimension);
|
int flagIndex =
|
||||||
if(!g_NetworkManager.SystemFlagGet(player->connection->getNetworkPlayer(),flagIndex)) continue;
|
ServerPlayer::getFlagIndexForChunk(pos, parent->dimension);
|
||||||
|
if (!g_NetworkManager.SystemFlagGet(
|
||||||
|
player->connection->getNetworkPlayer(), flagIndex))
|
||||||
|
continue;
|
||||||
|
|
||||||
// From here on the same rules as in the loop above - don't send it if we've already sent to the same system
|
// From here on the same rules as in the loop above - don't send it if
|
||||||
|
// we've already sent to the same system
|
||||||
bool dontSend = false;
|
bool dontSend = false;
|
||||||
if( sentTo.size() )
|
if (sentTo.size()) {
|
||||||
{
|
|
||||||
INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer();
|
INetworkPlayer* thisPlayer = player->connection->getNetworkPlayer();
|
||||||
if( thisPlayer == NULL )
|
if (thisPlayer == NULL) {
|
||||||
{
|
|
||||||
dontSend = true;
|
dontSend = true;
|
||||||
}
|
} else {
|
||||||
else
|
for (unsigned int j = 0; j < sentTo.size(); j++) {
|
||||||
{
|
|
||||||
for(unsigned int j = 0; j < sentTo.size(); j++ )
|
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
std::shared_ptr<ServerPlayer> player2 = sentTo[j];
|
||||||
INetworkPlayer *otherPlayer = player2->connection->getNetworkPlayer();
|
INetworkPlayer* otherPlayer =
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
player2->connection->getNetworkPlayer();
|
||||||
{
|
if (otherPlayer != NULL &&
|
||||||
|
thisPlayer->IsSameSystem(otherPlayer)) {
|
||||||
dontSend = true;
|
dontSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !dontSend )
|
if (!dontSend) {
|
||||||
{
|
|
||||||
player->connection->send(packet);
|
player->connection->send(packet);
|
||||||
sentTo.push_back(player);
|
sentTo.push_back(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) {
|
||||||
{
|
|
||||||
bool didRegionUpdate = false;
|
bool didRegionUpdate = false;
|
||||||
ServerLevel* level = parent->getLevel();
|
ServerLevel* level = parent->getLevel();
|
||||||
if (ticksToNextRegionUpdate > 0) ticksToNextRegionUpdate--;
|
if (ticksToNextRegionUpdate > 0) ticksToNextRegionUpdate--;
|
||||||
if (changes == 0)
|
if (changes == 0) {
|
||||||
{
|
|
||||||
prioritised = false;
|
prioritised = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (changes == 1)
|
if (changes == 1) {
|
||||||
{
|
|
||||||
int x = pos.x * 16 + xChangeMin;
|
int x = pos.x * 16 + xChangeMin;
|
||||||
int y = yChangeMin;
|
int y = yChangeMin;
|
||||||
int z = pos.z * 16 + zChangeMin;
|
int z = pos.z * 16 + zChangeMin;
|
||||||
broadcast( std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) ) );
|
broadcast(std::shared_ptr<TileUpdatePacket>(
|
||||||
if (level->isEntityTile(x, y, z))
|
new TileUpdatePacket(x, y, z, level)));
|
||||||
{
|
if (level->isEntityTile(x, y, z)) {
|
||||||
broadcast(level->getTileEntity(x, y, z));
|
broadcast(level->getTileEntity(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
} else if (changes == MAX_CHANGES_BEFORE_RESEND) {
|
||||||
else if (changes == MAX_CHANGES_BEFORE_RESEND)
|
|
||||||
{
|
|
||||||
// 4J added, to allow limiting of region update packets created
|
// 4J added, to allow limiting of region update packets created
|
||||||
if( !prioritised )
|
if (!prioritised) {
|
||||||
{
|
if (!allowRegionUpdate || (ticksToNextRegionUpdate > 0)) {
|
||||||
if( !allowRegionUpdate || ( ticksToNextRegionUpdate > 0 ) )
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -325,32 +331,36 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
||||||
int ys = yChangeMax - yChangeMin + 2;
|
int ys = yChangeMax - yChangeMin + 2;
|
||||||
int zs = zChangeMax - zChangeMin + 1;
|
int zs = zChangeMax - zChangeMin + 1;
|
||||||
|
|
||||||
// Fix for buf #95007 : TCR #001 BAS Game Stability: TU12: Code: Compliance: More than 192 dropped items causes game to freeze or crash.
|
// Fix for buf #95007 : TCR #001 BAS Game Stability: TU12: Code:
|
||||||
// Block region update packets can only encode ys in a range of 1 - 256
|
// Compliance: More than 192 dropped items causes game to freeze or
|
||||||
|
// crash. Block region update packets can only encode ys in a range of 1
|
||||||
|
// - 256
|
||||||
if (ys > 256) ys = 256;
|
if (ys > 256) ys = 256;
|
||||||
|
|
||||||
broadcast( std::shared_ptr<BlockRegionUpdatePacket>( new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level) ) );
|
broadcast(std::shared_ptr<BlockRegionUpdatePacket>(
|
||||||
std::vector<std::shared_ptr<TileEntity> > *tes = level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys, zp + zs);
|
new BlockRegionUpdatePacket(xp, yp, zp, xs, ys, zs, level)));
|
||||||
for (unsigned int i = 0; i < tes->size(); i++)
|
std::vector<std::shared_ptr<TileEntity> >* tes =
|
||||||
{
|
level->getTileEntitiesInRegion(xp, yp, zp, xp + xs, yp + ys,
|
||||||
|
zp + zs);
|
||||||
|
for (unsigned int i = 0; i < tes->size(); i++) {
|
||||||
broadcast(tes->at(i));
|
broadcast(tes->at(i));
|
||||||
}
|
}
|
||||||
delete tes;
|
delete tes;
|
||||||
ticksToNextRegionUpdate = MIN_TICKS_BETWEEN_REGION_UPDATE;
|
ticksToNextRegionUpdate = MIN_TICKS_BETWEEN_REGION_UPDATE;
|
||||||
didRegionUpdate = true;
|
didRegionUpdate = true;
|
||||||
}
|
} else {
|
||||||
else
|
// 4J As we only get here if changes is less than
|
||||||
{
|
// MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in
|
||||||
// 4J As we only get here if changes is less than MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in the packet
|
// the packet
|
||||||
broadcast( std::shared_ptr<ChunkTilesUpdatePacket>( new ChunkTilesUpdatePacket(pos.x, pos.z, changedTiles, (uint8_t)changes, level) ) );
|
broadcast(
|
||||||
for (int i = 0; i < changes; i++)
|
std::shared_ptr<ChunkTilesUpdatePacket>(new ChunkTilesUpdatePacket(
|
||||||
{
|
pos.x, pos.z, changedTiles, (uint8_t)changes, level)));
|
||||||
|
for (int i = 0; i < changes; i++) {
|
||||||
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
|
int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15);
|
||||||
int y = ((changedTiles[i]) & 255);
|
int y = ((changedTiles[i]) & 255);
|
||||||
int z = pos.z * 16 + ((changedTiles[i] >> 8) & 15);
|
int z = pos.z * 16 + ((changedTiles[i] >> 8) & 15);
|
||||||
|
|
||||||
if (level->isEntityTile(x, y, z))
|
if (level->isEntityTile(x, y, z)) {
|
||||||
{
|
|
||||||
// System.out.println("Sending!");
|
// System.out.println("Sending!");
|
||||||
broadcast(level->getTileEntity(x, y, z));
|
broadcast(level->getTileEntity(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
@ -361,20 +371,16 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate)
|
||||||
return didRegionUpdate;
|
return didRegionUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<TileEntity> te)
|
void PlayerChunkMap::PlayerChunk::broadcast(std::shared_ptr<TileEntity> te) {
|
||||||
{
|
if (te != NULL) {
|
||||||
if (te != NULL)
|
|
||||||
{
|
|
||||||
std::shared_ptr<Packet> p = te->getUpdatePacket();
|
std::shared_ptr<Packet> p = te->getUpdatePacket();
|
||||||
if (p != NULL)
|
if (p != NULL) {
|
||||||
{
|
|
||||||
broadcast(p);
|
broadcast(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerChunkMap::PlayerChunkMap(ServerLevel *level, int dimension, int radius)
|
PlayerChunkMap::PlayerChunkMap(ServerLevel* level, int dimension, int radius) {
|
||||||
{
|
|
||||||
assert(radius <= MAX_VIEW_DISTANCE);
|
assert(radius <= MAX_VIEW_DISTANCE);
|
||||||
assert(radius >= MIN_VIEW_DISTANCE);
|
assert(radius >= MIN_VIEW_DISTANCE);
|
||||||
this->radius = radius;
|
this->radius = radius;
|
||||||
|
|
@ -382,46 +388,40 @@ PlayerChunkMap::PlayerChunkMap(ServerLevel *level, int dimension, int radius)
|
||||||
this->dimension = dimension;
|
this->dimension = dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerChunkMap::~PlayerChunkMap()
|
PlayerChunkMap::~PlayerChunkMap() {
|
||||||
{
|
for (AUTO_VAR(it, chunks.begin()); it != chunks.end(); it++) {
|
||||||
for( AUTO_VAR(it, chunks.begin()); it != chunks.end(); it++ )
|
|
||||||
{
|
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerLevel *PlayerChunkMap::getLevel()
|
ServerLevel* PlayerChunkMap::getLevel() { return level; }
|
||||||
{
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayerChunkMap::tick()
|
void PlayerChunkMap::tick() {
|
||||||
{
|
// 4J - some changes here so that we only send one region update per tick.
|
||||||
// 4J - some changes here so that we only send one region update per tick. The chunks themselves also
|
// The chunks themselves also limit their resend rate to once every
|
||||||
// limit their resend rate to once every MIN_TICKS_BETWEEN_REGION_UPDATE ticks
|
// MIN_TICKS_BETWEEN_REGION_UPDATE ticks
|
||||||
bool regionUpdateSent = false;
|
bool regionUpdateSent = false;
|
||||||
for (unsigned int i = 0; i < changedChunks.size();)
|
for (unsigned int i = 0; i < changedChunks.size();) {
|
||||||
{
|
regionUpdateSent |=
|
||||||
regionUpdateSent |= changedChunks[i]->broadcastChanges(!regionUpdateSent);
|
changedChunks[i]->broadcastChanges(!regionUpdateSent);
|
||||||
// Changes will be 0 if the chunk actually sent something, in which case we can delete it from this array
|
// Changes will be 0 if the chunk actually sent something, in which case
|
||||||
if( changedChunks[i]->changes == 0 )
|
// we can delete it from this array
|
||||||
{
|
if (changedChunks[i]->changes == 0) {
|
||||||
changedChunks[i] = changedChunks.back();
|
changedChunks[i] = changedChunks.back();
|
||||||
changedChunks.pop_back();
|
changedChunks.pop_back();
|
||||||
}
|
} else {
|
||||||
else
|
// Limiting of some kind means we didn't send this chunk so move
|
||||||
{
|
// onto the next
|
||||||
// Limiting of some kind means we didn't send this chunk so move onto the next
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( unsigned int i = 0; i < players.size(); i++ )
|
for (unsigned int i = 0; i < players.size(); i++) {
|
||||||
{
|
|
||||||
tickAddRequests(players[i]);
|
tickAddRequests(players[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - Added 1.1 but not relevant to us as we never no 0 players anyway, and don't think we should be dropping stuff
|
// 4J Stu - Added 1.1 but not relevant to us as we never no 0 players
|
||||||
|
// anyway, and don't think we should be dropping stuff
|
||||||
// if (players.isEmpty()) {
|
// if (players.isEmpty()) {
|
||||||
// ServerLevel level = server.getLevel(this.dimension);
|
// ServerLevel level = server.getLevel(this.dimension);
|
||||||
// Dimension dimension = level.dimension;
|
// Dimension dimension = level.dimension;
|
||||||
|
|
@ -431,24 +431,20 @@ void PlayerChunkMap::tick()
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerChunkMap::hasChunk(int x, int z)
|
bool PlayerChunkMap::hasChunk(int x, int z) {
|
||||||
{
|
|
||||||
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
||||||
return chunks.find(id) != chunks.end();
|
return chunks.find(id) != chunks.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerChunkMap::PlayerChunk *PlayerChunkMap::getChunk(int x, int z, bool create)
|
PlayerChunkMap::PlayerChunk* PlayerChunkMap::getChunk(int x, int z,
|
||||||
{
|
bool create) {
|
||||||
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
||||||
AUTO_VAR(it, chunks.find(id));
|
AUTO_VAR(it, chunks.find(id));
|
||||||
|
|
||||||
PlayerChunk* chunk = NULL;
|
PlayerChunk* chunk = NULL;
|
||||||
if( it != chunks.end() )
|
if (it != chunks.end()) {
|
||||||
{
|
|
||||||
chunk = it->second;
|
chunk = it->second;
|
||||||
}
|
} else if (create) {
|
||||||
else if ( create)
|
|
||||||
{
|
|
||||||
chunk = new PlayerChunk(x, z, this);
|
chunk = new PlayerChunk(x, z, this);
|
||||||
chunks[id] = chunk;
|
chunks[id] = chunk;
|
||||||
}
|
}
|
||||||
|
|
@ -456,33 +452,26 @@ PlayerChunkMap::PlayerChunk *PlayerChunkMap::getChunk(int x, int z, bool create)
|
||||||
return chunk;
|
return chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - added. If a chunk exists, add a player to it straight away. If it doesn't exist,
|
// 4J - added. If a chunk exists, add a player to it straight away. If it
|
||||||
// queue a request for it to be created.
|
// doesn't exist, queue a request for it to be created.
|
||||||
void PlayerChunkMap::getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::getChunkAndAddPlayer(
|
||||||
{
|
int x, int z, std::shared_ptr<ServerPlayer> player) {
|
||||||
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
||||||
AUTO_VAR(it, chunks.find(id));
|
AUTO_VAR(it, chunks.find(id));
|
||||||
|
|
||||||
if( it != chunks.end() )
|
if (it != chunks.end()) {
|
||||||
{
|
|
||||||
it->second->add(player);
|
it->second->add(player);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
addRequests.push_back(PlayerChunkAddRequest(x, z, player));
|
addRequests.push_back(PlayerChunkAddRequest(x, z, player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - added. If the chunk and player are in the queue to be added, remove from there. Otherwise
|
// 4J - added. If the chunk and player are in the queue to be added, remove from
|
||||||
// attempt to remove from main chunk map.
|
// there. Otherwise attempt to remove from main chunk map.
|
||||||
void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::getChunkAndRemovePlayer(
|
||||||
{
|
int x, int z, std::shared_ptr<ServerPlayer> player) {
|
||||||
for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++ )
|
for (AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++) {
|
||||||
{
|
if ((it->x == x) && (it->z == z) && (it->player == player)) {
|
||||||
if( ( it->x == x ) &&
|
|
||||||
( it->z == z ) &&
|
|
||||||
( it->player == player ) )
|
|
||||||
{
|
|
||||||
addRequests.erase(it);
|
addRequests.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -490,33 +479,27 @@ void PlayerChunkMap::getChunkAndRemovePlayer(int x, int z, std::shared_ptr<Serve
|
||||||
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
__int64 id = (x + 0x7fffffffLL) | ((z + 0x7fffffffLL) << 32);
|
||||||
AUTO_VAR(it, chunks.find(id));
|
AUTO_VAR(it, chunks.find(id));
|
||||||
|
|
||||||
if( it != chunks.end() )
|
if (it != chunks.end()) {
|
||||||
{
|
|
||||||
it->second->remove(player);
|
it->second->remove(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - added - actually create & add player to a playerchunk, if there is one queued for this player.
|
// 4J - added - actually create & add player to a playerchunk, if there is one
|
||||||
void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player)
|
// queued for this player.
|
||||||
{
|
void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player) {
|
||||||
if( addRequests.size() )
|
if (addRequests.size()) {
|
||||||
{
|
|
||||||
// Find the nearest chunk request to the player
|
// Find the nearest chunk request to the player
|
||||||
int px = (int)player->x;
|
int px = (int)player->x;
|
||||||
int pz = (int)player->z;
|
int pz = (int)player->z;
|
||||||
int minDistSq = -1;
|
int minDistSq = -1;
|
||||||
|
|
||||||
AUTO_VAR(itNearest, addRequests.end());
|
AUTO_VAR(itNearest, addRequests.end());
|
||||||
for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++ )
|
for (AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); it++) {
|
||||||
{
|
if (it->player == player) {
|
||||||
if( it->player == player )
|
|
||||||
{
|
|
||||||
int xm = (it->x * 16) + 8;
|
int xm = (it->x * 16) + 8;
|
||||||
int zm = (it->z * 16) + 8;
|
int zm = (it->z * 16) + 8;
|
||||||
int distSq = (xm - px) * (xm - px) +
|
int distSq = (xm - px) * (xm - px) + (zm - pz) * (zm - pz);
|
||||||
(zm - pz) * (zm - pz);
|
if ((minDistSq == -1) || (distSq < minDistSq)) {
|
||||||
if( ( minDistSq == -1 ) || ( distSq < minDistSq ) )
|
|
||||||
{
|
|
||||||
minDistSq = distSq;
|
minDistSq = distSq;
|
||||||
itNearest = it;
|
itNearest = it;
|
||||||
}
|
}
|
||||||
|
|
@ -524,8 +507,7 @@ void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we found one at all, then do this one
|
// If we found one at all, then do this one
|
||||||
if( itNearest != addRequests.end() )
|
if (itNearest != addRequests.end()) {
|
||||||
{
|
|
||||||
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
getChunk(itNearest->x, itNearest->z, true)->add(itNearest->player);
|
||||||
addRequests.erase(itNearest);
|
addRequests.erase(itNearest);
|
||||||
return;
|
return;
|
||||||
|
|
@ -533,30 +515,26 @@ void PlayerChunkMap::tickAddRequests(std::shared_ptr<ServerPlayer> player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::broadcastTileUpdate(std::shared_ptr<Packet> packet, int x, int y, int z)
|
void PlayerChunkMap::broadcastTileUpdate(std::shared_ptr<Packet> packet, int x,
|
||||||
{
|
int y, int z) {
|
||||||
int xc = x >> 4;
|
int xc = x >> 4;
|
||||||
int zc = z >> 4;
|
int zc = z >> 4;
|
||||||
PlayerChunk* chunk = getChunk(xc, zc, false);
|
PlayerChunk* chunk = getChunk(xc, zc, false);
|
||||||
if (chunk != NULL)
|
if (chunk != NULL) {
|
||||||
{
|
|
||||||
chunk->broadcast(packet);
|
chunk->broadcast(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::tileChanged(int x, int y, int z)
|
void PlayerChunkMap::tileChanged(int x, int y, int z) {
|
||||||
{
|
|
||||||
int xc = x >> 4;
|
int xc = x >> 4;
|
||||||
int zc = z >> 4;
|
int zc = z >> 4;
|
||||||
PlayerChunk* chunk = getChunk(xc, zc, false);
|
PlayerChunk* chunk = getChunk(xc, zc, false);
|
||||||
if (chunk != NULL)
|
if (chunk != NULL) {
|
||||||
{
|
|
||||||
chunk->tileChanged(x & 15, y, z & 15);
|
chunk->tileChanged(x & 15, y, z & 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerChunkMap::isTrackingTile(int x, int y, int z)
|
bool PlayerChunkMap::isTrackingTile(int x, int y, int z) {
|
||||||
{
|
|
||||||
int xc = x >> 4;
|
int xc = x >> 4;
|
||||||
int zc = z >> 4;
|
int zc = z >> 4;
|
||||||
PlayerChunk* chunk = getChunk(xc, zc, false);
|
PlayerChunk* chunk = getChunk(xc, zc, false);
|
||||||
|
|
@ -564,20 +542,18 @@ bool PlayerChunkMap::isTrackingTile(int x, int y, int z)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J added - make sure that any tile updates for the chunk at this location get prioritised for sending
|
// 4J added - make sure that any tile updates for the chunk at this location get
|
||||||
void PlayerChunkMap::prioritiseTileChanges(int x, int y, int z)
|
// prioritised for sending
|
||||||
{
|
void PlayerChunkMap::prioritiseTileChanges(int x, int y, int z) {
|
||||||
int xc = x >> 4;
|
int xc = x >> 4;
|
||||||
int zc = z >> 4;
|
int zc = z >> 4;
|
||||||
PlayerChunk* chunk = getChunk(xc, zc, false);
|
PlayerChunk* chunk = getChunk(xc, zc, false);
|
||||||
if (chunk != NULL)
|
if (chunk != NULL) {
|
||||||
{
|
|
||||||
chunk->prioritiseTileChanges();
|
chunk->prioritiseTileChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player) {
|
||||||
{
|
|
||||||
static int direction[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
|
static int direction[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
|
||||||
|
|
||||||
int xc = (int)player->x >> 4;
|
int xc = (int)player->x >> 4;
|
||||||
|
|
@ -600,20 +576,18 @@ void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player)
|
||||||
// Origin
|
// Origin
|
||||||
getChunk(xc, zc, true)->add(player, false);
|
getChunk(xc, zc, true)->add(player, false);
|
||||||
|
|
||||||
// 4J Added so we send an area packet rather than one visibility packet per chunk
|
// 4J Added so we send an area packet rather than one visibility packet per
|
||||||
|
// chunk
|
||||||
int minX, maxX, minZ, maxZ;
|
int minX, maxX, minZ, maxZ;
|
||||||
minX = maxX = xc;
|
minX = maxX = xc;
|
||||||
minZ = maxZ = zc;
|
minZ = maxZ = zc;
|
||||||
|
|
||||||
// All but the last leg
|
// All but the last leg
|
||||||
for (int legSize = 1; legSize <= size * 2; legSize++)
|
for (int legSize = 1; legSize <= size * 2; legSize++) {
|
||||||
{
|
for (int leg = 0; leg < 2; leg++) {
|
||||||
for (int leg = 0; leg < 2; leg++)
|
|
||||||
{
|
|
||||||
int* dir = direction[facing++ % 4];
|
int* dir = direction[facing++ % 4];
|
||||||
|
|
||||||
for (int k = 0; k < legSize; k++)
|
for (int k = 0; k < legSize; k++) {
|
||||||
{
|
|
||||||
dx += dir[0];
|
dx += dir[0];
|
||||||
dz += dir[1];
|
dz += dir[1];
|
||||||
|
|
||||||
|
|
@ -632,8 +606,7 @@ void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player)
|
||||||
|
|
||||||
// Final leg
|
// Final leg
|
||||||
facing %= 4;
|
facing %= 4;
|
||||||
for (int k = 0; k < size * 2; k++)
|
for (int k = 0; k < size * 2; k++) {
|
||||||
{
|
|
||||||
dx += direction[facing][0];
|
dx += direction[facing][0];
|
||||||
dz += direction[facing][1];
|
dz += direction[facing][1];
|
||||||
|
|
||||||
|
|
@ -649,24 +622,22 @@ void PlayerChunkMap::add(std::shared_ptr<ServerPlayer> player)
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
player->connection->send( std::shared_ptr<ChunkVisibilityAreaPacket>( new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ) ) );
|
player->connection->send(std::shared_ptr<ChunkVisibilityAreaPacket>(
|
||||||
|
new ChunkVisibilityAreaPacket(minX, maxX, minZ, maxZ)));
|
||||||
|
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
getLevel()->cache->dontDrop(xc, zc);
|
getLevel()->cache->dontDrop(xc, zc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
players.push_back(player);
|
players.push_back(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerChunkMap::remove(std::shared_ptr<ServerPlayer> player)
|
void PlayerChunkMap::remove(std::shared_ptr<ServerPlayer> player) {
|
||||||
{
|
|
||||||
int xc = ((int)player->lastMoveX) >> 4;
|
int xc = ((int)player->lastMoveX) >> 4;
|
||||||
int zc = ((int)player->lastMoveZ) >> 4;
|
int zc = ((int)player->lastMoveZ) >> 4;
|
||||||
|
|
||||||
for (int x = xc - radius; x <= xc + radius; x++)
|
for (int x = xc - radius; x <= xc + radius; x++)
|
||||||
for (int z = zc - radius; z <= zc + radius; z++)
|
for (int z = zc - radius; z <= zc + radius; z++) {
|
||||||
{
|
|
||||||
PlayerChunk* playerChunk = getChunk(x, z, false);
|
PlayerChunk* playerChunk = getChunk(x, z, false);
|
||||||
if (playerChunk != NULL) playerChunk->remove(player);
|
if (playerChunk != NULL) playerChunk->remove(player);
|
||||||
}
|
}
|
||||||
|
|
@ -675,23 +646,18 @@ void PlayerChunkMap::remove(std::shared_ptr<ServerPlayer> player)
|
||||||
if (players.size() > 0 && it != players.end())
|
if (players.size() > 0 && it != players.end())
|
||||||
players.erase(find(players.begin(), players.end(), player));
|
players.erase(find(players.begin(), players.end(), player));
|
||||||
|
|
||||||
// 4J - added - also remove any queued requests to be added to playerchunks here
|
// 4J - added - also remove any queued requests to be added to playerchunks
|
||||||
for( AUTO_VAR(it, addRequests.begin()); it != addRequests.end(); )
|
// here
|
||||||
{
|
for (AUTO_VAR(it, addRequests.begin()); it != addRequests.end();) {
|
||||||
if( it->player == player )
|
if (it->player == player) {
|
||||||
{
|
|
||||||
it = addRequests.erase(it);
|
it = addRequests.erase(it);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc)
|
bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc) {
|
||||||
{
|
|
||||||
// If the distance between x and xc
|
// If the distance between x and xc
|
||||||
int xd = x - xc;
|
int xd = x - xc;
|
||||||
int zd = z - zc;
|
int zd = z - zc;
|
||||||
|
|
@ -700,10 +666,10 @@ bool PlayerChunkMap::chunkInRange(int x, int z, int xc, int zc)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - have changed this so that we queue requests to add the player to chunks if they
|
// 4J - have changed this so that we queue requests to add the player to chunks
|
||||||
// need to be created, so that we aren't creating potentially 20 chunks per player per tick
|
// if they need to be created, so that we aren't creating potentially 20 chunks
|
||||||
void PlayerChunkMap::move(std::shared_ptr<ServerPlayer> player)
|
// per player per tick
|
||||||
{
|
void PlayerChunkMap::move(std::shared_ptr<ServerPlayer> player) {
|
||||||
int xc = ((int)player->x) >> 4;
|
int xc = ((int)player->x) >> 4;
|
||||||
int zc = ((int)player->z) >> 4;
|
int zc = ((int)player->z) >> 4;
|
||||||
|
|
||||||
|
|
@ -720,17 +686,16 @@ void PlayerChunkMap::move(std::shared_ptr<ServerPlayer> player)
|
||||||
if (xd == 0 && zd == 0) return;
|
if (xd == 0 && zd == 0) return;
|
||||||
|
|
||||||
for (int x = xc - radius; x <= xc + radius; x++)
|
for (int x = xc - radius; x <= xc + radius; x++)
|
||||||
for (int z = zc - radius; z <= zc + radius; z++)
|
for (int z = zc - radius; z <= zc + radius; z++) {
|
||||||
{
|
if (!chunkInRange(x, z, last_xc, last_zc)) {
|
||||||
if (!chunkInRange(x, z, last_xc, last_zc))
|
// 4J - changed from separate getChunk & add so we can wrap
|
||||||
{
|
// these operations up and queue
|
||||||
// 4J - changed from separate getChunk & add so we can wrap these operations up and queue
|
|
||||||
getChunkAndAddPlayer(x, z, player);
|
getChunkAndAddPlayer(x, z, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!chunkInRange(x - xd, z - zd, xc, zc))
|
if (!chunkInRange(x - xd, z - zd, xc, zc)) {
|
||||||
{
|
// 4J - changed from separate getChunk & remove so we can wrap
|
||||||
// 4J - changed from separate getChunk & remove so we can wrap these operations up and queue
|
// these operations up and queue
|
||||||
getChunkAndRemovePlayer(x - xd, z - zd, player);
|
getChunkAndRemovePlayer(x - xd, z - zd, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -739,54 +704,45 @@ void PlayerChunkMap::move(std::shared_ptr<ServerPlayer> player)
|
||||||
player->lastMoveZ = player->z;
|
player->lastMoveZ = player->z;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlayerChunkMap::getMaxRange()
|
int PlayerChunkMap::getMaxRange() { return radius * 16 - 16; }
|
||||||
{
|
|
||||||
return radius * 16 - 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PlayerChunkMap::isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk)
|
bool PlayerChunkMap::isPlayerIn(std::shared_ptr<ServerPlayer> player,
|
||||||
{
|
int xChunk, int zChunk) {
|
||||||
PlayerChunk* chunk = getChunk(xChunk, zChunk, false);
|
PlayerChunk* chunk = getChunk(xChunk, zChunk, false);
|
||||||
|
|
||||||
if(chunk == NULL)
|
if (chunk == NULL) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else
|
AUTO_VAR(it1,
|
||||||
{
|
find(chunk->players.begin(), chunk->players.end(), player));
|
||||||
AUTO_VAR(it1, find(chunk->players.begin(), chunk->players.end(), player));
|
AUTO_VAR(it2, find(player->chunksToSend.begin(),
|
||||||
AUTO_VAR(it2, find(player->chunksToSend.begin(), player->chunksToSend.end(), chunk->pos));
|
player->chunksToSend.end(), chunk->pos));
|
||||||
return it1 != chunk->players.end() && it2 == player->chunksToSend.end();
|
return it1 != chunk->players.end() && it2 == player->chunksToSend.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
//return chunk == NULL ? false : chunk->players->contains(player) && !player->chunksToSend->contains(chunk->pos);
|
// return chunk == NULL ? false : chunk->players->contains(player) &&
|
||||||
|
// !player->chunksToSend->contains(chunk->pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PlayerChunkMap::convertChunkRangeToBlock(int radius)
|
int PlayerChunkMap::convertChunkRangeToBlock(int radius) {
|
||||||
{
|
|
||||||
return radius * 16 - 16;
|
return radius * 16 - 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AP added for Vita so the range can be increased once the level starts
|
// AP added for Vita so the range can be increased once the level starts
|
||||||
void PlayerChunkMap::setRadius(int newRadius)
|
void PlayerChunkMap::setRadius(int newRadius) {
|
||||||
{
|
if (radius != newRadius) {
|
||||||
if( radius != newRadius )
|
|
||||||
{
|
|
||||||
PlayerList* players = level->getServer()->getPlayerList();
|
PlayerList* players = level->getServer()->getPlayerList();
|
||||||
for( int i = 0;i < players->players.size();i += 1 )
|
for (int i = 0; i < players->players.size(); i += 1) {
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> player = players->players[i];
|
std::shared_ptr<ServerPlayer> player = players->players[i];
|
||||||
if( player->level == level )
|
if (player->level == level) {
|
||||||
{
|
|
||||||
int xc = ((int)player->x) >> 4;
|
int xc = ((int)player->x) >> 4;
|
||||||
int zc = ((int)player->z) >> 4;
|
int zc = ((int)player->z) >> 4;
|
||||||
|
|
||||||
for (int x = xc - newRadius; x <= xc + newRadius; x++)
|
for (int x = xc - newRadius; x <= xc + newRadius; x++)
|
||||||
for (int z = zc - newRadius; z <= zc + newRadius; z++)
|
for (int z = zc - newRadius; z <= zc + newRadius; z++) {
|
||||||
{
|
|
||||||
// check if this chunk is outside the old radius area
|
// check if this chunk is outside the old radius area
|
||||||
if ( x < xc - radius || x > xc + radius || z < zc - radius || z > zc + radius )
|
if (x < xc - radius || x > xc + radius ||
|
||||||
{
|
z < zc - radius || z > zc + radius) {
|
||||||
getChunkAndAddPlayer(x, z, player);
|
getChunkAndAddPlayer(x, z, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ class MinecraftServer;
|
||||||
class Packet;
|
class Packet;
|
||||||
class TileEntity;
|
class TileEntity;
|
||||||
|
|
||||||
|
class PlayerChunkMap {
|
||||||
class PlayerChunkMap
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
static const int MAX_VIEW_DISTANCE = 30;
|
static const int MAX_VIEW_DISTANCE = 30;
|
||||||
|
|
@ -21,17 +19,18 @@ public:
|
||||||
static const int MIN_TICKS_BETWEEN_REGION_UPDATE = 10;
|
static const int MIN_TICKS_BETWEEN_REGION_UPDATE = 10;
|
||||||
|
|
||||||
// 4J - added
|
// 4J - added
|
||||||
class PlayerChunkAddRequest
|
class PlayerChunkAddRequest {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
int x, z;
|
int x, z;
|
||||||
std::shared_ptr<ServerPlayer> player;
|
std::shared_ptr<ServerPlayer> player;
|
||||||
PlayerChunkAddRequest(int x, int z, std::shared_ptr<ServerPlayer> player ) : x(x), z(z), player(player) {}
|
PlayerChunkAddRequest(int x, int z,
|
||||||
|
std::shared_ptr<ServerPlayer> player)
|
||||||
|
: x(x), z(z), player(player) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerChunk
|
class PlayerChunk {
|
||||||
{
|
|
||||||
friend class PlayerChunkMap;
|
friend class PlayerChunkMap;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerChunkMap* parent; // 4J added
|
PlayerChunkMap* parent; // 4J added
|
||||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||||
|
|
@ -50,7 +49,8 @@ public:
|
||||||
PlayerChunk(int x, int z, PlayerChunkMap* pcm);
|
PlayerChunk(int x, int z, PlayerChunkMap* pcm);
|
||||||
~PlayerChunk();
|
~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 add(std::shared_ptr<ServerPlayer> player, bool sendPacket = true);
|
||||||
void remove(std::shared_ptr<ServerPlayer> player);
|
void remove(std::shared_ptr<ServerPlayer> player);
|
||||||
void tileChanged(int x, int y, int z);
|
void tileChanged(int x, int y, int z);
|
||||||
|
|
@ -64,9 +64,11 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||||
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
void flagEntitiesToBeRemoved(unsigned int* flags,
|
||||||
|
bool* removedFound); // 4J added
|
||||||
private:
|
private:
|
||||||
std::unordered_map<__int64,PlayerChunk *,LongKeyHash,LongKeyEq> chunks; // 4J - was LongHashMap
|
std::unordered_map<__int64, PlayerChunk*, LongKeyHash, LongKeyEq>
|
||||||
|
chunks; // 4J - was LongHashMap
|
||||||
std::vector<PlayerChunk*> changedChunks;
|
std::vector<PlayerChunk*> changedChunks;
|
||||||
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
|
std::vector<PlayerChunkAddRequest> addRequests; // 4J added
|
||||||
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
|
void tickAddRequests(std::shared_ptr<ServerPlayer> player); // 4J added
|
||||||
|
|
@ -81,23 +83,30 @@ public:
|
||||||
ServerLevel* getLevel();
|
ServerLevel* getLevel();
|
||||||
void tick();
|
void tick();
|
||||||
bool hasChunk(int x, int z);
|
bool hasChunk(int x, int z);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PlayerChunk* getChunk(int x, int z, bool create);
|
PlayerChunk* getChunk(int x, int z, bool create);
|
||||||
void getChunkAndAddPlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
void getChunkAndAddPlayer(
|
||||||
void getChunkAndRemovePlayer(int x, int z, std::shared_ptr<ServerPlayer> player); // 4J added
|
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:
|
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);
|
void tileChanged(int x, int y, int z);
|
||||||
bool isTrackingTile(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 prioritiseTileChanges(int x, int y, int z); // 4J added
|
||||||
void add(std::shared_ptr<ServerPlayer> player);
|
void add(std::shared_ptr<ServerPlayer> player);
|
||||||
void remove(std::shared_ptr<ServerPlayer> player);
|
void remove(std::shared_ptr<ServerPlayer> player);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool chunkInRange(int x, int z, int xc, int zc);
|
bool chunkInRange(int x, int z, int xc, int zc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void move(std::shared_ptr<ServerPlayer> player);
|
void move(std::shared_ptr<ServerPlayer> player);
|
||||||
int getMaxRange();
|
int getMaxRange();
|
||||||
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk, int zChunk);
|
bool isPlayerIn(std::shared_ptr<ServerPlayer> player, int xChunk,
|
||||||
|
int zChunk);
|
||||||
static int convertChunkRangeToBlock(int radius);
|
static int convertChunkRangeToBlock(int radius);
|
||||||
|
|
||||||
// AP added for Vita
|
// AP added for Vita
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -8,10 +8,7 @@ class Connection;
|
||||||
class ServerPlayer;
|
class ServerPlayer;
|
||||||
class INetworkPlayer;
|
class INetworkPlayer;
|
||||||
|
|
||||||
|
class PlayerConnection : public PacketListener, public ConsoleInputSource {
|
||||||
|
|
||||||
class PlayerConnection : public PacketListener, public ConsoleInputSource
|
|
||||||
{
|
|
||||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -40,7 +37,8 @@ private:
|
||||||
bool m_bHasClientTickedOnce;
|
bool m_bHasClientTickedOnce;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayerConnection(MinecraftServer *server, Connection *connection, std::shared_ptr<ServerPlayer> player);
|
PlayerConnection(MinecraftServer* server, Connection* connection,
|
||||||
|
std::shared_ptr<ServerPlayer> player);
|
||||||
~PlayerConnection();
|
~PlayerConnection();
|
||||||
void tick();
|
void tick();
|
||||||
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
void disconnect(DisconnectPacket::eDisconnectReason reason);
|
||||||
|
|
@ -52,20 +50,26 @@ private:
|
||||||
public:
|
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);
|
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 handlePlayerAction(std::shared_ptr<PlayerActionPacket> packet);
|
||||||
virtual void handleUseItem(std::shared_ptr<UseItemPacket> 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);
|
virtual void onUnhandledPacket(std::shared_ptr<Packet> packet);
|
||||||
void send(std::shared_ptr<Packet> packet);
|
void send(std::shared_ptr<Packet> packet);
|
||||||
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
|
void queueSend(std::shared_ptr<Packet> packet); // 4J Added
|
||||||
virtual void handleSetCarriedItem(std::shared_ptr<SetCarriedItemPacket> packet);
|
virtual void handleSetCarriedItem(
|
||||||
|
std::shared_ptr<SetCarriedItemPacket> packet);
|
||||||
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
|
virtual void handleChat(std::shared_ptr<ChatPacket> packet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleCommand(const std::wstring& message);
|
void handleCommand(const std::wstring& message);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
virtual void handleAnimate(std::shared_ptr<AnimatePacket> packet);
|
||||||
virtual void handlePlayerCommand(std::shared_ptr<PlayerCommandPacket> packet);
|
virtual void handlePlayerCommand(
|
||||||
|
std::shared_ptr<PlayerCommandPacket> packet);
|
||||||
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
|
virtual void handleDisconnect(std::shared_ptr<DisconnectPacket> packet);
|
||||||
int countDelayedPackets();
|
int countDelayedPackets();
|
||||||
virtual void info(const std::wstring& string);
|
virtual void info(const std::wstring& string);
|
||||||
|
|
@ -73,9 +77,11 @@ public:
|
||||||
virtual std::wstring getConsoleName();
|
virtual std::wstring getConsoleName();
|
||||||
virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
|
virtual void handleInteract(std::shared_ptr<InteractPacket> packet);
|
||||||
bool canHandleAsyncPackets();
|
bool canHandleAsyncPackets();
|
||||||
virtual void handleClientCommand(std::shared_ptr<ClientCommandPacket> packet);
|
virtual void handleClientCommand(
|
||||||
|
std::shared_ptr<ClientCommandPacket> packet);
|
||||||
virtual void handleRespawn(std::shared_ptr<RespawnPacket> 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:
|
private:
|
||||||
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
|
std::unordered_map<int, short, IntKeyHash, IntKeyEq> expectedAcks;
|
||||||
|
|
@ -83,28 +89,39 @@ private:
|
||||||
public:
|
public:
|
||||||
// 4J Stu - Handlers only valid in debug mode
|
// 4J Stu - Handlers only valid in debug mode
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
virtual void handleContainerSetSlot(std::shared_ptr<ContainerSetSlotPacket> packet);
|
virtual void handleContainerSetSlot(
|
||||||
|
std::shared_ptr<ContainerSetSlotPacket> packet);
|
||||||
#endif
|
#endif
|
||||||
virtual void handleContainerClick(std::shared_ptr<ContainerClickPacket> packet);
|
virtual void handleContainerClick(
|
||||||
virtual void handleContainerButtonClick(std::shared_ptr<ContainerButtonClickPacket> packet);
|
std::shared_ptr<ContainerClickPacket> packet);
|
||||||
virtual void handleSetCreativeModeSlot(std::shared_ptr<SetCreativeModeSlotPacket> 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 handleContainerAck(std::shared_ptr<ContainerAckPacket> packet);
|
||||||
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
virtual void handleSignUpdate(std::shared_ptr<SignUpdatePacket> packet);
|
||||||
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
virtual void handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet);
|
||||||
virtual void handlePlayerInfo(std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
|
virtual void handlePlayerInfo(
|
||||||
|
std::shared_ptr<PlayerInfoPacket> packet); // 4J Added
|
||||||
virtual bool isServerPacketListener();
|
virtual bool isServerPacketListener();
|
||||||
virtual void handlePlayerAbilities(std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
virtual void handlePlayerAbilities(
|
||||||
virtual void handleCustomPayload(std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
std::shared_ptr<PlayerAbilitiesPacket> playerAbilitiesPacket);
|
||||||
|
virtual void handleCustomPayload(
|
||||||
|
std::shared_ptr<CustomPayloadPacket> customPayloadPacket);
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
|
virtual void handleCraftItem(std::shared_ptr<CraftItemPacket> packet);
|
||||||
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
|
virtual void handleTradeItem(std::shared_ptr<TradeItemPacket> packet);
|
||||||
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
|
virtual void handleDebugOptions(std::shared_ptr<DebugOptionsPacket> packet);
|
||||||
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
virtual void handleTexture(std::shared_ptr<TexturePacket> packet);
|
||||||
virtual void handleTextureAndGeometry(std::shared_ptr<TextureAndGeometryPacket> packet);
|
virtual void handleTextureAndGeometry(
|
||||||
virtual void handleTextureChange(std::shared_ptr<TextureChangePacket> packet);
|
std::shared_ptr<TextureAndGeometryPacket> packet);
|
||||||
virtual void handleTextureAndGeometryChange(std::shared_ptr<TextureAndGeometryChangePacket> packet);
|
virtual void handleTextureChange(
|
||||||
virtual void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
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 handleKickPlayer(std::shared_ptr<KickPlayerPacket> packet);
|
||||||
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
|
virtual void handleGameCommand(std::shared_ptr<GameCommandPacket> packet);
|
||||||
|
|
||||||
|
|
@ -113,13 +130,16 @@ public:
|
||||||
bool isGuest();
|
bool isGuest();
|
||||||
|
|
||||||
// 4J Added as we need to set this from outside sometimes
|
// 4J Added as we need to set this from outside sometimes
|
||||||
void setPlayer(std::shared_ptr<ServerPlayer> player) { this->player = player; }
|
void setPlayer(std::shared_ptr<ServerPlayer> player) {
|
||||||
|
this->player = player;
|
||||||
|
}
|
||||||
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
|
std::shared_ptr<ServerPlayer> getPlayer() { return player; }
|
||||||
|
|
||||||
// 4J Added to signal a disconnect from another thread
|
// 4J Added to signal a disconnect from another thread
|
||||||
void closeOnTick() { m_bCloseOnTick = true; }
|
void closeOnTick() { m_bCloseOnTick = true; }
|
||||||
|
|
||||||
// 4J Added so that we can send on textures that get received after this connection requested them
|
// 4J Added so that we can send on textures that get received after this
|
||||||
|
// connection requested them
|
||||||
void handleTextureReceived(const std::wstring& textureName);
|
void handleTextureReceived(const std::wstring& textureName);
|
||||||
void handleTextureAndGeometryReceived(const std::wstring& textureName);
|
void handleTextureAndGeometryReceived(const std::wstring& textureName);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
class PlayerInfo {
|
||||||
class PlayerInfo
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
std::wstring name;
|
std::wstring name;
|
||||||
int latency;
|
int latency;
|
||||||
|
|
||||||
PlayerInfo(const std::wstring &name)
|
PlayerInfo(const std::wstring& name) {
|
||||||
{
|
|
||||||
this->name = name;
|
this->name = name;
|
||||||
latency = 0;
|
latency = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -15,12 +15,10 @@ class ProgressListener;
|
||||||
class GameType;
|
class GameType;
|
||||||
class LoginPacket;
|
class LoginPacket;
|
||||||
|
|
||||||
|
class PlayerList {
|
||||||
|
|
||||||
class PlayerList
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int SEND_PLAYER_INFO_INTERVAL = 20 * 10; // 4J - brought forward from 1.2.3
|
static const int SEND_PLAYER_INFO_INTERVAL =
|
||||||
|
20 * 10; // 4J - brought forward from 1.2.3
|
||||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
public:
|
public:
|
||||||
std::vector<std::shared_ptr<ServerPlayer> > players;
|
std::vector<std::shared_ptr<ServerPlayer> > players;
|
||||||
|
|
@ -51,34 +49,51 @@ private:
|
||||||
|
|
||||||
int sendAllPlayerInfoIn;
|
int sendAllPlayerInfoIn;
|
||||||
|
|
||||||
// 4J Added to maintain which players in which dimensions can receive all packet types
|
// 4J Added to maintain which players in which dimensions can receive all
|
||||||
|
// packet types
|
||||||
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
|
std::vector<std::shared_ptr<ServerPlayer> > receiveAllPlayers[3];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(std::shared_ptr<ServerPlayer> currentPlayer);
|
std::shared_ptr<ServerPlayer> findAlivePlayerOnSystem(
|
||||||
|
std::shared_ptr<ServerPlayer> currentPlayer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player, bool usePlayerDimension = true, int dimension = 0);
|
void removePlayerFromReceiving(std::shared_ptr<ServerPlayer> player,
|
||||||
|
bool usePlayerDimension = true,
|
||||||
|
int dimension = 0);
|
||||||
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
|
void addPlayerToReceiving(std::shared_ptr<ServerPlayer> player);
|
||||||
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
|
bool canReceiveAllPackets(std::shared_ptr<ServerPlayer> player);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayerList(MinecraftServer* server);
|
PlayerList(MinecraftServer* server);
|
||||||
~PlayerList();
|
~PlayerList();
|
||||||
void placeNewPlayer(Connection *connection, std::shared_ptr<ServerPlayer> player, std::shared_ptr<LoginPacket> packet);
|
void placeNewPlayer(Connection* connection,
|
||||||
|
std::shared_ptr<ServerPlayer> player,
|
||||||
|
std::shared_ptr<LoginPacket> packet);
|
||||||
void setLevel(ServerLevelArray levels);
|
void setLevel(ServerLevelArray levels);
|
||||||
void changeDimension(std::shared_ptr<ServerPlayer> player, ServerLevel *from);
|
void changeDimension(std::shared_ptr<ServerPlayer> player,
|
||||||
|
ServerLevel* from);
|
||||||
int getMaxRange();
|
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:
|
protected:
|
||||||
void save(std::shared_ptr<ServerPlayer> player);
|
void save(std::shared_ptr<ServerPlayer> player);
|
||||||
|
|
||||||
public:
|
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 add(std::shared_ptr<ServerPlayer> player);
|
||||||
void move(std::shared_ptr<ServerPlayer> player);
|
void move(std::shared_ptr<ServerPlayer> player);
|
||||||
void remove(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> getPlayerForLogin(
|
||||||
std::shared_ptr<ServerPlayer> respawn(std::shared_ptr<ServerPlayer> serverPlayer, int targetDimension, bool keepAllPlayerData);
|
PendingConnection* pendingConnection, const std::wstring& userName,
|
||||||
void toggleDimension(std::shared_ptr<ServerPlayer> player, int targetDimension);
|
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();
|
void tick();
|
||||||
bool isTrackingTile(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 prioritiseTileChanges(int x, int y, int z, int dimension); // 4J added
|
||||||
|
|
@ -94,17 +109,22 @@ public:
|
||||||
std::shared_ptr<ServerPlayer> getPlayer(const std::wstring& name);
|
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 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(double x, double y, double z, double range, int dimension,
|
||||||
void broadcast(std::shared_ptr<Player> except, double x, double y, double z, double range, int dimension, std::shared_ptr<Packet> packet);
|
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);
|
void broadcastToAllOps(const std::wstring& message);
|
||||||
bool sendTo(const std::wstring& name, std::shared_ptr<Packet> packet);
|
bool sendTo(const std::wstring& name, std::shared_ptr<Packet> packet);
|
||||||
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps param
|
// 4J Added ProgressListener *progressListener param and bDeleteGuestMaps
|
||||||
void saveAll(ProgressListener *progressListener, bool bDeleteGuestMaps = false);
|
// param
|
||||||
|
void saveAll(ProgressListener* progressListener,
|
||||||
|
bool bDeleteGuestMaps = false);
|
||||||
void whiteList(const std::wstring& playerName);
|
void whiteList(const std::wstring& playerName);
|
||||||
void blackList(const std::wstring& playerName);
|
void blackList(const std::wstring& playerName);
|
||||||
// Set<String> getWhiteList(); / 4J removed
|
// Set<String> getWhiteList(); / 4J removed
|
||||||
void reloadWhitelist();
|
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);
|
void sendAllPlayerInfo(std::shared_ptr<ServerPlayer> player);
|
||||||
int getPlayerCount();
|
int getPlayerCount();
|
||||||
int getPlayerCount(ServerLevel* level); // 4J Added
|
int getPlayerCount(ServerLevel* level); // 4J Added
|
||||||
|
|
@ -114,7 +134,9 @@ public:
|
||||||
void setOverrideGameMode(GameType* gameMode);
|
void setOverrideGameMode(GameType* gameMode);
|
||||||
|
|
||||||
private:
|
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:
|
public:
|
||||||
void setAllowCheatsForAllPlayers(bool allowCommands);
|
void setAllowCheatsForAllPlayers(bool allowCommands);
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -8,17 +8,17 @@
|
||||||
|
|
||||||
class ServerLevel;
|
class ServerLevel;
|
||||||
|
|
||||||
class ServerChunkCache : public ChunkSource
|
class ServerChunkCache : public ChunkSource {
|
||||||
{
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
|
// std::unordered_set<int,IntKeyHash, IntKeyEq> toDrop;
|
||||||
private:
|
private:
|
||||||
LevelChunk* emptyChunk;
|
LevelChunk* emptyChunk;
|
||||||
ChunkSource* source;
|
ChunkSource* source;
|
||||||
ChunkStorage* storage;
|
ChunkStorage* storage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool autoCreate;
|
bool autoCreate;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LevelChunk** cache;
|
LevelChunk** cache;
|
||||||
std::vector<LevelChunk*> m_loadedChunkList;
|
std::vector<LevelChunk*> m_loadedChunkList;
|
||||||
|
|
@ -36,7 +36,8 @@ private:
|
||||||
int XZOFFSET;
|
int XZOFFSET;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source);
|
ServerChunkCache(ServerLevel* level, ChunkStorage* storage,
|
||||||
|
ChunkSource* source);
|
||||||
virtual ~ServerChunkCache();
|
virtual ~ServerChunkCache();
|
||||||
virtual bool hasChunk(int x, int z);
|
virtual bool hasChunk(int x, int z);
|
||||||
std::vector<LevelChunk*>* getLoadedChunkList();
|
std::vector<LevelChunk*>* getLoadedChunkList();
|
||||||
|
|
@ -60,18 +61,19 @@ private:
|
||||||
void saveEntities(LevelChunk* levelChunk);
|
void saveEntities(LevelChunk* levelChunk);
|
||||||
void save(LevelChunk* levelChunk);
|
void save(LevelChunk* levelChunk);
|
||||||
|
|
||||||
void updatePostProcessFlag(short flag, int x, int z, int xo, int zo, LevelChunk *lc); // 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 updatePostProcessFlags(int x, int z); // 4J added
|
||||||
void flagPostProcessComplete(short flag, int x, int z); // 4J added
|
void flagPostProcessComplete(short flag, int x, int z); // 4J added
|
||||||
public:
|
public:
|
||||||
virtual void postProcess(ChunkSource* parent, int x, int z);
|
virtual void postProcess(ChunkSource* parent, int x, int z);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef _LARGE_WORLDS
|
#ifdef _LARGE_WORLDS
|
||||||
static const int MAX_SAVES = 20;
|
static const int MAX_SAVES = 20;
|
||||||
#else
|
#else
|
||||||
// 4J Stu - Was 24, but lowering it drastically so that we can trickle save chunks
|
// 4J Stu - Was 24, but lowering it drastically so that we can trickle save
|
||||||
|
// chunks
|
||||||
static const int MAX_SAVES = 1;
|
static const int MAX_SAVES = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -82,18 +84,21 @@ public:
|
||||||
virtual bool shouldSave();
|
virtual bool shouldSave();
|
||||||
virtual std::wstring gatherStats();
|
virtual std::wstring gatherStats();
|
||||||
|
|
||||||
virtual std::vector<Biome::MobSpawnerData *> *getMobsAt(MobCategory *mobCategory, int x, int y, int z);
|
virtual std::vector<Biome::MobSpawnerData*>* getMobsAt(
|
||||||
virtual TilePos *findNearestMapFeature(Level *level, const std::wstring &featureName, int x, int y, int z);
|
MobCategory* mobCategory, int x, int y, int z);
|
||||||
|
virtual TilePos* findNearestMapFeature(Level* level,
|
||||||
|
const std::wstring& featureName,
|
||||||
|
int x, int y, int z);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef struct _SaveThreadData
|
typedef struct _SaveThreadData {
|
||||||
{
|
|
||||||
ServerChunkCache* cache;
|
ServerChunkCache* cache;
|
||||||
LevelChunk* chunkToSave;
|
LevelChunk* chunkToSave;
|
||||||
bool saveEntities;
|
bool saveEntities;
|
||||||
bool useSharedThreadStorage;
|
bool useSharedThreadStorage;
|
||||||
C4JThread::Event* notificationEvent;
|
C4JThread::Event* notificationEvent;
|
||||||
C4JThread::Event *wakeEvent; // This is a handle to the one fired by the producer thread
|
C4JThread::Event* wakeEvent; // This is a handle to the one fired by
|
||||||
|
// the producer thread
|
||||||
} SaveThreadData;
|
} SaveThreadData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,7 @@
|
||||||
#include "../Commands/TeleportCommand.h"
|
#include "../Commands/TeleportCommand.h"
|
||||||
#include "ServerCommandDispatcher.h"
|
#include "ServerCommandDispatcher.h"
|
||||||
|
|
||||||
ServerCommandDispatcher::ServerCommandDispatcher()
|
ServerCommandDispatcher::ServerCommandDispatcher() {
|
||||||
{
|
|
||||||
addCommand(new TimeCommand());
|
addCommand(new TimeCommand());
|
||||||
addCommand(new GameModeCommand());
|
addCommand(new GameModeCommand());
|
||||||
addCommand(new DefaultGameModeCommand());
|
addCommand(new DefaultGameModeCommand());
|
||||||
|
|
@ -52,24 +51,28 @@ ServerCommandDispatcher::ServerCommandDispatcher()
|
||||||
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)
|
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();
|
PlayerList* playerList = MinecraftServer::getInstance()->getPlayers();
|
||||||
// for (Player player : MinecraftServer.getInstance().getPlayers().players)
|
// for (Player player : MinecraftServer.getInstance().getPlayers().players)
|
||||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
for (AUTO_VAR(it, playerList->players.begin());
|
||||||
{
|
it != playerList->players.end(); ++it) {
|
||||||
std::shared_ptr<ServerPlayer> player = *it;
|
std::shared_ptr<ServerPlayer> player = *it;
|
||||||
if (player != source && playerList->isOp(player))
|
if (player != source && playerList->isOp(player)) {
|
||||||
{
|
|
||||||
// TODO: Change chat packet to be able to send more bits of data
|
// 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?
|
// 4J Stu - Take this out until we can add the name of the player
|
||||||
//player->sendMessage(message, messageType, customData, additionalMessage);
|
// performing the action. Also if the target is a mod then maybe
|
||||||
//player->sendMessage("\u00A77\u00A7o[" + source.getName() + ": " + player.localize(message, args) + "]");
|
// 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)
|
if ((type & LOGTYPE_DONT_SHOW_TO_SELF) != LOGTYPE_DONT_SHOW_TO_SELF) {
|
||||||
{
|
source->sendMessage(message, messageType, customData,
|
||||||
source->sendMessage(message, messageType, customData, additionalMessage);
|
additionalMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,9 +3,12 @@
|
||||||
#include "../../Minecraft.World/Commands/CommandDispatcher.h"
|
#include "../../Minecraft.World/Commands/CommandDispatcher.h"
|
||||||
#include "../../Minecraft.World/Commands/AdminLogCommand.h"
|
#include "../../Minecraft.World/Commands/AdminLogCommand.h"
|
||||||
|
|
||||||
class ServerCommandDispatcher : public CommandDispatcher, public AdminLogCommand
|
class ServerCommandDispatcher : public CommandDispatcher,
|
||||||
{
|
public AdminLogCommand {
|
||||||
public:
|
public:
|
||||||
ServerCommandDispatcher();
|
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"");
|
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"");
|
||||||
};
|
};
|
||||||
|
|
@ -9,8 +9,7 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.level.h"
|
||||||
#include "../Level/MultiPlayerLevel.h"
|
#include "../Level/MultiPlayerLevel.h"
|
||||||
|
|
||||||
ServerConnection::ServerConnection(MinecraftServer *server)
|
ServerConnection::ServerConnection(MinecraftServer* server) {
|
||||||
{
|
|
||||||
// 4J - added initialiser
|
// 4J - added initialiser
|
||||||
connectionCounter = 0;
|
connectionCounter = 0;
|
||||||
InitializeCriticalSection(&pending_cs);
|
InitializeCriticalSection(&pending_cs);
|
||||||
|
|
@ -18,63 +17,59 @@ ServerConnection::ServerConnection(MinecraftServer *server)
|
||||||
this->server = server;
|
this->server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerConnection::~ServerConnection()
|
ServerConnection::~ServerConnection() { DeleteCriticalSection(&pending_cs); }
|
||||||
{
|
|
||||||
DeleteCriticalSection(&pending_cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4J - added to handle incoming connections, to replace thread that original used to have
|
// 4J - added to handle incoming connections, to replace thread that original
|
||||||
void ServerConnection::NewIncomingSocket(Socket *socket)
|
// 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++)));
|
std::shared_ptr<PendingConnection> unconnectedClient =
|
||||||
|
std::shared_ptr<PendingConnection>(new PendingConnection(
|
||||||
|
server, socket,
|
||||||
|
L"Connection #" + _toString<int>(connectionCounter++)));
|
||||||
handleConnection(unconnectedClient);
|
handleConnection(unconnectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::addPlayerConnection(std::shared_ptr<PlayerConnection> uc)
|
void ServerConnection::addPlayerConnection(
|
||||||
{
|
std::shared_ptr<PlayerConnection> uc) {
|
||||||
players.push_back(uc);
|
players.push_back(uc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc)
|
void ServerConnection::handleConnection(std::shared_ptr<PendingConnection> uc) {
|
||||||
{
|
|
||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
pending.push_back(uc);
|
pending.push_back(uc);
|
||||||
LeaveCriticalSection(&pending_cs);
|
LeaveCriticalSection(&pending_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::stop()
|
void ServerConnection::stop() {
|
||||||
{
|
|
||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
for (unsigned int i = 0; i < pending.size(); i++)
|
for (unsigned int i = 0; i < pending.size(); i++) {
|
||||||
{
|
|
||||||
std::shared_ptr<PendingConnection> uc = pending[i];
|
std::shared_ptr<PendingConnection> uc = pending[i];
|
||||||
uc->connection->close(DisconnectPacket::eDisconnect_Closed);
|
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];
|
std::shared_ptr<PlayerConnection> player = players[i];
|
||||||
player->connection->close(DisconnectPacket::eDisconnect_Closed);
|
player->connection->close(DisconnectPacket::eDisconnect_Closed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::tick()
|
void ServerConnection::tick() {
|
||||||
{
|
{
|
||||||
{
|
// MGH - changed this so that the the CS lock doesn't cover the 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)
|
// (was causing a lockup when 2 players tried to join)
|
||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
std::vector<std::shared_ptr<PendingConnection> > tempPending = pending;
|
std::vector<std::shared_ptr<PendingConnection> > tempPending = pending;
|
||||||
LeaveCriticalSection(&pending_cs);
|
LeaveCriticalSection(&pending_cs);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < tempPending.size(); i++)
|
for (unsigned int i = 0; i < tempPending.size(); i++) {
|
||||||
{
|
|
||||||
std::shared_ptr<PendingConnection> uc = tempPending[i];
|
std::shared_ptr<PendingConnection> uc = tempPending[i];
|
||||||
// try { // 4J - removed try/catch
|
// try { // 4J - removed try/catch
|
||||||
uc->tick();
|
uc->tick();
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// uc.disconnect("Internal server error");
|
// uc.disconnect("Internal server error");
|
||||||
// logger.log(Level.WARNING, "Failed to handle packet: " + e, e);
|
// logger.log(Level.WARNING, "Failed to handle packet: "
|
||||||
|
// + e, e);
|
||||||
// }
|
// }
|
||||||
if (uc->connection != NULL) uc->connection->flush();
|
if (uc->connection != NULL) uc->connection->flush();
|
||||||
}
|
}
|
||||||
|
|
@ -83,102 +78,97 @@ void ServerConnection::tick()
|
||||||
// now remove from the pending list
|
// now remove from the pending list
|
||||||
EnterCriticalSection(&pending_cs);
|
EnterCriticalSection(&pending_cs);
|
||||||
for (unsigned int i = 0; i < pending.size(); i++)
|
for (unsigned int i = 0; i < pending.size(); i++)
|
||||||
if (pending[i]->done)
|
if (pending[i]->done) {
|
||||||
{
|
|
||||||
pending.erase(pending.begin() + i);
|
pending.erase(pending.begin() + i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
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];
|
std::shared_ptr<PlayerConnection> player = players[i];
|
||||||
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
|
std::shared_ptr<ServerPlayer> serverPlayer = player->getPlayer();
|
||||||
if( serverPlayer )
|
if (serverPlayer) {
|
||||||
{
|
|
||||||
serverPlayer->doChunkSendingTick(false);
|
serverPlayer->doChunkSendingTick(false);
|
||||||
}
|
}
|
||||||
// try { // 4J - removed try/catch
|
// try { // 4J - removed try/catch
|
||||||
player->tick();
|
player->tick();
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// logger.log(Level.WARNING, "Failed to handle packet: " + e, e);
|
// logger.log(Level.WARNING, "Failed to handle packet: " + e,
|
||||||
// player.disconnect("Internal server error");
|
// e); player.disconnect("Internal server error");
|
||||||
// }
|
// }
|
||||||
if (player->done)
|
if (player->done) {
|
||||||
{
|
|
||||||
players.erase(players.begin() + i);
|
players.erase(players.begin() + i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
player->connection->flush();
|
player->connection->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerConnection::addPendingTextureRequest(const std::wstring &textureName)
|
bool ServerConnection::addPendingTextureRequest(
|
||||||
{
|
const std::wstring& textureName) {
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
|
||||||
if( it == m_pendingTextureRequests.end() )
|
m_pendingTextureRequests.end(), textureName));
|
||||||
{
|
if (it == m_pendingTextureRequests.end()) {
|
||||||
m_pendingTextureRequests.push_back(textureName);
|
m_pendingTextureRequests.push_back(textureName);
|
||||||
return true;
|
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
|
// 4J Stu - We want to request this texture from everyone, if we have a
|
||||||
// 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
|
// duplicate it's most likely because the first person we asked for it
|
||||||
// a few more responses if people join with the same skin in a short space of time
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleTextureReceived(const std::wstring &textureName)
|
void ServerConnection::handleTextureReceived(const std::wstring& textureName) {
|
||||||
{
|
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
m_pendingTextureRequests.end(), textureName));
|
||||||
if( it != m_pendingTextureRequests.end() )
|
if (it != m_pendingTextureRequests.end()) {
|
||||||
{
|
|
||||||
m_pendingTextureRequests.erase(it);
|
m_pendingTextureRequests.erase(it);
|
||||||
}
|
}
|
||||||
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<PlayerConnection> player = players[i];
|
||||||
if (!player->done)
|
if (!player->done) {
|
||||||
{
|
|
||||||
player->handleTextureReceived(textureName);
|
player->handleTextureReceived(textureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleTextureAndGeometryReceived(const std::wstring &textureName)
|
void ServerConnection::handleTextureAndGeometryReceived(
|
||||||
{
|
const std::wstring& textureName) {
|
||||||
AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
|
AUTO_VAR(it, find(m_pendingTextureRequests.begin(),
|
||||||
if( it != m_pendingTextureRequests.end() )
|
m_pendingTextureRequests.end(), textureName));
|
||||||
{
|
if (it != m_pendingTextureRequests.end()) {
|
||||||
m_pendingTextureRequests.erase(it);
|
m_pendingTextureRequests.erase(it);
|
||||||
}
|
}
|
||||||
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<PlayerConnection> player = players[i];
|
||||||
if (!player->done)
|
if (!player->done) {
|
||||||
{
|
|
||||||
player->handleTextureAndGeometryReceived(textureName);
|
player->handleTextureAndGeometryReceived(textureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet)
|
void ServerConnection::handleServerSettingsChanged(
|
||||||
{
|
std::shared_ptr<ServerSettingsChangedPacket> packet) {
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
if(packet->action==ServerSettingsChangedPacket::HOST_DIFFICULTY)
|
if (packet->action == ServerSettingsChangedPacket::HOST_DIFFICULTY) {
|
||||||
{
|
for (unsigned int i = 0; i < pMinecraft->levels.length; ++i) {
|
||||||
for(unsigned int i = 0; i < pMinecraft->levels.length; ++i)
|
if (pMinecraft->levels[i] != NULL) {
|
||||||
{
|
app.DebugPrintf(
|
||||||
if( pMinecraft->levels[i] != NULL )
|
"ClientConnection::handleServerSettingsChanged - "
|
||||||
{
|
"Difficulty = %d",
|
||||||
app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data);
|
packet->data);
|
||||||
pMinecraft->levels[i]->difficulty = packet->data;
|
pMinecraft->levels[i]->difficulty = packet->data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)// options
|
// else
|
||||||
|
// if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)//
|
||||||
|
// options
|
||||||
// {
|
// {
|
||||||
// app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings)
|
// app.SetGameHostOption(eGameHostOption_All,packet->m_serverSettings)
|
||||||
// }
|
// }
|
||||||
|
|
@ -197,7 +187,8 @@ void ServerConnection::handleServerSettingsChanged(std::shared_ptr<ServerSetting
|
||||||
//
|
//
|
||||||
// for (unsigned int i = 0; i < players.size(); i++)
|
// for (unsigned int i = 0; i < players.size(); i++)
|
||||||
// {
|
// {
|
||||||
// std::shared_ptr<PlayerConnection> playerconnection = players[i];
|
// std::shared_ptr<PlayerConnection> playerconnection =
|
||||||
|
// players[i];
|
||||||
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
|
// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,7 @@ class MinecraftServer;
|
||||||
class Socket;
|
class Socket;
|
||||||
class ServerSettingsChangedPacket;
|
class ServerSettingsChangedPacket;
|
||||||
|
|
||||||
|
class ServerConnection {
|
||||||
|
|
||||||
class ServerConnection
|
|
||||||
{
|
|
||||||
// public static Logger logger = Logger.getLogger("Minecraft");
|
// public static Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -16,27 +13,36 @@ private:
|
||||||
// private Thread listenThread;
|
// private Thread listenThread;
|
||||||
public:
|
public:
|
||||||
volatile bool running;
|
volatile bool running;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int connectionCounter;
|
int connectionCounter;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CRITICAL_SECTION pending_cs; // 4J added
|
CRITICAL_SECTION pending_cs; // 4J added
|
||||||
std::vector<std::shared_ptr<PendingConnection> > pending;
|
std::vector<std::shared_ptr<PendingConnection> > pending;
|
||||||
std::vector<std::shared_ptr<PlayerConnection> > players;
|
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
|
// 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;
|
std::vector<std::wstring> m_pendingTextureRequests;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MinecraftServer* server;
|
MinecraftServer* server;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerConnection(MinecraftServer *server); // 4J - removed params InetAddress address, int port);
|
ServerConnection(
|
||||||
|
MinecraftServer*
|
||||||
|
server); // 4J - removed params InetAddress address, int port);
|
||||||
~ServerConnection();
|
~ServerConnection();
|
||||||
void NewIncomingSocket(Socket* socket); // 4J - added
|
void NewIncomingSocket(Socket* socket); // 4J - added
|
||||||
|
|
||||||
void removeSpamProtection(Socket *socket) { }// 4J Stu - Not implemented as not required
|
void removeSpamProtection(Socket* socket) {
|
||||||
|
} // 4J Stu - Not implemented as not required
|
||||||
void addPlayerConnection(std::shared_ptr<PlayerConnection> uc);
|
void addPlayerConnection(std::shared_ptr<PlayerConnection> uc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleConnection(std::shared_ptr<PendingConnection> uc);
|
void handleConnection(std::shared_ptr<PendingConnection> uc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void stop();
|
void stop();
|
||||||
void tick();
|
void tick();
|
||||||
|
|
@ -45,5 +51,6 @@ public:
|
||||||
bool addPendingTextureRequest(const std::wstring& textureName);
|
bool addPendingTextureRequest(const std::wstring& textureName);
|
||||||
void handleTextureReceived(const std::wstring& textureName);
|
void handleTextureReceived(const std::wstring& textureName);
|
||||||
void handleTextureAndGeometryReceived(const std::wstring& textureName);
|
void handleTextureAndGeometryReceived(const std::wstring& textureName);
|
||||||
void handleServerSettingsChanged(std::shared_ptr<ServerSettingsChangedPacket> packet);
|
void handleServerSettingsChanged(
|
||||||
|
std::shared_ptr<ServerSettingsChangedPacket> packet);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
class ServerInterface {
|
||||||
class ServerInterface
|
|
||||||
{
|
|
||||||
virtual int getConfigInt(const std::wstring& name, int defaultValue) = 0;
|
virtual int getConfigInt(const std::wstring& name, int defaultValue) = 0;
|
||||||
virtual std::wstring getConfigString(const std::wstring &name, const std::wstring &defaultValue) = 0;
|
virtual std::wstring getConfigString(const std::wstring& name,
|
||||||
virtual bool getConfigBoolean(const std::wstring &name, bool defaultValue) = 0;
|
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 setProperty(std::wstring& propertyName, void* value) = 0;
|
||||||
virtual void configSave() = 0;
|
virtual void configSave() = 0;
|
||||||
virtual std::wstring getConfigPath() = 0;
|
virtual std::wstring getConfigPath() = 0;
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,12 @@
|
||||||
|
|
||||||
// Iggy GDraw support functions - normally in the Iggy library, stubbed here
|
// Iggy GDraw support functions - normally in the Iggy library, stubbed here
|
||||||
void* IggyGDrawMallocAnnotated(SINTa size, const char* file, int line) {
|
void* IggyGDrawMallocAnnotated(SINTa size, const char* file, int line) {
|
||||||
(void)file; (void)line;
|
(void)file;
|
||||||
|
(void)line;
|
||||||
return malloc((size_t)size);
|
return malloc((size_t)size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IggyGDrawFree(void *ptr) {
|
void IggyGDrawFree(void* ptr) { free(ptr); }
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void IggyGDrawSendWarning(Iggy* f, char const* message, ...) {
|
void IggyGDrawSendWarning(Iggy* f, char const* message, ...) {
|
||||||
(void)f;
|
(void)f;
|
||||||
|
|
@ -42,7 +41,8 @@ void IggyGDrawSendWarning(Iggy *f, char const *message, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void IggyDiscardVertexBufferCallback(void* owner, void* buf) {
|
void IggyDiscardVertexBufferCallback(void* owner, void* buf) {
|
||||||
(void)owner; (void)buf;
|
(void)owner;
|
||||||
|
(void)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -65,8 +65,10 @@ GLE(BufferData, "BufferDataARB", BUFFERDA
|
||||||
GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \
|
GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \
|
||||||
GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \
|
GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \
|
||||||
GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \
|
GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \
|
||||||
GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", ENABLEVERTEXATTRIBARRAYARB) \
|
GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", \
|
||||||
GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", DISABLEVERTEXATTRIBARRAYARB) \
|
ENABLEVERTEXATTRIBARRAYARB) \
|
||||||
|
GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", \
|
||||||
|
DISABLEVERTEXATTRIBARRAYARB) \
|
||||||
/* GL_ARB_shader_objects */ \
|
/* GL_ARB_shader_objects */ \
|
||||||
GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \
|
GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \
|
||||||
GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \
|
GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \
|
||||||
|
|
@ -97,14 +99,18 @@ GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBU
|
||||||
GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \
|
GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \
|
||||||
GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \
|
GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \
|
||||||
GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \
|
GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \
|
||||||
GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", CHECKFRAMEBUFFERSTATUSEXT) \
|
GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", \
|
||||||
GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", FRAMEBUFFERRENDERBUFFEREXT) \
|
CHECKFRAMEBUFFERSTATUSEXT) \
|
||||||
GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", FRAMEBUFFERTEXTURE2DEXT) \
|
GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", \
|
||||||
|
FRAMEBUFFERRENDERBUFFEREXT) \
|
||||||
|
GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", \
|
||||||
|
FRAMEBUFFERTEXTURE2DEXT) \
|
||||||
GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \
|
GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \
|
||||||
/* GL_EXT_framebuffer_blit */ \
|
/* GL_EXT_framebuffer_blit */ \
|
||||||
GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \
|
GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \
|
||||||
/* GL_EXT_framebuffer_multisample */ \
|
/* GL_EXT_framebuffer_multisample */ \
|
||||||
GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT",RENDERBUFFERSTORAGEMULTISAMPLEEXT) \
|
GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT", \
|
||||||
|
RENDERBUFFERSTORAGEMULTISAMPLEEXT) \
|
||||||
/* <end> */
|
/* <end> */
|
||||||
|
|
||||||
#define gdraw_GLx_(id) gdraw_GL_##id
|
#define gdraw_GLx_(id) gdraw_GL_##id
|
||||||
|
|
@ -123,20 +129,18 @@ typedef gdraw_gl_resourcetype gdraw_resourcetype;
|
||||||
GDRAW_GL_EXTENSION_LIST
|
GDRAW_GL_EXTENSION_LIST
|
||||||
#undef GLE
|
#undef GLE
|
||||||
|
|
||||||
static void load_extensions(void)
|
static void load_extensions(void) {
|
||||||
{
|
#define GLE(id, import, procname) \
|
||||||
#define GLE(id, import, procname) gl##id = (PFNGL##procname##PROC) SDL_GL_GetProcAddress("gl" import);
|
gl##id = (PFNGL##procname##PROC)SDL_GL_GetProcAddress("gl" import);
|
||||||
GDRAW_GL_EXTENSION_LIST
|
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);
|
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);
|
fprintf(stderr, "[GDraw GL] %s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,7 +155,10 @@ static void error_msg_platform_specific(const char *msg)
|
||||||
#ifdef RR_BREAK
|
#ifdef RR_BREAK
|
||||||
#undef RR_BREAK
|
#undef RR_BREAK
|
||||||
#endif
|
#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"
|
#include "../../../Windows64/Iggy/gdraw/gdraw_gl_shared.inl"
|
||||||
|
|
||||||
|
|
@ -160,21 +167,29 @@ static void error_msg_platform_specific(const char *msg)
|
||||||
// Initialization and platform-specific functionality
|
// 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[] = {
|
static const TextureFormatDesc tex_formats[] = {
|
||||||
{IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
|
{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_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA,
|
||||||
{ IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 },
|
GL_UNSIGNED_SHORT_4_4_4_4},
|
||||||
{ IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
|
{IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA,
|
||||||
{ IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
|
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_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_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_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE,
|
||||||
{ IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE },
|
GL_UNSIGNED_BYTE},
|
||||||
{ IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0, GL_UNSIGNED_BYTE },
|
{IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE,
|
||||||
{ IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0, GL_UNSIGNED_BYTE },
|
GL_UNSIGNED_BYTE},
|
||||||
{ IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0, 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},
|
{0, 0, 0, 0, 0, 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -185,7 +200,9 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
|
||||||
// check for the extensions we need
|
// check for the extensions we need
|
||||||
s = (const char*)glGetString(GL_EXTENSIONS);
|
s = (const char*)glGetString(GL_EXTENSIONS);
|
||||||
if (s == NULL) {
|
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);
|
assert(s != NULL);
|
||||||
return 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_EXT_framebuffer_object") ||
|
||||||
!hasext(s, "GL_ARB_shader_objects") ||
|
!hasext(s, "GL_ARB_shader_objects") ||
|
||||||
!hasext(s, "GL_ARB_vertex_shader") ||
|
!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");
|
fprintf(stderr, "[GDraw GL] Required GL extensions not available\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -211,8 +227,7 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
|
||||||
|
|
||||||
load_extensions();
|
load_extensions();
|
||||||
funcs = create_context(w, h);
|
funcs = create_context(w, h);
|
||||||
if (!funcs)
|
if (!funcs) return NULL;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
gdraw->tex_formats = tex_formats;
|
gdraw->tex_formats = tex_formats;
|
||||||
|
|
||||||
|
|
@ -221,7 +236,8 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
|
||||||
gdraw->has_depth24 = true; // we just assume.
|
gdraw->has_depth24 = true; // we just assume.
|
||||||
gdraw->has_texture_max_level = true; // core on regular GL
|
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);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &n);
|
||||||
gdraw->has_conditional_non_power_of_two = n < 8192;
|
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();
|
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;
|
return funcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,14 +261,15 @@ GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples)
|
||||||
// 4J-specific custom draw functions
|
// 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
|
// Same as BeginCustomDraw but uses different depth param
|
||||||
clear_renderstate();
|
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);
|
gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum gdraw_gl_resourcetype
|
typedef enum gdraw_gl_resourcetype {
|
||||||
{
|
|
||||||
GDRAW_GL_RESOURCE_rendertarget,
|
GDRAW_GL_RESOURCE_rendertarget,
|
||||||
GDRAW_GL_RESOURCE_texture,
|
GDRAW_GL_RESOURCE_texture,
|
||||||
GDRAW_GL_RESOURCE_vertexbuffer,
|
GDRAW_GL_RESOURCE_vertexbuffer,
|
||||||
|
|
@ -19,23 +18,38 @@ typedef enum gdraw_gl_resourcetype
|
||||||
|
|
||||||
struct IggyCustomDrawCallbackRegion;
|
struct IggyCustomDrawCallbackRegion;
|
||||||
|
|
||||||
extern int gdraw_GL_SetResourceLimits(gdraw_gl_resourcetype type, S32 num_handles, S32 num_bytes);
|
extern int gdraw_GL_SetResourceLimits(gdraw_gl_resourcetype type,
|
||||||
extern GDrawFunctions * gdraw_GL_CreateContext(S32 min_w, S32 min_h, S32 msaa_samples);
|
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_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 void gdraw_GL_NoMoreGDrawThisFrame(void);
|
||||||
|
|
||||||
extern GDrawTexture *gdraw_GL_WrappedTextureCreate(S32 gl_texture_handle, S32 width, S32 height, int has_mipmaps);
|
extern GDrawTexture* gdraw_GL_WrappedTextureCreate(S32 gl_texture_handle,
|
||||||
extern void gdraw_GL_WrappedTextureChange(GDrawTexture *tex, S32 new_gl_texture_handle, S32 new_width, S32 new_height, int new_has_mipmaps);
|
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_WrappedTextureDestroy(GDrawTexture* tex);
|
||||||
|
|
||||||
extern void gdraw_GL_BeginCustomDraw(struct IggyCustomDrawCallbackRegion *region, float *matrix);
|
extern void gdraw_GL_BeginCustomDraw(
|
||||||
|
struct IggyCustomDrawCallbackRegion* region, float* matrix);
|
||||||
extern void gdraw_GL_EndCustomDraw(struct IggyCustomDrawCallbackRegion* region);
|
extern void gdraw_GL_EndCustomDraw(struct IggyCustomDrawCallbackRegion* region);
|
||||||
|
|
||||||
extern void gdraw_GL_CalculateCustomDraw_4J(struct IggyCustomDrawCallbackRegion *region, float *matrix);
|
extern void gdraw_GL_CalculateCustomDraw_4J(
|
||||||
extern void gdraw_GL_BeginCustomDraw_4J(struct IggyCustomDrawCallbackRegion *region, float *matrix);
|
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 GDrawTexture* gdraw_GL_MakeTextureFromResource(
|
||||||
|
unsigned char* resource_file, S32 resource_len,
|
||||||
|
IggyFileTextureRaw* texture);
|
||||||
extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture* tex);
|
extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture* tex);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,6 @@
|
||||||
|
|
||||||
#include "LinuxLeaderboardManager.h"
|
#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
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
#include "../../Common/Leaderboards/LeaderboardManager.h"
|
#include "../../Common/Leaderboards/LeaderboardManager.h"
|
||||||
|
|
||||||
class LinuxLeaderboardManager : public LeaderboardManager
|
class LinuxLeaderboardManager : public LeaderboardManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual void Tick() {}
|
virtual void Tick() {}
|
||||||
|
|
||||||
|
|
@ -17,13 +16,29 @@ public:
|
||||||
virtual void DeleteSession() {}
|
virtual void DeleteSession() {}
|
||||||
|
|
||||||
// Write the given stats
|
// Write the given stats
|
||||||
//This is called synchronously and will not free any memory allocated for views when it is done
|
// 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_Friends(LeaderboardReadListener* callback,
|
||||||
virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount) { return false; }
|
int difficulty, EStatsType type,
|
||||||
virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount) { return false; }
|
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
|
// Perform a flush of the stats
|
||||||
virtual void FlushStats() {}
|
virtual void FlushStats() {}
|
||||||
|
|
|
||||||
|
|
@ -9,94 +9,79 @@
|
||||||
#include "../../Minecraft.World/IO/Streams/FloatBuffer.h"
|
#include "../../Minecraft.World/IO/Streams/FloatBuffer.h"
|
||||||
#include "../../Minecraft.World/IO/Streams/ByteBuffer.h"
|
#include "../../Minecraft.World/IO/Streams/ByteBuffer.h"
|
||||||
|
|
||||||
|
int glGenTextures() {
|
||||||
int glGenTextures()
|
|
||||||
{
|
|
||||||
GLuint id = 0;
|
GLuint id = 0;
|
||||||
::glGenTextures(1, &id);
|
::glGenTextures(1, &id);
|
||||||
return (int)id;
|
return (int)id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void glGenTextures(IntBuffer *buf)
|
void glGenTextures(IntBuffer* buf) {
|
||||||
{
|
|
||||||
GLuint id = 0;
|
GLuint id = 0;
|
||||||
::glGenTextures(1, &id);
|
::glGenTextures(1, &id);
|
||||||
buf->put((int)id);
|
buf->put((int)id);
|
||||||
buf->flip();
|
buf->flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glDeleteTextures(int id)
|
void glDeleteTextures(int id) {
|
||||||
{
|
|
||||||
GLuint uid = (GLuint)id;
|
GLuint uid = (GLuint)id;
|
||||||
::glDeleteTextures(1, &uid);
|
::glDeleteTextures(1, &uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glDeleteTextures(IntBuffer *buf)
|
void glDeleteTextures(IntBuffer* buf) {
|
||||||
{
|
|
||||||
int id = buf->get(0);
|
int id = buf->get(0);
|
||||||
GLuint uid = (GLuint)id;
|
GLuint uid = (GLuint)id;
|
||||||
::glDeleteTextures(1, &uid);
|
::glDeleteTextures(1, &uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glLight(int light, int pname, FloatBuffer *params)
|
void glLight(int light, int pname, FloatBuffer* params) {
|
||||||
{
|
|
||||||
::glLightfv((GLenum)light, (GLenum)pname, params->_getDataPointer());
|
::glLightfv((GLenum)light, (GLenum)pname, params->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glLightModel(int pname, FloatBuffer *params)
|
void glLightModel(int pname, FloatBuffer* params) {
|
||||||
{
|
|
||||||
::glLightModelfv((GLenum)pname, params->_getDataPointer());
|
::glLightModelfv((GLenum)pname, params->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glGetFloat(int pname, FloatBuffer *params)
|
void glGetFloat(int pname, FloatBuffer* params) {
|
||||||
{
|
|
||||||
::glGetFloatv((GLenum)pname, params->_getDataPointer());
|
::glGetFloatv((GLenum)pname, params->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glTexGen(int coord, int pname, FloatBuffer *params)
|
void glTexGen(int coord, int pname, FloatBuffer* params) {
|
||||||
{
|
|
||||||
::glTexGenfv((GLenum)coord, (GLenum)pname, params->_getDataPointer());
|
::glTexGenfv((GLenum)coord, (GLenum)pname, params->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glFog(int pname, FloatBuffer *params)
|
void glFog(int pname, FloatBuffer* params) {
|
||||||
{
|
|
||||||
::glFogfv((GLenum)pname, params->_getDataPointer());
|
::glFogfv((GLenum)pname, params->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glTexCoordPointer(int size, int type, FloatBuffer *pointer)
|
void glTexCoordPointer(int size, int type, FloatBuffer* pointer) {
|
||||||
{
|
|
||||||
::glTexCoordPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
|
::glTexCoordPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glNormalPointer(int type, ByteBuffer *pointer)
|
void glNormalPointer(int type, ByteBuffer* pointer) {
|
||||||
{
|
|
||||||
::glNormalPointer((GLenum)type, 0, pointer->getBuffer());
|
::glNormalPointer((GLenum)type, 0, pointer->getBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glColorPointer(int size, bool normalized, int stride, ByteBuffer *pointer)
|
void glColorPointer(int size, bool normalized, int stride,
|
||||||
{
|
ByteBuffer* pointer) {
|
||||||
(void)normalized;
|
(void)normalized;
|
||||||
::glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer->getBuffer());
|
::glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer->getBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glVertexPointer(int size, int type, FloatBuffer *pointer)
|
void glVertexPointer(int size, int type, FloatBuffer* pointer) {
|
||||||
{
|
|
||||||
::glVertexPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
|
::glVertexPointer(size, (GLenum)type, 0, pointer->_getDataPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void glEndList(int)
|
void glEndList(int) { ::glEndList(); }
|
||||||
{
|
|
||||||
::glEndList();
|
|
||||||
}
|
|
||||||
|
|
||||||
void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer *pixels)
|
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;
|
void* data = pixels ? pixels->getBuffer() : nullptr;
|
||||||
::glTexImage2D((GLenum)target, level, internalformat, width, height, border, (GLenum)format, (GLenum)type, data);
|
::glTexImage2D((GLenum)target, level, internalformat, width, height, border,
|
||||||
|
(GLenum)format, (GLenum)type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glCallLists(IntBuffer *lists)
|
void glCallLists(IntBuffer* lists) {
|
||||||
{
|
|
||||||
int count = lists->limit() - lists->position();
|
int count = lists->limit() - lists->position();
|
||||||
::glCallLists(count, GL_INT, lists->getBuffer());
|
::glCallLists(count, GL_INT, lists->getBuffer());
|
||||||
}
|
}
|
||||||
|
|
@ -107,21 +92,21 @@ static PFNGLENDQUERYARBPROC _glEndQueryARB = nullptr;
|
||||||
static PFNGLGETQUERYOBJECTUIVARBPROC _glGetQueryObjectuivARB = nullptr;
|
static PFNGLGETQUERYOBJECTUIVARBPROC _glGetQueryObjectuivARB = nullptr;
|
||||||
static bool _queriesInitialized = false;
|
static bool _queriesInitialized = false;
|
||||||
|
|
||||||
static void initQueryFuncs()
|
static void initQueryFuncs() {
|
||||||
{
|
|
||||||
if (_queriesInitialized) return;
|
if (_queriesInitialized) return;
|
||||||
_queriesInitialized = true;
|
_queriesInitialized = true;
|
||||||
_glGenQueriesARB = (PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB");
|
_glGenQueriesARB =
|
||||||
_glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)dlsym(RTLD_DEFAULT, "glBeginQueryARB");
|
(PFNGLGENQUERIESARBPROC)dlsym(RTLD_DEFAULT, "glGenQueriesARB");
|
||||||
|
_glBeginQueryARB =
|
||||||
|
(PFNGLBEGINQUERYARBPROC)dlsym(RTLD_DEFAULT, "glBeginQueryARB");
|
||||||
_glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB");
|
_glEndQueryARB = (PFNGLENDQUERYARBPROC)dlsym(RTLD_DEFAULT, "glEndQueryARB");
|
||||||
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(RTLD_DEFAULT, "glGetQueryObjectuivARB");
|
_glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)dlsym(
|
||||||
|
RTLD_DEFAULT, "glGetQueryObjectuivARB");
|
||||||
}
|
}
|
||||||
|
|
||||||
void glGenQueriesARB(IntBuffer *buf)
|
void glGenQueriesARB(IntBuffer* buf) {
|
||||||
{
|
|
||||||
initQueryFuncs();
|
initQueryFuncs();
|
||||||
if (_glGenQueriesARB)
|
if (_glGenQueriesARB) {
|
||||||
{
|
|
||||||
GLuint id = 0;
|
GLuint id = 0;
|
||||||
_glGenQueriesARB(1, &id);
|
_glGenQueriesARB(1, &id);
|
||||||
buf->put((int)id);
|
buf->put((int)id);
|
||||||
|
|
@ -129,23 +114,19 @@ void glGenQueriesARB(IntBuffer *buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glBeginQueryARB(int target, int id)
|
void glBeginQueryARB(int target, int id) {
|
||||||
{
|
|
||||||
initQueryFuncs();
|
initQueryFuncs();
|
||||||
if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id);
|
if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glEndQueryARB(int target)
|
void glEndQueryARB(int target) {
|
||||||
{
|
|
||||||
initQueryFuncs();
|
initQueryFuncs();
|
||||||
if (_glEndQueryARB) _glEndQueryARB((GLenum)target);
|
if (_glEndQueryARB) _glEndQueryARB((GLenum)target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glGetQueryObjectuARB(int id, int pname, IntBuffer *params)
|
void glGetQueryObjectuARB(int id, int pname, IntBuffer* params) {
|
||||||
{
|
|
||||||
initQueryFuncs();
|
initQueryFuncs();
|
||||||
if (_glGetQueryObjectuivARB)
|
if (_glGetQueryObjectuivARB) {
|
||||||
{
|
|
||||||
GLuint val = 0;
|
GLuint val = 0;
|
||||||
_glGetQueryObjectuivARB((GLuint)id, (GLenum)pname, &val);
|
_glGetQueryObjectuivARB((GLuint)id, (GLenum)pname, &val);
|
||||||
params->put((int)val);
|
params->put((int)val);
|
||||||
|
|
@ -153,9 +134,10 @@ void glGetQueryObjectuARB(int id, int pname, IntBuffer *params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer *pixels)
|
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());
|
::glReadPixels(x, y, width, height, (GLenum)format, (GLenum)type,
|
||||||
|
pixels->getBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -15,44 +15,33 @@ 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)
|
void CConsoleMinecraftApp::StoreLaunchData() {}
|
||||||
{
|
void CConsoleMinecraftApp::ExitGame() {}
|
||||||
ProfileManager.SetRichPresenceContextValue(iPad,CONTEXT_GAME_STATE,contextId);
|
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);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConsoleMinecraftApp::CaptureSaveThumbnail()
|
void CConsoleMinecraftApp::CaptureSaveThumbnail() {}
|
||||||
{
|
void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t** thumbnailData,
|
||||||
}
|
unsigned int* thumbnailSize) {}
|
||||||
void CConsoleMinecraftApp::GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize)
|
void CConsoleMinecraftApp::ReleaseSaveThumbnail() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
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()
|
void CConsoleMinecraftApp::TemporaryCreateGameStart() {
|
||||||
{
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_Main::OnInit
|
///From CScene_Main::OnInit
|
||||||
|
|
||||||
app.setLevelGenerationOptions(NULL);
|
app.setLevelGenerationOptions(NULL);
|
||||||
|
|
||||||
|
|
@ -63,14 +52,16 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||||
pMinecraft->user->name = L"Windows";
|
pMinecraft->user->name = L"Windows";
|
||||||
app.ApplyGameSettingsChanged(0);
|
app.ApplyGameSettingsChanged(0);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameJoinLoad::OnInit
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///From CScene_MultiGameJoinLoad::OnInit
|
||||||
MinecraftServer::resetFlags();
|
MinecraftServer::resetFlags();
|
||||||
|
|
||||||
// From CScene_MultiGameJoinLoad::OnNotifyPressEx
|
// From CScene_MultiGameJoinLoad::OnNotifyPressEx
|
||||||
app.SetTutorialMode(false);
|
app.SetTutorialMode(false);
|
||||||
app.SetCorruptSaveDeleted(false);
|
app.SetCorruptSaveDeleted(false);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////// From CScene_MultiGameCreate::CreateGame
|
//////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
///From CScene_MultiGameCreate::CreateGame
|
||||||
|
|
||||||
app.ClearTerrainFeaturePosition();
|
app.ClearTerrainFeaturePosition();
|
||||||
std::wstring wWorldName = L"TestWorld";
|
std::wstring wWorldName = L"TestWorld";
|
||||||
|
|
@ -79,7 +70,10 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||||
StorageManager.SetSaveTitle(wWorldName.c_str());
|
StorageManager.SetSaveTitle(wWorldName.c_str());
|
||||||
|
|
||||||
bool isFlat = false;
|
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->seed = seedValue;
|
||||||
|
|
@ -90,7 +84,9 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||||
app.SetGameHostOption(eGameHostOption_Gamertags, 1);
|
app.SetGameHostOption(eGameHostOption_Gamertags, 1);
|
||||||
app.SetGameHostOption(eGameHostOption_BedrockFog, 1);
|
app.SetGameHostOption(eGameHostOption_BedrockFog, 1);
|
||||||
|
|
||||||
app.SetGameHostOption(eGameHostOption_GameType,GameType::CREATIVE->getId() ); // LevelSettings::GAMETYPE_SURVIVAL
|
app.SetGameHostOption(
|
||||||
|
eGameHostOption_GameType,
|
||||||
|
GameType::CREATIVE->getId()); // LevelSettings::GAMETYPE_SURVIVAL
|
||||||
app.SetGameHostOption(eGameHostOption_LevelType, 0);
|
app.SetGameHostOption(eGameHostOption_LevelType, 0);
|
||||||
app.SetGameHostOption(eGameHostOption_Structures, 1);
|
app.SetGameHostOption(eGameHostOption_Structures, 1);
|
||||||
app.SetGameHostOption(eGameHostOption_BonusChest, 0);
|
app.SetGameHostOption(eGameHostOption_BonusChest, 0);
|
||||||
|
|
@ -114,25 +110,22 @@ void CConsoleMinecraftApp::TemporaryCreateGameStart()
|
||||||
// Reset the autosave time
|
// Reset the autosave time
|
||||||
app.SetAutosaveTimerTime();
|
app.SetAutosaveTimerTime();
|
||||||
|
|
||||||
C4JThread* thread = new C4JThread(loadingParams->func, loadingParams->lpParam, "RunNetworkGame");
|
C4JThread* thread = new C4JThread(loadingParams->func,
|
||||||
|
loadingParams->lpParam, "RunNetworkGame");
|
||||||
thread->Run();
|
thread->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT)
|
int CConsoleMinecraftApp::GetLocalTMSFileIndex(WCHAR* wchTMSFile,
|
||||||
{
|
bool bFilenameIncludesExtension,
|
||||||
|
eFileExtensionType eEXT) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile)
|
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR* wchTMSFile) { return -1; }
|
||||||
{
|
|
||||||
|
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR* wchTMSFile,
|
||||||
|
eFileExtensionType eExt) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CConsoleMinecraftApp::LoadLocalTMSFile(WCHAR *wchTMSFile, eFileExtensionType eExt)
|
void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType) {}
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CConsoleMinecraftApp::FreeLocalTMSFiles(eTMSFileType eType)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class CConsoleMinecraftApp : public CMinecraftApp
|
class CConsoleMinecraftApp : public CMinecraftApp {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
CConsoleMinecraftApp();
|
CConsoleMinecraftApp();
|
||||||
|
|
||||||
|
|
@ -12,18 +11,23 @@ public:
|
||||||
virtual void FatalLoadError();
|
virtual void FatalLoadError();
|
||||||
|
|
||||||
virtual void CaptureSaveThumbnail();
|
virtual void CaptureSaveThumbnail();
|
||||||
virtual void GetSaveThumbnail(std::uint8_t **thumbnailData, unsigned int *thumbnailSize);
|
virtual void GetSaveThumbnail(std::uint8_t** thumbnailData,
|
||||||
|
unsigned int* thumbnailSize);
|
||||||
virtual void ReleaseSaveThumbnail();
|
virtual void ReleaseSaveThumbnail();
|
||||||
virtual void GetScreenshot(int iPad, std::uint8_t **screenshotData, unsigned int *screenshotSize);
|
virtual void GetScreenshot(int iPad, std::uint8_t** screenshotData,
|
||||||
|
unsigned int* screenshotSize);
|
||||||
|
|
||||||
virtual int LoadLocalTMSFile(WCHAR* wchTMSFile);
|
virtual int LoadLocalTMSFile(WCHAR* wchTMSFile);
|
||||||
virtual int LoadLocalTMSFile(WCHAR* wchTMSFile, eFileExtensionType eExt);
|
virtual int LoadLocalTMSFile(WCHAR* wchTMSFile, eFileExtensionType eExt);
|
||||||
|
|
||||||
virtual void FreeLocalTMSFiles(eTMSFileType eType);
|
virtual void FreeLocalTMSFiles(eTMSFileType eType);
|
||||||
virtual int GetLocalTMSFileIndex(WCHAR *wchTMSFile,bool bFilenameIncludesExtension,eFileExtensionType eEXT=eFileExtensionType_PNG);
|
virtual int GetLocalTMSFileIndex(
|
||||||
|
WCHAR* wchTMSFile, bool bFilenameIncludesExtension,
|
||||||
|
eFileExtensionType eEXT = eFileExtensionType_PNG);
|
||||||
|
|
||||||
// BANNED LEVEL LIST
|
// BANNED LEVEL LIST
|
||||||
virtual void ReadBannedList(int iPad, eTMSAction action=(eTMSAction)0, bool bCallback=false) {}
|
virtual void ReadBannedList(int iPad, eTMSAction action = (eTMSAction)0,
|
||||||
|
bool bCallback = false) {}
|
||||||
|
|
||||||
C4JStringTable* GetStringTable() { return NULL; }
|
C4JStringTable* GetStringTable() { return NULL; }
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -8,6 +8,9 @@ void ShutdownManager::StartShutdown() {}
|
||||||
void ShutdownManager::MainThreadHandleShutdown() {}
|
void ShutdownManager::MainThreadHandleShutdown() {}
|
||||||
|
|
||||||
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/) {}
|
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/) {}
|
||||||
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/, C4JThread::EventArray * /*eventArray*/) {}
|
void ShutdownManager::HasStarted(ShutdownManager::EThreadId /*threadId*/,
|
||||||
bool ShutdownManager::ShouldRun(ShutdownManager::EThreadId /*threadId*/) { return true; }
|
C4JThread::EventArray* /*eventArray*/) {}
|
||||||
|
bool ShutdownManager::ShouldRun(ShutdownManager::EThreadId /*threadId*/) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
void ShutdownManager::HasFinished(ShutdownManager::EThreadId /*threadId*/) {}
|
void ShutdownManager::HasFinished(ShutdownManager::EThreadId /*threadId*/) {}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,7 @@
|
||||||
|
|
||||||
ConsoleUIController ui;
|
ConsoleUIController ui;
|
||||||
|
|
||||||
void ConsoleUIController::init(S32 w, S32 h)
|
void ConsoleUIController::init(S32 w, S32 h) {
|
||||||
{
|
|
||||||
#ifdef _ENABLEIGGY
|
#ifdef _ENABLEIGGY
|
||||||
// Shared init
|
// Shared init
|
||||||
preInit(w, h);
|
preInit(w, h);
|
||||||
|
|
@ -21,18 +20,18 @@ void ConsoleUIController::init(S32 w, S32 h)
|
||||||
// init
|
// init
|
||||||
gdraw_funcs = gdraw_GL_CreateContext(w, h, 0);
|
gdraw_funcs = gdraw_GL_CreateContext(w, h, 0);
|
||||||
|
|
||||||
if (!gdraw_funcs)
|
if (!gdraw_funcs) {
|
||||||
{
|
|
||||||
app.DebugPrintf("Failed to initialise GDraw GL!\n");
|
app.DebugPrintf("Failed to initialise GDraw GL!\n");
|
||||||
fprintf(stderr, "[Linux_UIController] Failed to initialise GDraw GL!\n");
|
fprintf(stderr,
|
||||||
|
"[Linux_UIController] Failed to initialise GDraw GL!\n");
|
||||||
// nott fatal for now
|
// nott fatal for now
|
||||||
}
|
} else {
|
||||||
else
|
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000,
|
||||||
{
|
16 * 1024 * 1024);
|
||||||
|
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000,
|
||||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000, 16 * 1024 * 1024);
|
128 * 1024 * 1024);
|
||||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000, 128 * 1024 * 1024);
|
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10,
|
||||||
gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10, 32 * 1024 * 1024);
|
32 * 1024 * 1024);
|
||||||
|
|
||||||
IggySetGDraw(gdraw_funcs);
|
IggySetGDraw(gdraw_funcs);
|
||||||
}
|
}
|
||||||
|
|
@ -41,11 +40,9 @@ void ConsoleUIController::init(S32 w, S32 h)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleUIController::render()
|
void ConsoleUIController::render() {
|
||||||
{
|
|
||||||
#ifdef _ENABLEIGGY
|
#ifdef _ENABLEIGGY
|
||||||
if (!gdraw_funcs)
|
if (!gdraw_funcs) return;
|
||||||
return;
|
|
||||||
|
|
||||||
gdraw_GL_SetTileOrigin(0, 0, 0);
|
gdraw_GL_SetTileOrigin(0, 0, 0);
|
||||||
|
|
||||||
|
|
@ -56,20 +53,19 @@ void ConsoleUIController::render()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleUIController::beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion)
|
void ConsoleUIController::beginIggyCustomDraw4J(
|
||||||
{
|
IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) {
|
||||||
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
|
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomDrawData *ConsoleUIController::setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region)
|
CustomDrawData* ConsoleUIController::setupCustomDraw(
|
||||||
{
|
UIScene* scene, IggyCustomDrawCallbackRegion* region) {
|
||||||
CustomDrawData* customDrawRegion = new CustomDrawData();
|
CustomDrawData* customDrawRegion = new CustomDrawData();
|
||||||
customDrawRegion->x0 = region->x0;
|
customDrawRegion->x0 = region->x0;
|
||||||
customDrawRegion->x1 = region->x1;
|
customDrawRegion->x1 = region->x1;
|
||||||
customDrawRegion->y0 = region->y0;
|
customDrawRegion->y0 = region->y0;
|
||||||
customDrawRegion->y1 = region->y1;
|
customDrawRegion->y1 = region->y1;
|
||||||
|
|
||||||
|
|
||||||
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
|
gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat);
|
||||||
|
|
||||||
setupCustomDrawGameStateAndMatrices(scene, customDrawRegion);
|
setupCustomDrawGameStateAndMatrices(scene, customDrawRegion);
|
||||||
|
|
@ -77,8 +73,8 @@ CustomDrawData *ConsoleUIController::setupCustomDraw(UIScene *scene, IggyCustomD
|
||||||
return customDrawRegion;
|
return customDrawRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomDrawData *ConsoleUIController::calculateCustomDraw(IggyCustomDrawCallbackRegion *region)
|
CustomDrawData* ConsoleUIController::calculateCustomDraw(
|
||||||
{
|
IggyCustomDrawCallbackRegion* region) {
|
||||||
CustomDrawData* customDrawRegion = new CustomDrawData();
|
CustomDrawData* customDrawRegion = new CustomDrawData();
|
||||||
customDrawRegion->x0 = region->x0;
|
customDrawRegion->x0 = region->x0;
|
||||||
customDrawRegion->x1 = region->x1;
|
customDrawRegion->x1 = region->x1;
|
||||||
|
|
@ -90,35 +86,29 @@ CustomDrawData *ConsoleUIController::calculateCustomDraw(IggyCustomDrawCallbackR
|
||||||
return customDrawRegion;
|
return customDrawRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion *region)
|
void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion* region) {
|
||||||
{
|
|
||||||
endCustomDrawGameStateAndMatrices();
|
endCustomDrawGameStateAndMatrices();
|
||||||
|
|
||||||
gdraw_GL_EndCustomDraw(region);
|
gdraw_GL_EndCustomDraw(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos)
|
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) {
|
||||||
{
|
|
||||||
gdraw_GL_SetTileOrigin(xPos, yPos, 0);
|
gdraw_GL_SetTileOrigin(xPos, yPos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId)
|
GDrawTexture* ConsoleUIController::getSubstitutionTexture(int textureId) {
|
||||||
{
|
|
||||||
// todo impl
|
// todo impl
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleUIController::destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle)
|
void ConsoleUIController::destroySubstitutionTexture(void* destroyCallBackData,
|
||||||
{
|
GDrawTexture* handle) {
|
||||||
if (handle)
|
if (handle) gdraw_GL_WrappedTextureDestroy(handle);
|
||||||
gdraw_GL_WrappedTextureDestroy(handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConsoleUIController::shutdown()
|
void ConsoleUIController::shutdown() {
|
||||||
{
|
|
||||||
#ifdef _ENABLEIGGY
|
#ifdef _ENABLEIGGY
|
||||||
if (gdraw_funcs)
|
if (gdraw_funcs) {
|
||||||
{
|
|
||||||
gdraw_GL_DestroyContext();
|
gdraw_GL_DestroyContext();
|
||||||
gdraw_funcs = nullptr;
|
gdraw_funcs = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,17 @@
|
||||||
|
|
||||||
#include "../Common/UI/UIController.h"
|
#include "../Common/UI/UIController.h"
|
||||||
|
|
||||||
class ConsoleUIController : public UIController
|
class ConsoleUIController : public UIController {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
void init(S32 w, S32 h);
|
void init(S32 w, S32 h);
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
void beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion);
|
void beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion* region,
|
||||||
virtual CustomDrawData *setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region);
|
CustomDrawData* customDrawRegion);
|
||||||
virtual CustomDrawData *calculateCustomDraw(IggyCustomDrawCallbackRegion *region);
|
virtual CustomDrawData* setupCustomDraw(
|
||||||
|
UIScene* scene, IggyCustomDrawCallbackRegion* region);
|
||||||
|
virtual CustomDrawData* calculateCustomDraw(
|
||||||
|
IggyCustomDrawCallbackRegion* region);
|
||||||
virtual void endCustomDraw(IggyCustomDrawCallbackRegion* region);
|
virtual void endCustomDraw(IggyCustomDrawCallbackRegion* region);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -18,7 +20,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GDrawTexture* getSubstitutionTexture(int textureId);
|
GDrawTexture* getSubstitutionTexture(int textureId);
|
||||||
void destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle);
|
void destroySubstitutionTexture(void* destroyCallBackData,
|
||||||
|
GDrawTexture* handle);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,11 @@
|
||||||
#ifndef _SOCIAL_MANAGER_H
|
#ifndef _SOCIAL_MANAGER_H
|
||||||
#define _SOCIAL_MANAGER_H
|
#define _SOCIAL_MANAGER_H
|
||||||
|
|
||||||
enum ESocialNetwork
|
enum ESocialNetwork { eFacebook = 0, eNumSocialNetworks };
|
||||||
{
|
|
||||||
eFacebook = 0,
|
|
||||||
eNumSocialNetworks
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSocialManager
|
class CSocialManager {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static CSocialManager* Instance()
|
static CSocialManager* Instance() {
|
||||||
{
|
|
||||||
static CSocialManager s_instance;
|
static CSocialManager s_instance;
|
||||||
return &s_instance;
|
return &s_instance;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,22 +11,11 @@
|
||||||
|
|
||||||
#include "DirectXMath.h"
|
#include "DirectXMath.h"
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX {
|
||||||
{
|
|
||||||
|
|
||||||
enum ContainmentType
|
enum ContainmentType { DISJOINT = 0, INTERSECTS = 1, CONTAINS = 2 };
|
||||||
{
|
|
||||||
DISJOINT = 0,
|
|
||||||
INTERSECTS = 1,
|
|
||||||
CONTAINS = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum PlaneIntersectionType
|
enum PlaneIntersectionType { FRONT = 0, INTERSECTING = 1, BACK = 2 };
|
||||||
{
|
|
||||||
FRONT = 0,
|
|
||||||
INTERSECTING = 1,
|
|
||||||
BACK = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
struct BoundingBox;
|
struct BoundingBox;
|
||||||
struct BoundingOrientedBox;
|
struct BoundingOrientedBox;
|
||||||
|
|
@ -42,8 +31,7 @@ namespace DirectX
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Bounding sphere
|
// Bounding sphere
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
struct BoundingSphere
|
struct BoundingSphere {
|
||||||
{
|
|
||||||
XMFLOAT3 Center; // Center of the sphere.
|
XMFLOAT3 Center; // Center of the sphere.
|
||||||
float Radius; // Radius of the sphere.
|
float Radius; // Radius of the sphere.
|
||||||
|
|
||||||
|
|
@ -56,19 +44,25 @@ namespace DirectX
|
||||||
BoundingSphere(BoundingSphere&&) = default;
|
BoundingSphere(BoundingSphere&&) = default;
|
||||||
BoundingSphere& operator=(BoundingSphere&&) = default;
|
BoundingSphere& operator=(BoundingSphere&&) = default;
|
||||||
|
|
||||||
constexpr BoundingSphere(_In_ const XMFLOAT3& center, _In_ float radius) noexcept
|
constexpr BoundingSphere(_In_ const XMFLOAT3& center,
|
||||||
|
_In_ float radius) noexcept
|
||||||
: Center(center), Radius(radius) {}
|
: Center(center), Radius(radius) {}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out, _In_ FXMMATRIX M) const noexcept;
|
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out,
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingSphere& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
|
_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
|
// Transform the sphere
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
|
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 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 BoundingSphere& sh) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
|
ContainmentType Contains(
|
||||||
|
_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
||||||
|
|
||||||
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
|
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
|
||||||
|
|
@ -76,36 +70,49 @@ namespace DirectX
|
||||||
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
bool Intersects(_In_ const BoundingFrustum& fr) 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;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
|
||||||
|
_In_ FXMVECTOR V2) const noexcept;
|
||||||
// Triangle-sphere test
|
// Triangle-sphere test
|
||||||
|
|
||||||
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
PlaneIntersectionType XM_CALLCONV
|
||||||
|
Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
||||||
// Plane-sphere test
|
// Plane-sphere test
|
||||||
|
|
||||||
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
|
||||||
|
_Out_ float& Dist) const noexcept;
|
||||||
// Ray-sphere test
|
// Ray-sphere test
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
|
ContainmentType XM_CALLCONV
|
||||||
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
|
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)
|
// Test sphere against six planes (see BoundingFrustum::GetPlanes)
|
||||||
|
|
||||||
// Static methods
|
// Static methods
|
||||||
static void CreateMerged(_Out_ BoundingSphere& Out, _In_ const BoundingSphere& S1, _In_ const BoundingSphere& S2) noexcept;
|
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,
|
||||||
static void CreateFromBoundingBox(_Out_ BoundingSphere& Out, _In_ const BoundingOrientedBox& box) noexcept;
|
_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,
|
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;
|
_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;
|
static void CreateFromFrustum(_Out_ BoundingSphere& Out,
|
||||||
|
_In_ const BoundingFrustum& fr) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Axis-aligned bounding box
|
// Axis-aligned bounding box
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
struct BoundingBox
|
struct BoundingBox {
|
||||||
{
|
|
||||||
static constexpr size_t CORNER_COUNT = 8;
|
static constexpr size_t CORNER_COUNT = 8;
|
||||||
|
|
||||||
XMFLOAT3 Center; // Center of the box.
|
XMFLOAT3 Center; // Center of the box.
|
||||||
|
|
@ -120,21 +127,27 @@ namespace DirectX
|
||||||
BoundingBox(BoundingBox&&) = default;
|
BoundingBox(BoundingBox&&) = default;
|
||||||
BoundingBox& operator=(BoundingBox&&) = default;
|
BoundingBox& operator=(BoundingBox&&) = default;
|
||||||
|
|
||||||
constexpr BoundingBox(_In_ const XMFLOAT3& center, _In_ const XMFLOAT3& extents) noexcept
|
constexpr BoundingBox(_In_ const XMFLOAT3& center,
|
||||||
|
_In_ const XMFLOAT3& extents) noexcept
|
||||||
: Center(center), Extents(extents) {}
|
: Center(center), Extents(extents) {}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingBox& Out, _In_ FXMMATRIX M) const noexcept;
|
void XM_CALLCONV Transform(_Out_ BoundingBox& Out,
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingBox& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
|
_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;
|
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
|
||||||
// Gets the 8 corners of the box
|
// Gets the 8 corners of the box
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
|
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 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 BoundingSphere& sh) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
|
ContainmentType Contains(
|
||||||
|
_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
||||||
|
|
||||||
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
|
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
|
||||||
|
|
@ -142,42 +155,55 @@ namespace DirectX
|
||||||
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
bool Intersects(_In_ const BoundingFrustum& fr) 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;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
|
||||||
|
_In_ FXMVECTOR V2) const noexcept;
|
||||||
// Triangle-Box test
|
// Triangle-Box test
|
||||||
|
|
||||||
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
PlaneIntersectionType XM_CALLCONV
|
||||||
|
Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
||||||
// Plane-box test
|
// Plane-box test
|
||||||
|
|
||||||
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
|
||||||
|
_Out_ float& Dist) const noexcept;
|
||||||
// Ray-Box test
|
// Ray-Box test
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
|
ContainmentType XM_CALLCONV
|
||||||
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
|
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)
|
// Test box against six planes (see BoundingFrustum::GetPlanes)
|
||||||
|
|
||||||
// Static methods
|
// Static methods
|
||||||
static void CreateMerged(_Out_ BoundingBox& Out, _In_ const BoundingBox& b1, _In_ const BoundingBox& b2) noexcept;
|
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 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 XM_CALLCONV CreateFromPoints(_Out_ BoundingBox& Out,
|
||||||
|
_In_ FXMVECTOR pt1,
|
||||||
|
_In_ FXMVECTOR pt2) noexcept;
|
||||||
static void CreateFromPoints(_Out_ BoundingBox& Out, _In_ size_t Count,
|
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;
|
_In_reads_bytes_(sizeof(XMFLOAT3) +
|
||||||
|
Stride * (Count - 1))
|
||||||
|
const XMFLOAT3* pPoints,
|
||||||
|
_In_ size_t Stride) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Oriented bounding box
|
// Oriented bounding box
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
struct BoundingOrientedBox
|
struct BoundingOrientedBox {
|
||||||
{
|
|
||||||
static constexpr size_t CORNER_COUNT = 8;
|
static constexpr size_t CORNER_COUNT = 8;
|
||||||
|
|
||||||
XMFLOAT3 Center; // Center of the box.
|
XMFLOAT3 Center; // Center of the box.
|
||||||
XMFLOAT3 Extents; // Distance from the center to each side.
|
XMFLOAT3 Extents; // Distance from the center to each side.
|
||||||
XMFLOAT4 Orientation; // Unit quaternion representing rotation (box -> world).
|
XMFLOAT4
|
||||||
|
Orientation; // Unit quaternion representing rotation (box -> world).
|
||||||
|
|
||||||
// Creators
|
// Creators
|
||||||
BoundingOrientedBox() noexcept : Center(0, 0, 0), Extents(1.f, 1.f, 1.f), Orientation(0, 0, 0, 1.f) {}
|
BoundingOrientedBox() noexcept
|
||||||
|
: Center(0, 0, 0), Extents(1.f, 1.f, 1.f), Orientation(0, 0, 0, 1.f) {}
|
||||||
|
|
||||||
BoundingOrientedBox(const BoundingOrientedBox&) = default;
|
BoundingOrientedBox(const BoundingOrientedBox&) = default;
|
||||||
BoundingOrientedBox& operator=(const BoundingOrientedBox&) = default;
|
BoundingOrientedBox& operator=(const BoundingOrientedBox&) = default;
|
||||||
|
|
@ -185,21 +211,28 @@ namespace DirectX
|
||||||
BoundingOrientedBox(BoundingOrientedBox&&) = default;
|
BoundingOrientedBox(BoundingOrientedBox&&) = default;
|
||||||
BoundingOrientedBox& operator=(BoundingOrientedBox&&) = default;
|
BoundingOrientedBox& operator=(BoundingOrientedBox&&) = default;
|
||||||
|
|
||||||
constexpr BoundingOrientedBox(_In_ const XMFLOAT3& center, _In_ const XMFLOAT3& extents, _In_ const XMFLOAT4& orientation) noexcept
|
constexpr BoundingOrientedBox(_In_ const XMFLOAT3& center,
|
||||||
|
_In_ const XMFLOAT3& extents,
|
||||||
|
_In_ const XMFLOAT4& orientation) noexcept
|
||||||
: Center(center), Extents(extents), Orientation(orientation) {}
|
: Center(center), Extents(extents), Orientation(orientation) {}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out, _In_ FXMMATRIX M) const noexcept;
|
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out,
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingOrientedBox& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
|
_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;
|
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
|
||||||
// Gets the 8 corners of the box
|
// Gets the 8 corners of the box
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
|
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 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 BoundingSphere& sh) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
|
ContainmentType Contains(
|
||||||
|
_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
||||||
|
|
||||||
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
|
bool Intersects(_In_ const BoundingSphere& sh) const noexcept;
|
||||||
|
|
@ -207,31 +240,40 @@ namespace DirectX
|
||||||
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
bool Intersects(_In_ const BoundingFrustum& fr) 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;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
|
||||||
|
_In_ FXMVECTOR V2) const noexcept;
|
||||||
// Triangle-OrientedBox test
|
// Triangle-OrientedBox test
|
||||||
|
|
||||||
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
PlaneIntersectionType XM_CALLCONV
|
||||||
|
Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
||||||
// Plane-OrientedBox test
|
// Plane-OrientedBox test
|
||||||
|
|
||||||
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
|
||||||
|
_Out_ float& Dist) const noexcept;
|
||||||
// Ray-OrientedBox test
|
// Ray-OrientedBox test
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
|
ContainmentType XM_CALLCONV
|
||||||
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
|
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)
|
// Test OrientedBox against six planes (see BoundingFrustum::GetPlanes)
|
||||||
|
|
||||||
// Static methods
|
// Static methods
|
||||||
static void CreateFromBoundingBox(_Out_ BoundingOrientedBox& Out, _In_ const BoundingBox& box) noexcept;
|
static void CreateFromBoundingBox(_Out_ BoundingOrientedBox& Out,
|
||||||
|
_In_ const BoundingBox& box) noexcept;
|
||||||
|
|
||||||
static void CreateFromPoints(_Out_ BoundingOrientedBox& Out, _In_ size_t Count,
|
static void CreateFromPoints(_Out_ BoundingOrientedBox& Out,
|
||||||
_In_reads_bytes_(sizeof(XMFLOAT3) + Stride * (Count - 1)) const XMFLOAT3* pPoints, _In_ size_t Stride) noexcept;
|
_In_ size_t Count,
|
||||||
|
_In_reads_bytes_(sizeof(XMFLOAT3) +
|
||||||
|
Stride * (Count - 1))
|
||||||
|
const XMFLOAT3* pPoints,
|
||||||
|
_In_ size_t Stride) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
// Bounding frustum
|
// Bounding frustum
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
struct BoundingFrustum
|
struct BoundingFrustum {
|
||||||
{
|
|
||||||
static constexpr size_t CORNER_COUNT = 8;
|
static constexpr size_t CORNER_COUNT = 8;
|
||||||
|
|
||||||
XMFLOAT3 Origin; // Origin of the frustum (and projection).
|
XMFLOAT3 Origin; // Origin of the frustum (and projection).
|
||||||
|
|
@ -244,9 +286,15 @@ namespace DirectX
|
||||||
float Near, Far; // Z of the near plane and far plane.
|
float Near, Far; // Z of the near plane and far plane.
|
||||||
|
|
||||||
// Creators
|
// Creators
|
||||||
BoundingFrustum() noexcept :
|
BoundingFrustum() noexcept
|
||||||
Origin(0, 0, 0), Orientation(0, 0, 0, 1.f), RightSlope(1.f), LeftSlope(-1.f),
|
: Origin(0, 0, 0),
|
||||||
TopSlope(1.f), BottomSlope(-1.f), Near(0), Far(1.f) {}
|
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(const BoundingFrustum&) = default;
|
||||||
BoundingFrustum& operator=(const BoundingFrustum&) = default;
|
BoundingFrustum& operator=(const BoundingFrustum&) = default;
|
||||||
|
|
@ -254,26 +302,39 @@ namespace DirectX
|
||||||
BoundingFrustum(BoundingFrustum&&) = default;
|
BoundingFrustum(BoundingFrustum&&) = default;
|
||||||
BoundingFrustum& operator=(BoundingFrustum&&) = default;
|
BoundingFrustum& operator=(BoundingFrustum&&) = default;
|
||||||
|
|
||||||
constexpr BoundingFrustum(_In_ const XMFLOAT3& origin, _In_ const XMFLOAT4& orientation,
|
constexpr BoundingFrustum(_In_ const XMFLOAT3& origin,
|
||||||
_In_ float rightSlope, _In_ float leftSlope, _In_ float topSlope, _In_ float bottomSlope,
|
_In_ const XMFLOAT4& orientation,
|
||||||
_In_ float nearPlane, _In_ float farPlane) noexcept
|
_In_ float rightSlope, _In_ float leftSlope,
|
||||||
: Origin(origin), Orientation(orientation),
|
_In_ float topSlope, _In_ float bottomSlope,
|
||||||
RightSlope(rightSlope), LeftSlope(leftSlope), TopSlope(topSlope), BottomSlope(bottomSlope),
|
_In_ float nearPlane,
|
||||||
Near(nearPlane), Far(farPlane) {}
|
_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;
|
BoundingFrustum(_In_ CXMMATRIX Projection, bool rhcoords = false) noexcept;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out, _In_ FXMMATRIX M) const noexcept;
|
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out,
|
||||||
void XM_CALLCONV Transform(_Out_ BoundingFrustum& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation) const noexcept;
|
_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;
|
void GetCorners(_Out_writes_(8) XMFLOAT3* Corners) const noexcept;
|
||||||
// Gets the 8 corners of the frustum
|
// Gets the 8 corners of the frustum
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV Contains(_In_ FXMVECTOR Point) const noexcept;
|
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 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 BoundingSphere& sp) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
ContainmentType Contains(_In_ const BoundingBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingOrientedBox& box) const noexcept;
|
ContainmentType Contains(
|
||||||
|
_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
ContainmentType Contains(_In_ const BoundingFrustum& fr) const noexcept;
|
||||||
// Frustum-Frustum test
|
// Frustum-Frustum test
|
||||||
|
|
||||||
|
|
@ -282,46 +343,64 @@ namespace DirectX
|
||||||
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
bool Intersects(_In_ const BoundingOrientedBox& box) const noexcept;
|
||||||
bool Intersects(_In_ const BoundingFrustum& fr) 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;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1,
|
||||||
|
_In_ FXMVECTOR V2) const noexcept;
|
||||||
// Triangle-Frustum test
|
// Triangle-Frustum test
|
||||||
|
|
||||||
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
PlaneIntersectionType XM_CALLCONV
|
||||||
|
Intersects(_In_ FXMVECTOR Plane) const noexcept;
|
||||||
// Plane-Frustum test
|
// Plane-Frustum test
|
||||||
|
|
||||||
bool XM_CALLCONV Intersects(_In_ FXMVECTOR rayOrigin, _In_ FXMVECTOR Direction, _Out_ float& Dist) const noexcept;
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR rayOrigin,
|
||||||
|
_In_ FXMVECTOR Direction,
|
||||||
|
_Out_ float& Dist) const noexcept;
|
||||||
// Ray-Frustum test
|
// Ray-Frustum test
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
|
ContainmentType XM_CALLCONV
|
||||||
_In_ GXMVECTOR Plane3, _In_ HXMVECTOR Plane4, _In_ HXMVECTOR Plane5) const noexcept;
|
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)
|
// Test frustum against six planes (see BoundingFrustum::GetPlanes)
|
||||||
|
|
||||||
void GetPlanes(_Out_opt_ XMVECTOR* NearPlane, _Out_opt_ XMVECTOR* FarPlane, _Out_opt_ XMVECTOR* RightPlane,
|
void GetPlanes(_Out_opt_ XMVECTOR* NearPlane, _Out_opt_ XMVECTOR* FarPlane,
|
||||||
_Out_opt_ XMVECTOR* LeftPlane, _Out_opt_ XMVECTOR* TopPlane, _Out_opt_ XMVECTOR* BottomPlane) const noexcept;
|
_Out_opt_ XMVECTOR* RightPlane,
|
||||||
|
_Out_opt_ XMVECTOR* LeftPlane, _Out_opt_ XMVECTOR* TopPlane,
|
||||||
|
_Out_opt_ XMVECTOR* BottomPlane) const noexcept;
|
||||||
// Create 6 Planes representation of Frustum
|
// Create 6 Planes representation of Frustum
|
||||||
|
|
||||||
// Static methods
|
// Static methods
|
||||||
static void XM_CALLCONV CreateFromMatrix(_Out_ BoundingFrustum& Out, _In_ FXMMATRIX Projection, bool rhcoords = false) noexcept;
|
static void XM_CALLCONV CreateFromMatrix(_Out_ BoundingFrustum& Out,
|
||||||
|
_In_ FXMMATRIX Projection,
|
||||||
|
bool rhcoords = false) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Triangle intersection testing routines.
|
// Triangle intersection testing routines.
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
namespace TriangleTests
|
namespace TriangleTests {
|
||||||
{
|
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction,
|
||||||
bool XM_CALLCONV Intersects(_In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _In_ FXMVECTOR V0, _In_ GXMVECTOR V1, _In_ HXMVECTOR V2, _Out_ float& Dist) noexcept;
|
_In_ FXMVECTOR V0, _In_ GXMVECTOR V1,
|
||||||
|
_In_ HXMVECTOR V2, _Out_ float& Dist) noexcept;
|
||||||
// Ray-Triangle
|
// 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;
|
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
|
// Triangle-Triangle
|
||||||
|
|
||||||
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2, _In_ GXMVECTOR Plane) noexcept;
|
PlaneIntersectionType XM_CALLCONV Intersects(_In_ FXMVECTOR V0,
|
||||||
|
_In_ FXMVECTOR V1,
|
||||||
|
_In_ FXMVECTOR V2,
|
||||||
|
_In_ GXMVECTOR Plane) noexcept;
|
||||||
// Plane-Triangle
|
// Plane-Triangle
|
||||||
|
|
||||||
ContainmentType XM_CALLCONV ContainedBy(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2,
|
ContainmentType XM_CALLCONV
|
||||||
|
ContainedBy(_In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2,
|
||||||
_In_ GXMVECTOR Plane0, _In_ HXMVECTOR Plane1, _In_ HXMVECTOR Plane2,
|
_In_ GXMVECTOR Plane0, _In_ HXMVECTOR Plane1, _In_ HXMVECTOR Plane2,
|
||||||
_In_ CXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5) noexcept;
|
_In_ CXMVECTOR Plane3, _In_ CXMVECTOR Plane4,
|
||||||
|
_In_ CXMVECTOR Plane5) noexcept;
|
||||||
// Test a triangle against six planes at once (see BoundingFrustum::GetPlanes)
|
// Test a triangle against six planes at once (see BoundingFrustum::GetPlanes)
|
||||||
}
|
} // namespace TriangleTests
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
@ -367,4 +446,3 @@ namespace DirectX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace DirectX
|
} // namespace DirectX
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,302 +11,490 @@
|
||||||
|
|
||||||
#include "DirectXMath.h"
|
#include "DirectXMath.h"
|
||||||
|
|
||||||
namespace DirectX
|
namespace DirectX {
|
||||||
{
|
|
||||||
|
|
||||||
namespace Colors
|
namespace Colors {
|
||||||
{
|
|
||||||
// Standard colors (Red/Green/Blue/Alpha) in sRGB colorspace
|
// Standard colors (Red/Green/Blue/Alpha) in sRGB colorspace
|
||||||
XMGLOBALCONST XMVECTORF32 AliceBlue = { { { 0.941176534f, 0.972549081f, 1.f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 AliceBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 AntiqueWhite = { { { 0.980392218f, 0.921568692f, 0.843137324f, 1.f } } };
|
{{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 Aqua = {{{0.f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Aquamarine = { { { 0.498039246f, 1.f, 0.831372619f, 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 Azure = {{{0.941176534f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Beige = { { { 0.960784376f, 0.960784376f, 0.862745166f, 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 Bisque = {{{1.f, 0.894117713f, 0.768627524f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Black = {{{0.f, 0.f, 0.f, 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 BlanchedAlmond = {
|
||||||
|
{{1.f, 0.921568692f, 0.803921640f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Blue = {{{0.f, 0.f, 1.f, 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 BlueViolet = {
|
||||||
XMGLOBALCONST XMVECTORF32 Brown = { { { 0.647058845f, 0.164705887f, 0.164705887f, 1.f } } };
|
{{0.541176498f, 0.168627456f, 0.886274576f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 BurlyWood = { { { 0.870588303f, 0.721568644f, 0.529411793f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Brown = {
|
||||||
XMGLOBALCONST XMVECTORF32 CadetBlue = { { { 0.372549027f, 0.619607866f, 0.627451003f, 1.f } } };
|
{{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 Chartreuse = {{{0.498039246f, 1.f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Chocolate = { { { 0.823529482f, 0.411764741f, 0.117647067f, 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 Coral = {{{1.f, 0.498039246f, 0.313725501f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 CornflowerBlue = { { { 0.392156899f, 0.584313750f, 0.929411829f, 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 Cornsilk = {{{1.f, 0.972549081f, 0.862745166f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Crimson = { { { 0.862745166f, 0.078431375f, 0.235294133f, 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 Cyan = {{{0.f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkBlue = {{{0.f, 0.f, 0.545098066f, 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 DarkCyan = {{{0.f, 0.545098066f, 0.545098066f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = { { { 0.721568644f, 0.525490224f, 0.043137256f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkGray = { { { 0.662745118f, 0.662745118f, 0.662745118f, 1.f } } };
|
{{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 DarkGreen = {{{0.f, 0.392156899f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkKhaki = { { { 0.741176486f, 0.717647076f, 0.419607878f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkKhaki = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkMagenta = { { { 0.545098066f, 0.f, 0.545098066f, 1.f } } };
|
{{0.741176486f, 0.717647076f, 0.419607878f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkOliveGreen = { { { 0.333333343f, 0.419607878f, 0.184313729f, 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 DarkOrange = {{{1.f, 0.549019635f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkOrchid = { { { 0.600000024f, 0.196078449f, 0.800000072f, 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 DarkRed = {{{0.545098066f, 0.f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSalmon = { { { 0.913725555f, 0.588235319f, 0.478431404f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkSalmon = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = { { { 0.560784340f, 0.737254918f, 0.545098066f, 1.f } } };
|
{{0.913725555f, 0.588235319f, 0.478431404f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = { { { 0.282352954f, 0.239215702f, 0.545098066f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSlateGray = { { { 0.184313729f, 0.309803933f, 0.309803933f, 1.f } } };
|
{{0.560784340f, 0.737254918f, 0.545098066f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkTurquoise = { { { 0.f, 0.807843208f, 0.819607913f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkViolet = { { { 0.580392182f, 0.f, 0.827451050f, 1.f } } };
|
{{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 DeepPink = {{{1.f, 0.078431375f, 0.576470613f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DeepSkyBlue = {{{0.f, 0.749019623f, 1.f, 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 DimGray = {
|
||||||
XMGLOBALCONST XMVECTORF32 DodgerBlue = { { { 0.117647067f, 0.564705908f, 1.f, 1.f } } };
|
{{0.411764741f, 0.411764741f, 0.411764741f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Firebrick = { { { 0.698039234f, 0.133333340f, 0.133333340f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DodgerBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 FloralWhite = { { { 1.f, 0.980392218f, 0.941176534f, 1.f } } };
|
{{0.117647067f, 0.564705908f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 ForestGreen = { { { 0.133333340f, 0.545098066f, 0.133333340f, 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 Fuchsia = {{{1.f, 0.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Gainsboro = { { { 0.862745166f, 0.862745166f, 0.862745166f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Gainsboro = {
|
||||||
XMGLOBALCONST XMVECTORF32 GhostWhite = { { { 0.972549081f, 0.972549081f, 1.f, 1.f } } };
|
{{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 Gold = {{{1.f, 0.843137324f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Goldenrod = { { { 0.854902029f, 0.647058845f, 0.125490203f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Goldenrod = {
|
||||||
XMGLOBALCONST XMVECTORF32 Gray = { { { 0.501960814f, 0.501960814f, 0.501960814f, 1.f } } };
|
{{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 Green = {{{0.f, 0.501960814f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 GreenYellow = { { { 0.678431392f, 1.f, 0.184313729f, 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 Honeydew = {{{0.941176534f, 1.f, 0.941176534f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 HotPink = {{{1.f, 0.411764741f, 0.705882370f, 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 IndianRed = {
|
||||||
|
{{0.803921640f, 0.360784322f, 0.360784322f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Indigo = {{{0.294117659f, 0.f, 0.509803951f, 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 Ivory = {{{1.f, 1.f, 0.941176534f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Khaki = { { { 0.941176534f, 0.901960850f, 0.549019635f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Khaki = {
|
||||||
XMGLOBALCONST XMVECTORF32 Lavender = { { { 0.901960850f, 0.901960850f, 0.980392218f, 1.f } } };
|
{{0.941176534f, 0.901960850f, 0.549019635f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LavenderBlush = { { { 1.f, 0.941176534f, 0.960784376f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Lavender = {
|
||||||
XMGLOBALCONST XMVECTORF32 LawnGreen = { { { 0.486274540f, 0.988235354f, 0.f, 1.f } } };
|
{{0.901960850f, 0.901960850f, 0.980392218f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LemonChiffon = { { { 1.f, 0.980392218f, 0.803921640f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LavenderBlush = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightBlue = { { { 0.678431392f, 0.847058892f, 0.901960850f, 1.f } } };
|
{{1.f, 0.941176534f, 0.960784376f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightCoral = { { { 0.941176534f, 0.501960814f, 0.501960814f, 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 LightCyan = {{{0.878431439f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = { { { 0.980392218f, 0.980392218f, 0.823529482f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightGray = { { { 0.827451050f, 0.827451050f, 0.827451050f, 1.f } } };
|
{{0.980392218f, 0.980392218f, 0.823529482f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightGreen = { { { 0.564705908f, 0.933333397f, 0.564705908f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightGray = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightPink = { { { 1.f, 0.713725507f, 0.756862819f, 1.f } } };
|
{{0.827451050f, 0.827451050f, 0.827451050f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightSalmon = { { { 1.f, 0.627451003f, 0.478431404f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightSeaGreen = { { { 0.125490203f, 0.698039234f, 0.666666687f, 1.f } } };
|
{{0.564705908f, 0.933333397f, 0.564705908f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightSkyBlue = { { { 0.529411793f, 0.807843208f, 0.980392218f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightPink = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightSlateGray = { { { 0.466666698f, 0.533333361f, 0.600000024f, 1.f } } };
|
{{1.f, 0.713725507f, 0.756862819f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightSteelBlue = { { { 0.690196097f, 0.768627524f, 0.870588303f, 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 LightYellow = {{{1.f, 1.f, 0.878431439f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Lime = {{{0.f, 1.f, 0.f, 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 LimeGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 Linen = { { { 0.980392218f, 0.941176534f, 0.901960850f, 1.f } } };
|
{{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 Magenta = {{{1.f, 0.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Maroon = {{{0.501960814f, 0.f, 0.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 MediumAquamarine = {
|
||||||
|
{{0.400000036f, 0.803921640f, 0.666666687f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumBlue = {{{0.f, 0.f, 0.803921640f, 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 MediumOrchid = {
|
||||||
XMGLOBALCONST XMVECTORF32 MediumPurple = { { { 0.576470613f, 0.439215720f, 0.858823597f, 1.f } } };
|
{{0.729411781f, 0.333333343f, 0.827451050f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = { { { 0.235294133f, 0.701960802f, 0.443137288f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumPurple = {
|
||||||
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = { { { 0.482352972f, 0.407843173f, 0.933333397f, 1.f } } };
|
{{0.576470613f, 0.439215720f, 0.858823597f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = { { { 0.f, 0.980392218f, 0.603921592f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 MediumTurquoise = { { { 0.282352954f, 0.819607913f, 0.800000072f, 1.f } } };
|
{{0.235294133f, 0.701960802f, 0.443137288f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumVioletRed = { { { 0.780392230f, 0.082352944f, 0.521568656f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 MidnightBlue = { { { 0.098039225f, 0.098039225f, 0.439215720f, 1.f } } };
|
{{0.482352972f, 0.407843173f, 0.933333397f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MintCream = { { { 0.960784376f, 1.f, 0.980392218f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 MistyRose = { { { 1.f, 0.894117713f, 0.882353008f, 1.f } } };
|
{{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 Moccasin = {{{1.f, 0.894117713f, 0.709803939f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 NavajoWhite = { { { 1.f, 0.870588303f, 0.678431392f, 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 Navy = {{{0.f, 0.f, 0.501960814f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 OldLace = { { { 0.992156923f, 0.960784376f, 0.901960850f, 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 Olive = {{{0.501960814f, 0.501960814f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 OliveDrab = { { { 0.419607878f, 0.556862772f, 0.137254909f, 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 Orange = {{{1.f, 0.647058845f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 OrangeRed = {{{1.f, 0.270588249f, 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 Orchid = {
|
||||||
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = { { { 0.933333397f, 0.909803987f, 0.666666687f, 1.f } } };
|
{{0.854902029f, 0.439215720f, 0.839215755f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 PaleGreen = { { { 0.596078455f, 0.984313786f, 0.596078455f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = {
|
||||||
XMGLOBALCONST XMVECTORF32 PaleTurquoise = { { { 0.686274529f, 0.933333397f, 0.933333397f, 1.f } } };
|
{{0.933333397f, 0.909803987f, 0.666666687f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 PaleVioletRed = { { { 0.858823597f, 0.439215720f, 0.576470613f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 PaleGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 PapayaWhip = { { { 1.f, 0.937254965f, 0.835294187f, 1.f } } };
|
{{0.596078455f, 0.984313786f, 0.596078455f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 PeachPuff = { { { 1.f, 0.854902029f, 0.725490212f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 PaleTurquoise = {
|
||||||
XMGLOBALCONST XMVECTORF32 Peru = { { { 0.803921640f, 0.521568656f, 0.247058839f, 1.f } } };
|
{{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 Pink = {{{1.f, 0.752941251f, 0.796078503f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Plum = { { { 0.866666734f, 0.627451003f, 0.866666734f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Plum = {
|
||||||
XMGLOBALCONST XMVECTORF32 PowderBlue = { { { 0.690196097f, 0.878431439f, 0.901960850f, 1.f } } };
|
{{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 Purple = {{{0.501960814f, 0.f, 0.501960814f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Red = {{{1.f, 0.f, 0.f, 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 RosyBrown = {
|
||||||
XMGLOBALCONST XMVECTORF32 RoyalBlue = { { { 0.254901975f, 0.411764741f, 0.882353008f, 1.f } } };
|
{{0.737254918f, 0.560784340f, 0.560784340f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SaddleBrown = { { { 0.545098066f, 0.270588249f, 0.074509807f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 RoyalBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 Salmon = { { { 0.980392218f, 0.501960814f, 0.447058856f, 1.f } } };
|
{{0.254901975f, 0.411764741f, 0.882353008f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SandyBrown = { { { 0.956862807f, 0.643137276f, 0.376470625f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 SaddleBrown = {
|
||||||
XMGLOBALCONST XMVECTORF32 SeaGreen = { { { 0.180392161f, 0.545098066f, 0.341176480f, 1.f } } };
|
{{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 SeaShell = {{{1.f, 0.960784376f, 0.933333397f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Sienna = { { { 0.627451003f, 0.321568638f, 0.176470593f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Sienna = {
|
||||||
XMGLOBALCONST XMVECTORF32 Silver = { { { 0.752941251f, 0.752941251f, 0.752941251f, 1.f } } };
|
{{0.627451003f, 0.321568638f, 0.176470593f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SkyBlue = { { { 0.529411793f, 0.807843208f, 0.921568692f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Silver = {
|
||||||
XMGLOBALCONST XMVECTORF32 SlateBlue = { { { 0.415686309f, 0.352941185f, 0.803921640f, 1.f } } };
|
{{0.752941251f, 0.752941251f, 0.752941251f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SlateGray = { { { 0.439215720f, 0.501960814f, 0.564705908f, 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 Snow = {{{1.f, 0.980392218f, 0.980392218f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SpringGreen = {{{0.f, 1.f, 0.498039246f, 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 SteelBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 Tan = { { { 0.823529482f, 0.705882370f, 0.549019635f, 1.f } } };
|
{{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 Teal = {{{0.f, 0.501960814f, 0.501960814f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Thistle = { { { 0.847058892f, 0.749019623f, 0.847058892f, 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 Tomato = {{{1.f, 0.388235331f, 0.278431386f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Transparent = {{{0.f, 0.f, 0.f, 0.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 Turquoise = {
|
||||||
XMGLOBALCONST XMVECTORF32 Violet = { { { 0.933333397f, 0.509803951f, 0.933333397f, 1.f } } };
|
{{0.250980407f, 0.878431439f, 0.815686345f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Wheat = { { { 0.960784376f, 0.870588303f, 0.701960802f, 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 White = {{{1.f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 WhiteSmoke = { { { 0.960784376f, 0.960784376f, 0.960784376f, 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 Yellow = {{{1.f, 1.f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 YellowGreen = { { { 0.603921592f, 0.803921640f, 0.196078449f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 YellowGreen = {
|
||||||
|
{{0.603921592f, 0.803921640f, 0.196078449f, 1.f}}};
|
||||||
|
|
||||||
} // namespace Colors
|
} // namespace Colors
|
||||||
|
|
||||||
namespace ColorsLinear
|
namespace ColorsLinear {
|
||||||
{
|
|
||||||
// Standard colors (Red/Green/Blue/Alpha) in linear colorspace
|
// Standard colors (Red/Green/Blue/Alpha) in linear colorspace
|
||||||
XMGLOBALCONST XMVECTORF32 AliceBlue = { { { 0.871367335f, 0.938685894f, 1.f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 AliceBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 AntiqueWhite = { { { 0.955973506f, 0.830770075f, 0.679542601f, 1.f } } };
|
{{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 Aqua = {{{0.f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Aquamarine = { { { 0.212230787f, 1.f, 0.658374965f, 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 Azure = {{{0.871367335f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Beige = { { { 0.913098991f, 0.913098991f, 0.715693772f, 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 Bisque = {{{1.f, 0.775822461f, 0.552011609f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Black = {{{0.f, 0.f, 0.f, 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 BlanchedAlmond = {
|
||||||
|
{{1.f, 0.830770075f, 0.610495746f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Blue = {{{0.f, 0.f, 1.f, 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 BlueViolet = {
|
||||||
XMGLOBALCONST XMVECTORF32 Brown = { { { 0.376262218f, 0.023153365f, 0.023153365f, 1.f } } };
|
{{0.254152179f, 0.024157630f, 0.760524750f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 BurlyWood = { { { 0.730461001f, 0.479320228f, 0.242281199f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Brown = {
|
||||||
XMGLOBALCONST XMVECTORF32 CadetBlue = { { { 0.114435382f, 0.341914445f, 0.351532698f, 1.f } } };
|
{{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 Chartreuse = {{{0.212230787f, 1.f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Chocolate = { { { 0.644479871f, 0.141263321f, 0.012983031f, 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 Coral = {{{1.f, 0.212230787f, 0.080219828f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 CornflowerBlue = { { { 0.127437726f, 0.300543845f, 0.846873462f, 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 Cornsilk = {{{1.f, 0.938685894f, 0.715693772f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Crimson = { { { 0.715693772f, 0.006995410f, 0.045186214f, 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 Cyan = {{{0.f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkBlue = {{{0.f, 0.f, 0.258182913f, 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 DarkCyan = {{{0.f, 0.258182913f, 0.258182913f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = { { { 0.479320228f, 0.238397658f, 0.003346536f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkGoldenrod = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkGray = { { { 0.396755308f, 0.396755308f, 0.396755308f, 1.f } } };
|
{{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 DarkGreen = {{{0.f, 0.127437726f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkKhaki = { { { 0.508881450f, 0.473531544f, 0.147027299f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkKhaki = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkMagenta = { { { 0.258182913f, 0.f, 0.258182913f, 1.f } } };
|
{{0.508881450f, 0.473531544f, 0.147027299f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkOliveGreen = { { { 0.090841733f, 0.147027299f, 0.028426038f, 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 DarkOrange = {{{1.f, 0.262250721f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkOrchid = { { { 0.318546832f, 0.031896040f, 0.603827536f, 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 DarkRed = {{{0.258182913f, 0.f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSalmon = { { { 0.814846814f, 0.304987371f, 0.194617867f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkSalmon = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = { { { 0.274677366f, 0.502886593f, 0.258182913f, 1.f } } };
|
{{0.814846814f, 0.304987371f, 0.194617867f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = { { { 0.064803280f, 0.046665095f, 0.258182913f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkSeaGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkSlateGray = { { { 0.028426038f, 0.078187428f, 0.078187428f, 1.f } } };
|
{{0.274677366f, 0.502886593f, 0.258182913f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DarkTurquoise = { { { 0.f, 0.617206752f, 0.637597024f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DarkSlateBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 DarkViolet = { { { 0.296138316f, 0.f, 0.651405811f, 1.f } } };
|
{{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 DeepPink = {{{1.f, 0.006995410f, 0.291770697f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 DeepSkyBlue = {{{0.f, 0.520995677f, 1.f, 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 DimGray = {
|
||||||
XMGLOBALCONST XMVECTORF32 DodgerBlue = { { { 0.012983031f, 0.278894335f, 1.f, 1.f } } };
|
{{0.141263321f, 0.141263321f, 0.141263321f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Firebrick = { { { 0.445201248f, 0.015996292f, 0.015996292f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 DodgerBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 FloralWhite = { { { 1.f, 0.955973506f, 0.871367335f, 1.f } } };
|
{{0.012983031f, 0.278894335f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 ForestGreen = { { { 0.015996292f, 0.258182913f, 0.015996292f, 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 Fuchsia = {{{1.f, 0.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Gainsboro = { { { 0.715693772f, 0.715693772f, 0.715693772f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Gainsboro = {
|
||||||
XMGLOBALCONST XMVECTORF32 GhostWhite = { { { 0.938685894f, 0.938685894f, 1.f, 1.f } } };
|
{{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 Gold = {{{1.f, 0.679542601f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Goldenrod = { { { 0.701102138f, 0.376262218f, 0.014443844f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Goldenrod = {
|
||||||
XMGLOBALCONST XMVECTORF32 Gray = { { { 0.215860531f, 0.215860531f, 0.215860531f, 1.f } } };
|
{{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 Green = {{{0.f, 0.215860531f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 GreenYellow = { { { 0.417885154f, 1.f, 0.028426038f, 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 Honeydew = {{{0.871367335f, 1.f, 0.871367335f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 HotPink = {{{1.f, 0.141263321f, 0.456411064f, 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 IndianRed = {
|
||||||
|
{{0.610495746f, 0.107023112f, 0.107023112f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Indigo = {{{0.070360109f, 0.f, 0.223227978f, 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 Ivory = {{{1.f, 1.f, 0.871367335f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Khaki = { { { 0.871367335f, 0.791298151f, 0.262250721f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Khaki = {
|
||||||
XMGLOBALCONST XMVECTORF32 Lavender = { { { 0.791298151f, 0.791298151f, 0.955973506f, 1.f } } };
|
{{0.871367335f, 0.791298151f, 0.262250721f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LavenderBlush = { { { 1.f, 0.871367335f, 0.913098991f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Lavender = {
|
||||||
XMGLOBALCONST XMVECTORF32 LawnGreen = { { { 0.201556295f, 0.973445475f, 0.f, 1.f } } };
|
{{0.791298151f, 0.791298151f, 0.955973506f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LemonChiffon = { { { 1.f, 0.955973506f, 0.610495746f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LavenderBlush = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightBlue = { { { 0.417885154f, 0.686685443f, 0.791298151f, 1.f } } };
|
{{1.f, 0.871367335f, 0.913098991f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightCoral = { { { 0.871367335f, 0.215860531f, 0.215860531f, 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 LightCyan = {{{0.745404482f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = { { { 0.955973506f, 0.955973506f, 0.644479871f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightGoldenrodYellow = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightGray = { { { 0.651405811f, 0.651405811f, 0.651405811f, 1.f } } };
|
{{0.955973506f, 0.955973506f, 0.644479871f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightGreen = { { { 0.278894335f, 0.854992807f, 0.278894335f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightGray = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightPink = { { { 1.f, 0.467783839f, 0.533276618f, 1.f } } };
|
{{0.651405811f, 0.651405811f, 0.651405811f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightSalmon = { { { 1.f, 0.351532698f, 0.194617867f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightSeaGreen = { { { 0.014443844f, 0.445201248f, 0.401977867f, 1.f } } };
|
{{0.278894335f, 0.854992807f, 0.278894335f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightSkyBlue = { { { 0.242281199f, 0.617206752f, 0.955973506f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 LightPink = {
|
||||||
XMGLOBALCONST XMVECTORF32 LightSlateGray = { { { 0.184475034f, 0.246201396f, 0.318546832f, 1.f } } };
|
{{1.f, 0.467783839f, 0.533276618f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 LightSteelBlue = { { { 0.434153706f, 0.552011609f, 0.730461001f, 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 LightYellow = {{{1.f, 1.f, 0.745404482f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Lime = {{{0.f, 1.f, 0.f, 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 LimeGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 Linen = { { { 0.955973506f, 0.871367335f, 0.791298151f, 1.f } } };
|
{{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 Magenta = {{{1.f, 0.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Maroon = {{{0.215860531f, 0.f, 0.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 MediumAquamarine = {
|
||||||
|
{{0.132868364f, 0.610495746f, 0.401977867f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumBlue = {{{0.f, 0.f, 0.610495746f, 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 MediumOrchid = {
|
||||||
XMGLOBALCONST XMVECTORF32 MediumPurple = { { { 0.291770697f, 0.162029430f, 0.708376050f, 1.f } } };
|
{{0.491020888f, 0.090841733f, 0.651405811f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = { { { 0.045186214f, 0.450785846f, 0.165132239f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumPurple = {
|
||||||
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = { { { 0.198069349f, 0.138431653f, 0.854992807f, 1.f } } };
|
{{0.291770697f, 0.162029430f, 0.708376050f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = { { { 0.f, 0.955973506f, 0.323143244f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumSeaGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 MediumTurquoise = { { { 0.064803280f, 0.637597024f, 0.603827536f, 1.f } } };
|
{{0.045186214f, 0.450785846f, 0.165132239f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MediumVioletRed = { { { 0.571125031f, 0.007499032f, 0.234550655f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumSlateBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 MidnightBlue = { { { 0.009721218f, 0.009721218f, 0.162029430f, 1.f } } };
|
{{0.198069349f, 0.138431653f, 0.854992807f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 MintCream = { { { 0.913098991f, 1.f, 0.955973506f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 MediumSpringGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 MistyRose = { { { 1.f, 0.775822461f, 0.752942443f, 1.f } } };
|
{{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 Moccasin = {{{1.f, 0.775822461f, 0.462077051f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 NavajoWhite = { { { 1.f, 0.730461001f, 0.417885154f, 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 Navy = {{{0.f, 0.f, 0.215860531f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 OldLace = { { { 0.982250869f, 0.913098991f, 0.791298151f, 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 Olive = {{{0.215860531f, 0.215860531f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 OliveDrab = { { { 0.147027299f, 0.270497859f, 0.016807375f, 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 Orange = {{{1.f, 0.376262218f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 OrangeRed = {{{1.f, 0.059511241f, 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 Orchid = {
|
||||||
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = { { { 0.854992807f, 0.806952477f, 0.401977867f, 1.f } } };
|
{{0.701102138f, 0.162029430f, 0.672443330f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 PaleGreen = { { { 0.313988745f, 0.964686573f, 0.313988745f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 PaleGoldenrod = {
|
||||||
XMGLOBALCONST XMVECTORF32 PaleTurquoise = { { { 0.428690553f, 0.854992807f, 0.854992807f, 1.f } } };
|
{{0.854992807f, 0.806952477f, 0.401977867f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 PaleVioletRed = { { { 0.708376050f, 0.162029430f, 0.291770697f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 PaleGreen = {
|
||||||
XMGLOBALCONST XMVECTORF32 PapayaWhip = { { { 1.f, 0.863157392f, 0.665387452f, 1.f } } };
|
{{0.313988745f, 0.964686573f, 0.313988745f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 PeachPuff = { { { 1.f, 0.701102138f, 0.485149980f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 PaleTurquoise = {
|
||||||
XMGLOBALCONST XMVECTORF32 Peru = { { { 0.610495746f, 0.234550655f, 0.049706575f, 1.f } } };
|
{{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 Pink = {{{1.f, 0.527115345f, 0.597202003f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Plum = { { { 0.723055363f, 0.351532698f, 0.723055363f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Plum = {
|
||||||
XMGLOBALCONST XMVECTORF32 PowderBlue = { { { 0.434153706f, 0.745404482f, 0.791298151f, 1.f } } };
|
{{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 Purple = {{{0.215860531f, 0.f, 0.215860531f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Red = {{{1.f, 0.f, 0.f, 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 RosyBrown = {
|
||||||
XMGLOBALCONST XMVECTORF32 RoyalBlue = { { { 0.052860655f, 0.141263321f, 0.752942443f, 1.f } } };
|
{{0.502886593f, 0.274677366f, 0.274677366f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SaddleBrown = { { { 0.258182913f, 0.059511241f, 0.006512091f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 RoyalBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 Salmon = { { { 0.955973506f, 0.215860531f, 0.168269455f, 1.f } } };
|
{{0.052860655f, 0.141263321f, 0.752942443f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SandyBrown = { { { 0.904661357f, 0.371237785f, 0.116970696f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 SaddleBrown = {
|
||||||
XMGLOBALCONST XMVECTORF32 SeaGreen = { { { 0.027320892f, 0.258182913f, 0.095307484f, 1.f } } };
|
{{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 SeaShell = {{{1.f, 0.913098991f, 0.854992807f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Sienna = { { { 0.351532698f, 0.084376216f, 0.026241222f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Sienna = {
|
||||||
XMGLOBALCONST XMVECTORF32 Silver = { { { 0.527115345f, 0.527115345f, 0.527115345f, 1.f } } };
|
{{0.351532698f, 0.084376216f, 0.026241222f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SkyBlue = { { { 0.242281199f, 0.617206752f, 0.830770075f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 Silver = {
|
||||||
XMGLOBALCONST XMVECTORF32 SlateBlue = { { { 0.144128501f, 0.102241747f, 0.610495746f, 1.f } } };
|
{{0.527115345f, 0.527115345f, 0.527115345f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SlateGray = { { { 0.162029430f, 0.215860531f, 0.278894335f, 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 Snow = {{{1.f, 0.955973506f, 0.955973506f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 SpringGreen = {{{0.f, 1.f, 0.212230787f, 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 SteelBlue = {
|
||||||
XMGLOBALCONST XMVECTORF32 Tan = { { { 0.644479871f, 0.456411064f, 0.262250721f, 1.f } } };
|
{{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 Teal = {{{0.f, 0.215860531f, 0.215860531f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Thistle = { { { 0.686685443f, 0.520995677f, 0.686685443f, 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 Tomato = {{{1.f, 0.124771863f, 0.063010029f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Transparent = {{{0.f, 0.f, 0.f, 0.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 Turquoise = {
|
||||||
XMGLOBALCONST XMVECTORF32 Violet = { { { 0.854992807f, 0.223227978f, 0.854992807f, 1.f } } };
|
{{0.051269468f, 0.745404482f, 0.630757332f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 Wheat = { { { 0.913098991f, 0.730461001f, 0.450785846f, 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 White = {{{1.f, 1.f, 1.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 WhiteSmoke = { { { 0.913098991f, 0.913098991f, 0.913098991f, 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 Yellow = {{{1.f, 1.f, 0.f, 1.f}}};
|
||||||
XMGLOBALCONST XMVECTORF32 YellowGreen = { { { 0.323143244f, 0.610495746f, 0.031896040f, 1.f } } };
|
XMGLOBALCONST XMVECTORF32 YellowGreen = {
|
||||||
|
{{0.323143244f, 0.610495746f, 0.031896040f, 1.f}}};
|
||||||
|
|
||||||
} // namespace ColorsLinear
|
} // namespace ColorsLinear
|
||||||
|
|
||||||
} // namespace DirectX
|
} // namespace DirectX
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
|
|
||||||
typedef struct _RECT
|
typedef struct _RECT {
|
||||||
{
|
|
||||||
LONG left;
|
LONG left;
|
||||||
LONG top;
|
LONG top;
|
||||||
LONG right;
|
LONG right;
|
||||||
|
|
@ -27,15 +26,14 @@ typedef void ID3D11Buffer;
|
||||||
// typedef DWORD (*PTHREAD_START_ROUTINE)( LPVOID lpThreadParameter);
|
// typedef DWORD (*PTHREAD_START_ROUTINE)( LPVOID lpThreadParameter);
|
||||||
// typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
|
// typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
|
||||||
|
|
||||||
// Used only by windows/durango gdraw and UIController. Will be unnecessary once we have our own
|
// Used only by windows/durango gdraw and UIController. Will be unnecessary once
|
||||||
// UIController stubs.
|
// we have our own UIController stubs.
|
||||||
typedef void ID3D11ShaderResourceView;
|
typedef void ID3D11ShaderResourceView;
|
||||||
typedef void ID3D11Resource;
|
typedef void ID3D11Resource;
|
||||||
typedef void ID3D11Texture2D;
|
typedef void ID3D11Texture2D;
|
||||||
typedef void D3D11_TEXTURE2D_DESC;
|
typedef void D3D11_TEXTURE2D_DESC;
|
||||||
|
|
||||||
enum D3D11_BLEND
|
enum D3D11_BLEND {
|
||||||
{
|
|
||||||
D3D11_BLEND_ZERO = 1,
|
D3D11_BLEND_ZERO = 1,
|
||||||
D3D11_BLEND_ONE = 2,
|
D3D11_BLEND_ONE = 2,
|
||||||
D3D11_BLEND_SRC_COLOR = 3,
|
D3D11_BLEND_SRC_COLOR = 3,
|
||||||
|
|
@ -55,9 +53,7 @@ enum D3D11_BLEND
|
||||||
D3D11_BLEND_INV_SRC1_ALPHA = 19
|
D3D11_BLEND_INV_SRC1_ALPHA = 19
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum D3D11_COMPARISON_FUNC {
|
||||||
enum D3D11_COMPARISON_FUNC
|
|
||||||
{
|
|
||||||
D3D11_COMPARISON_NEVER = 1,
|
D3D11_COMPARISON_NEVER = 1,
|
||||||
D3D11_COMPARISON_LESS = 2,
|
D3D11_COMPARISON_LESS = 2,
|
||||||
D3D11_COMPARISON_EQUAL = 3,
|
D3D11_COMPARISON_EQUAL = 3,
|
||||||
|
|
|
||||||
|
|
@ -3,38 +3,38 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "../../Windows64/Iggy/include/iggy.h"
|
#include "../../Windows64/Iggy/include/iggy.h"
|
||||||
|
|
||||||
#define STUBBED {}
|
#define STUBBED \
|
||||||
|
{ \
|
||||||
|
}
|
||||||
|
|
||||||
RADEXPFUNC inline IggyValuePath* RADEXPLINK IggyPlayerRootPath(Iggy* f) {
|
RADEXPFUNC inline IggyValuePath* RADEXPLINK IggyPlayerRootPath(Iggy* f) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RADEXPFUNC inline IggyResult RADEXPLINK IggyPlayerCallMethodRS(Iggy *f, IggyDataValue *result, IggyValuePath *target, IggyName methodname, S32 numargs, IggyDataValue *args) {
|
RADEXPFUNC inline IggyResult RADEXPLINK
|
||||||
|
IggyPlayerCallMethodRS(Iggy* f, IggyDataValue* result, IggyValuePath* target,
|
||||||
|
IggyName methodname, S32 numargs, IggyDataValue* args) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return IGGY_RESULT_SUCCESS;
|
return IGGY_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerDestroy(Iggy *player) {
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerDestroy(Iggy* player) { STUBBED; }
|
||||||
STUBBED;
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetDisplaySize(Iggy* f, S32 w,
|
||||||
}
|
S32 h) {
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetDisplaySize(Iggy *f, S32 w, S32 h) {
|
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
|
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesStart(Iggy *f) {
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesStart(Iggy* f) { STUBBED; }
|
||||||
STUBBED;
|
|
||||||
}
|
|
||||||
|
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTile(Iggy *f, S32 x0, S32 y0, S32 x1, S32 y1, S32 padding) {
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTile(Iggy* f, S32 x0, S32 y0,
|
||||||
STUBBED;
|
S32 x1, S32 y1,
|
||||||
}
|
S32 padding) {
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesEnd(Iggy *f) {
|
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerDrawTilesEnd(Iggy* f) { STUBBED; }
|
||||||
|
|
||||||
// Each fake Iggy player gets its own state block
|
// Each fake Iggy player gets its own state block
|
||||||
struct FakeIggyPlayer {
|
struct FakeIggyPlayer {
|
||||||
|
|
@ -49,9 +49,7 @@ static FakeIggyPlayer s_fakePlayers[64];
|
||||||
static int s_fakePlayerCount = 0;
|
static int s_fakePlayerCount = 0;
|
||||||
|
|
||||||
RADEXPFUNC inline Iggy* RADEXPLINK IggyPlayerCreateFromMemory(
|
RADEXPFUNC inline Iggy* RADEXPLINK IggyPlayerCreateFromMemory(
|
||||||
void const * data,
|
void const* data, U32 data_size_in_bytes, IggyPlayerConfig* config) {
|
||||||
U32 data_size_in_bytes,
|
|
||||||
IggyPlayerConfig *config) {
|
|
||||||
if (s_fakePlayerCount >= 64) return nullptr;
|
if (s_fakePlayerCount >= 64) return nullptr;
|
||||||
FakeIggyPlayer* fp = &s_fakePlayers[s_fakePlayerCount++];
|
FakeIggyPlayer* fp = &s_fakePlayers[s_fakePlayerCount++];
|
||||||
fp->tickCount = 0;
|
fp->tickCount = 0;
|
||||||
|
|
@ -63,7 +61,8 @@ RADEXPFUNC inline Iggy * RADEXPLINK IggyPlayerCreateFromMemory(
|
||||||
fp->props.movie_height_in_pixels = 1080;
|
fp->props.movie_height_in_pixels = 1080;
|
||||||
fp->props.movie_frame_rate_from_file_in_fps = 30.0f;
|
fp->props.movie_frame_rate_from_file_in_fps = 30.0f;
|
||||||
fp->props.movie_frame_rate_current_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);
|
fprintf(stderr, "[Iggy Stub] Created fake player %d (data=%p, size=%u)\n",
|
||||||
|
s_fakePlayerCount - 1, data, data_size_in_bytes);
|
||||||
return (Iggy*)fp;
|
return (Iggy*)fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,24 +72,32 @@ static FakeIggyPlayer* getFakePlayer(Iggy *player) {
|
||||||
|
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerInitializeAndTickRS(Iggy* player) {
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerInitializeAndTickRS(Iggy* player) {
|
||||||
FakeIggyPlayer* fp = getFakePlayer(player);
|
FakeIggyPlayer* fp = getFakePlayer(player);
|
||||||
if(fp) { fp->tickCount = 0; fp->needsTick = true; }
|
if (fp) {
|
||||||
|
fp->tickCount = 0;
|
||||||
|
fp->needsTick = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RADEXPFUNC inline IggyProperties * RADEXPLINK IggyPlayerProperties(Iggy *player) {
|
RADEXPFUNC inline IggyProperties* RADEXPLINK
|
||||||
|
IggyPlayerProperties(Iggy* player) {
|
||||||
FakeIggyPlayer* fp = getFakePlayer(player);
|
FakeIggyPlayer* fp = getFakePlayer(player);
|
||||||
if (fp) return &fp->props;
|
if (fp) return &fp->props;
|
||||||
static IggyProperties defaultProps = {};
|
static IggyProperties defaultProps = {};
|
||||||
return &defaultProps;
|
return &defaultProps;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetUserdata(Iggy *player, void *userdata) {
|
RADEXPFUNC inline void RADEXPLINK IggyPlayerSetUserdata(Iggy* player,
|
||||||
|
void* userdata) {
|
||||||
FakeIggyPlayer* fp = getFakePlayer(player);
|
FakeIggyPlayer* fp = getFakePlayer(player);
|
||||||
if (fp) fp->userdata = userdata;
|
if (fp) fp->userdata = userdata;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline IggyName RADEXPLINK IggyPlayerCreateFastName(Iggy *f, IggyUTF16 const *name, S32 len) {
|
RADEXPFUNC inline IggyName RADEXPLINK
|
||||||
|
IggyPlayerCreateFastName(Iggy* f, IggyUTF16 const* name, S32 len) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline rrbool RADEXPLINK IggyDebugGetMemoryUseInfo(Iggy *player, IggyLibrary lib, char const *category_string, S32 category_stringlen, S32 iteration, IggyMemoryUseInfo *data) {
|
RADEXPFUNC inline rrbool RADEXPLINK IggyDebugGetMemoryUseInfo(
|
||||||
|
Iggy* player, IggyLibrary lib, char const* category_string,
|
||||||
|
S32 category_stringlen, S32 iteration, IggyMemoryUseInfo* data) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -112,69 +119,97 @@ RADEXPFUNC inline void RADEXPLINK IggyPlayerDraw(Iggy *f) {
|
||||||
FakeIggyPlayer* fp = getFakePlayer(f);
|
FakeIggyPlayer* fp = getFakePlayer(f);
|
||||||
if (fp) fp->needsTick = true;
|
if (fp) fp->needsTick = true;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyMakeEventKey(IggyEvent *event, IggyKeyevent event_type, IggyKeycode keycode, IggyKeyloc keyloc) {
|
RADEXPFUNC inline void RADEXPLINK IggyMakeEventKey(IggyEvent* event,
|
||||||
|
IggyKeyevent event_type,
|
||||||
|
IggyKeycode keycode,
|
||||||
|
IggyKeyloc keyloc) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline rrbool RADEXPLINK IggyPlayerDispatchEventRS(Iggy *player, IggyEvent *event, IggyEventResult *result) {
|
RADEXPFUNC inline rrbool RADEXPLINK IggyPlayerDispatchEventRS(
|
||||||
|
Iggy* player, IggyEvent* event, IggyEventResult* result) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyFontRemoveUTF8(const char *fontname, S32 namelen_in_bytes, U32 fontflags) {
|
RADEXPFUNC inline void RADEXPLINK IggyFontRemoveUTF8(const char* fontname,
|
||||||
|
S32 namelen_in_bytes,
|
||||||
|
U32 fontflags) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyFontInstallBitmapUTF8(const IggyBitmapFontProvider *bmf, const char *fontname, S32 namelen_in_bytes, U32 fontflags) {
|
RADEXPFUNC inline void RADEXPLINK IggyFontInstallBitmapUTF8(
|
||||||
|
const IggyBitmapFontProvider* bmf, const char* fontname,
|
||||||
|
S32 namelen_in_bytes, U32 fontflags) {
|
||||||
STUBBED;
|
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) {
|
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;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeUTF8(const void *truetype_storage, S32 ttc_index, const char *fontname, S32 namelen_in_bytes, U32 fontflags) {
|
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeUTF8(
|
||||||
|
const void* truetype_storage, S32 ttc_index, const char* fontname,
|
||||||
|
S32 namelen_in_bytes, U32 fontflags) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline rrbool RADEXPLINK IggyValuePathMakeNameRef(IggyValuePath *result, IggyValuePath *parent, char const *text_utf8) {
|
RADEXPFUNC inline rrbool RADEXPLINK IggyValuePathMakeNameRef(
|
||||||
|
IggyValuePath* result, IggyValuePath* parent, char const* text_utf8) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline IggyResult RADEXPLINK IggyValueGetBooleanRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, rrbool *result) {
|
RADEXPFUNC inline IggyResult RADEXPLINK
|
||||||
|
IggyValueGetBooleanRS(IggyValuePath* var, IggyName sub_name,
|
||||||
|
char const* sub_name_utf8, rrbool* result) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return IGGY_RESULT_SUCCESS;
|
return IGGY_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeFallbackCodepointUTF8(const char *fontname, S32 len, U32 fontflags, S32 fallback_codepoint) {
|
RADEXPFUNC inline void RADEXPLINK IggyFontInstallTruetypeFallbackCodepointUTF8(
|
||||||
|
const char* fontname, S32 len, U32 fontflags, S32 fallback_codepoint) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline IggyResult RADEXPLINK IggyValueGetF64RS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, F64 *result) {
|
RADEXPFUNC inline IggyResult RADEXPLINK
|
||||||
|
IggyValueGetF64RS(IggyValuePath* var, IggyName sub_name,
|
||||||
|
char const* sub_name_utf8, F64* result) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return IGGY_RESULT_SUCCESS;
|
return IGGY_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline rrbool RADEXPLINK IggyValueSetBooleanRS(IggyValuePath *var, IggyName sub_name, char const *sub_name_utf8, rrbool value) {
|
RADEXPFUNC inline rrbool RADEXPLINK
|
||||||
|
IggyValueSetBooleanRS(IggyValuePath* var, IggyName sub_name,
|
||||||
|
char const* sub_name_utf8, rrbool value) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyInit(IggyAllocator* allocator) {
|
RADEXPFUNC inline void RADEXPLINK IggyInit(IggyAllocator* allocator) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggySetWarningCallback(Iggy_WarningFunction *error, void *user_callback_data) {
|
RADEXPFUNC inline void RADEXPLINK
|
||||||
|
IggySetWarningCallback(Iggy_WarningFunction* error, void* user_callback_data) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggySetTraceCallbackUTF8(Iggy_TraceFunctionUTF8 *trace_utf8, void *user_callback_data) {
|
RADEXPFUNC inline void RADEXPLINK IggySetTraceCallbackUTF8(
|
||||||
|
Iggy_TraceFunctionUTF8* trace_utf8, void* user_callback_data) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggySetFontCachingCalculationBuffer(
|
RADEXPFUNC inline void RADEXPLINK
|
||||||
S32 max_chars,
|
IggySetFontCachingCalculationBuffer(S32 max_chars, void* optional_temp_buffer,
|
||||||
void *optional_temp_buffer,
|
|
||||||
S32 optional_temp_buffer_size_in_bytes) {
|
S32 optional_temp_buffer_size_in_bytes) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggySetCustomDrawCallback(Iggy_CustomDrawCallback *custom_draw, void *user_callback_data) {
|
RADEXPFUNC inline void RADEXPLINK IggySetCustomDrawCallback(
|
||||||
|
Iggy_CustomDrawCallback* custom_draw, void* user_callback_data) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggySetAS3ExternalFunctionCallbackUTF16(Iggy_AS3ExternalFunctionUTF16 *as3_external_function_utf16, void *user_callback_data) {
|
RADEXPFUNC inline void RADEXPLINK IggySetAS3ExternalFunctionCallbackUTF16(
|
||||||
|
Iggy_AS3ExternalFunctionUTF16* as3_external_function_utf16,
|
||||||
|
void* user_callback_data) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyMakeEventMouseMove(IggyEvent *event, S32 x, S32 y) {
|
RADEXPFUNC inline void RADEXPLINK IggyMakeEventMouseMove(IggyEvent* event,
|
||||||
|
S32 x, S32 y) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggySetTextureSubstitutionCallbacks(Iggy_TextureSubstitutionCreateCallback *texture_create, Iggy_TextureSubstitutionDestroyCallback *texture_destroy, void *user_callback_data) {
|
RADEXPFUNC inline void RADEXPLINK IggySetTextureSubstitutionCallbacks(
|
||||||
|
Iggy_TextureSubstitutionCreateCallback* texture_create,
|
||||||
|
Iggy_TextureSubstitutionDestroyCallback* texture_destroy,
|
||||||
|
void* user_callback_data) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void* RADEXPLINK IggyPlayerGetUserdata(Iggy* player) {
|
RADEXPFUNC inline void* RADEXPLINK IggyPlayerGetUserdata(Iggy* player) {
|
||||||
|
|
@ -183,10 +218,8 @@ RADEXPFUNC inline void * RADEXPLINK IggyPlayerGetUserdata(Iggy *player) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline IggyLibrary RADEXPLINK IggyLibraryCreateFromMemoryUTF16(
|
RADEXPFUNC inline IggyLibrary RADEXPLINK IggyLibraryCreateFromMemoryUTF16(
|
||||||
IggyUTF16 const * url_utf16_null_terminated,
|
IggyUTF16 const* url_utf16_null_terminated, void const* data,
|
||||||
void const * data,
|
U32 data_size_in_bytes, IggyPlayerConfig* config) {
|
||||||
U32 data_size_in_bytes,
|
|
||||||
IggyPlayerConfig *config) {
|
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -201,25 +234,25 @@ RADEXPFUNC inline void RADEXPLINK IggySetGDraw(GDrawFunctions *gdraw_funcs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio stubs
|
// Audio stubs
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyAudioUseDefault(void) {
|
RADEXPFUNC inline void RADEXPLINK IggyAudioUseDefault(void) { STUBBED; }
|
||||||
STUBBED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Explorer/Perfmon, shit implmentation
|
// Explorer/Perfmon, shit implmentation
|
||||||
RADEXPFUNC inline void * RADEXPLINK IggyExpCreate(const char *host, int port, void *storage, int storage_size) {
|
RADEXPFUNC inline void* RADEXPLINK IggyExpCreate(const char* host, int port,
|
||||||
|
void* storage,
|
||||||
|
int storage_size) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyUseExplorer(Iggy *player, void *explorer) {
|
RADEXPFUNC inline void RADEXPLINK IggyUseExplorer(Iggy* player,
|
||||||
|
void* explorer) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void * RADEXPLINK IggyPerfmonCreate(void *(*alloc_func)(unsigned long), void (*free_func)(void *), void *user) {
|
RADEXPFUNC inline void* RADEXPLINK IggyPerfmonCreate(
|
||||||
|
void* (*alloc_func)(unsigned long), void (*free_func)(void*), void* user) {
|
||||||
STUBBED;
|
STUBBED;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
RADEXPFUNC inline void RADEXPLINK IggyInstallPerfmon(void *perfmon) {
|
RADEXPFUNC inline void RADEXPLINK IggyInstallPerfmon(void* perfmon) { STUBBED; }
|
||||||
STUBBED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GDraw memory/warning functions are defined in gdraw_glfw.c (C linkage)
|
// 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
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,8 @@ typedef float FLOAT;
|
||||||
#define MEM_HEAP 0x40000000
|
#define MEM_HEAP 0x40000000
|
||||||
#define MEM_16MB_PAGES 0x80000000
|
#define MEM_16MB_PAGES 0x80000000
|
||||||
|
|
||||||
#define THREAD_BASE_PRIORITY_LOWRT 15 // value that gets a thread to LowRealtime-1
|
#define THREAD_BASE_PRIORITY_LOWRT \
|
||||||
|
15 // value that gets a thread to LowRealtime-1
|
||||||
#define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
|
#define THREAD_BASE_PRIORITY_MAX 2 // maximum thread base priority boost
|
||||||
#define THREAD_BASE_PRIORITY_MIN -2 // minimum thread base priority boost
|
#define THREAD_BASE_PRIORITY_MIN -2 // minimum thread base priority boost
|
||||||
#define THREAD_BASE_PRIORITY_IDLE -15 // value that gets a thread to idle
|
#define THREAD_BASE_PRIORITY_IDLE -15 // value that gets a thread to idle
|
||||||
|
|
@ -171,7 +172,6 @@ typedef float FLOAT;
|
||||||
#define STATUS_PENDING ((DWORD)0x00000103L)
|
#define STATUS_PENDING ((DWORD)0x00000103L)
|
||||||
#define STILL_ACTIVE STATUS_PENDING
|
#define STILL_ACTIVE STATUS_PENDING
|
||||||
|
|
||||||
|
|
||||||
#define INVALID_HANDLE_VALUE ((HANDLE)(ULONG_PTR) - 1)
|
#define INVALID_HANDLE_VALUE ((HANDLE)(ULONG_PTR) - 1)
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
|
// https://learn.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime
|
||||||
|
|
@ -257,9 +257,11 @@ typedef HINSTANCE HMODULE;
|
||||||
|
|
||||||
#define FAILED(Status) ((HRESULT)(Status) < 0)
|
#define FAILED(Status) ((HRESULT)(Status) < 0)
|
||||||
#define MAKE_HRESULT(sev, fac, code) \
|
#define MAKE_HRESULT(sev, fac, code) \
|
||||||
((HRESULT) (((unsigned int)(sev)<<31) | ((unsigned int)(fac)<<16) | ((unsigned int)(code))) )
|
((HRESULT)(((unsigned int)(sev) << 31) | ((unsigned int)(fac) << 16) | \
|
||||||
|
((unsigned int)(code))))
|
||||||
#define MAKE_SCODE(sev, fac, code) \
|
#define MAKE_SCODE(sev, fac, code) \
|
||||||
((SCODE) (((unsigned int)(sev)<<31) | ((unsigned int)(fac)<<16) | ((unsigned int)(code))) )
|
((SCODE)(((unsigned int)(sev) << 31) | ((unsigned int)(fac) << 16) | \
|
||||||
|
((unsigned int)(code))))
|
||||||
#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L)
|
#define E_FAIL _HRESULT_TYPEDEF_(0x80004005L)
|
||||||
#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L)
|
#define E_ABORT _HRESULT_TYPEDEF_(0x80004004L)
|
||||||
#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L)
|
#define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002L)
|
||||||
|
|
@ -271,8 +273,8 @@ typedef RTL_CRITICAL_SECTION CRITICAL_SECTION;
|
||||||
typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
|
typedef PRTL_CRITICAL_SECTION PCRITICAL_SECTION;
|
||||||
typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
|
typedef PRTL_CRITICAL_SECTION LPCRITICAL_SECTION;
|
||||||
|
|
||||||
static inline void InitializeCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
static inline void InitializeCriticalSection(
|
||||||
{
|
PRTL_CRITICAL_SECTION CriticalSection) {
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
pthread_mutexattr_init(&attr);
|
pthread_mutexattr_init(&attr);
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
|
@ -280,73 +282,61 @@ static inline void InitializeCriticalSection(PRTL_CRITICAL_SECTION CriticalSecti
|
||||||
pthread_mutexattr_destroy(&attr);
|
pthread_mutexattr_destroy(&attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void InitializeCriticalSectionAndSpinCount(PRTL_CRITICAL_SECTION CriticalSection, ULONG SpinCount)
|
static inline void InitializeCriticalSectionAndSpinCount(
|
||||||
{
|
PRTL_CRITICAL_SECTION CriticalSection, ULONG SpinCount) {
|
||||||
// no spin count required because we use a recursive mutex
|
// no spin count required because we use a recursive mutex
|
||||||
InitializeCriticalSection(CriticalSection);
|
InitializeCriticalSection(CriticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void DeleteCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
static inline void DeleteCriticalSection(
|
||||||
{
|
PRTL_CRITICAL_SECTION CriticalSection) {
|
||||||
pthread_mutex_destroy(CriticalSection);
|
pthread_mutex_destroy(CriticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void EnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
static inline void EnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection) {
|
||||||
{
|
|
||||||
pthread_mutex_lock(CriticalSection);
|
pthread_mutex_lock(CriticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LeaveCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
static inline void LeaveCriticalSection(PRTL_CRITICAL_SECTION CriticalSection) {
|
||||||
{
|
|
||||||
pthread_mutex_unlock(CriticalSection);
|
pthread_mutex_unlock(CriticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ULONG TryEnterCriticalSection(PRTL_CRITICAL_SECTION CriticalSection)
|
static inline ULONG TryEnterCriticalSection(
|
||||||
{
|
PRTL_CRITICAL_SECTION CriticalSection) {
|
||||||
return pthread_mutex_trylock(CriticalSection) == 0;
|
return pthread_mutex_trylock(CriticalSection) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsalloc
|
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsalloc
|
||||||
static inline DWORD TlsAlloc(VOID)
|
static inline DWORD TlsAlloc(VOID) {
|
||||||
{
|
|
||||||
pthread_key_t key;
|
pthread_key_t key;
|
||||||
if (pthread_key_create(&key, NULL) == 0)
|
if (pthread_key_create(&key, NULL) == 0) return key;
|
||||||
return key;
|
|
||||||
return TLS_OUT_OF_INDEXES;
|
return TLS_OUT_OF_INDEXES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsfree
|
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsfree
|
||||||
static inline BOOL TlsFree(DWORD dwTlsIndex)
|
static inline BOOL TlsFree(DWORD dwTlsIndex) {
|
||||||
{
|
|
||||||
return pthread_key_delete(dwTlsIndex) == 0;
|
return pthread_key_delete(dwTlsIndex) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsgetvalue
|
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsgetvalue
|
||||||
static inline LPVOID TlsGetValue(DWORD dwTlsIndex)
|
static inline LPVOID TlsGetValue(DWORD dwTlsIndex) {
|
||||||
{
|
|
||||||
return pthread_getspecific(dwTlsIndex);
|
return pthread_getspecific(dwTlsIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlssetvalue
|
// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlssetvalue
|
||||||
static inline BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
|
static inline BOOL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue) {
|
||||||
{
|
|
||||||
return pthread_setspecific(dwTlsIndex, lpTlsValue) == 0;
|
return pthread_setspecific(dwTlsIndex, lpTlsValue) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalmemorystatus
|
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalmemorystatus
|
||||||
static inline VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer)
|
static inline VOID GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer) {
|
||||||
{
|
// TODO: Parse /proc/meminfo and set lpBuffer based on that. Probably will
|
||||||
// TODO: Parse /proc/meminfo and set lpBuffer based on that. Probably will also need another
|
// also need another different codepath for macOS too.
|
||||||
// different codepath for macOS too.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD GetLastError(VOID)
|
static inline DWORD GetLastError(VOID) { return errno; }
|
||||||
{
|
|
||||||
return errno;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline VOID Sleep(DWORD dwMilliseconds)
|
static inline VOID Sleep(DWORD dwMilliseconds) {
|
||||||
{
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
ts.tv_nsec = (dwMilliseconds * 1000000) % 1000000000;
|
ts.tv_nsec = (dwMilliseconds * 1000000) % 1000000000;
|
||||||
ts.tv_sec = dwMilliseconds / 1000;
|
ts.tv_sec = dwMilliseconds / 1000;
|
||||||
|
|
@ -358,18 +348,16 @@ static inline VOID Sleep(DWORD dwMilliseconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline LONG64 InterlockedCompareExchangeRelease64(
|
static inline LONG64 InterlockedCompareExchangeRelease64(
|
||||||
LONG64 volatile *Destination,
|
LONG64 volatile* Destination, LONG64 Exchange, LONG64 Comperand) {
|
||||||
LONG64 Exchange,
|
|
||||||
LONG64 Comperand)
|
|
||||||
{
|
|
||||||
LONG64 expected = Comperand;
|
LONG64 expected = Comperand;
|
||||||
__atomic_compare_exchange_n(Destination, &expected, Exchange, false, __ATOMIC_RELEASE, __ATOMIC_RELAXED);
|
__atomic_compare_exchange_n(Destination, &expected, Exchange, false,
|
||||||
|
__ATOMIC_RELEASE, __ATOMIC_RELAXED);
|
||||||
return expected;
|
return expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helper: convert time_t to FILETIME (100ns intervals since 1601-01-01)
|
// internal helper: convert time_t to FILETIME (100ns intervals since
|
||||||
static inline FILETIME _TimeToFileTime(time_t t)
|
// 1601-01-01)
|
||||||
{
|
static inline FILETIME _TimeToFileTime(time_t t) {
|
||||||
const ULONGLONG EPOCH_DIFF = 11644473600ULL;
|
const ULONGLONG EPOCH_DIFF = 11644473600ULL;
|
||||||
ULONGLONG val = ((ULONGLONG)t + EPOCH_DIFF) * 10000000ULL;
|
ULONGLONG val = ((ULONGLONG)t + EPOCH_DIFF) * 10000000ULL;
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
|
|
@ -379,11 +367,13 @@ static inline FILETIME _TimeToFileTime(time_t t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helper: fill WIN32_FIND_DATAA from stat + name
|
// internal helper: fill WIN32_FIND_DATAA from stat + name
|
||||||
static inline void _FillFindData(const char *name, const struct stat *st, WIN32_FIND_DATAA *out)
|
static inline void _FillFindData(const char* name, const struct stat* st,
|
||||||
{
|
WIN32_FIND_DATAA* out) {
|
||||||
memset(out, 0, sizeof(*out));
|
memset(out, 0, sizeof(*out));
|
||||||
out->dwFileAttributes = S_ISDIR(st->st_mode) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
|
out->dwFileAttributes =
|
||||||
if (!(st->st_mode & S_IWUSR)) out->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
|
S_ISDIR(st->st_mode) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
|
||||||
|
if (!(st->st_mode & S_IWUSR))
|
||||||
|
out->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
|
||||||
if (name[0] == '.') out->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
|
if (name[0] == '.') out->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
out->ftCreationTime = _TimeToFileTime(st->st_mtime);
|
out->ftCreationTime = _TimeToFileTime(st->st_mtime);
|
||||||
out->ftLastAccessTime = _TimeToFileTime(st->st_atime);
|
out->ftLastAccessTime = _TimeToFileTime(st->st_atime);
|
||||||
|
|
@ -393,116 +383,158 @@ static inline void _FillFindData(const char *name, const struct stat *st, WIN32_
|
||||||
strncpy(out->cFileName, name, MAX_PATH - 1);
|
strncpy(out->cFileName, name, MAX_PATH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HANDLE CreateFileA(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
static inline HANDLE CreateFileA(const char* lpFileName, DWORD dwDesiredAccess,
|
||||||
void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
DWORD dwShareMode, void* lpSecurityAttributes,
|
||||||
{
|
DWORD dwCreationDisposition,
|
||||||
|
DWORD dwFlagsAndAttributes,
|
||||||
|
HANDLE hTemplateFile) {
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if ((dwDesiredAccess & GENERIC_READ) && (dwDesiredAccess & GENERIC_WRITE)) flags = O_RDWR;
|
if ((dwDesiredAccess & GENERIC_READ) && (dwDesiredAccess & GENERIC_WRITE))
|
||||||
else if (dwDesiredAccess & GENERIC_WRITE) flags = O_WRONLY;
|
flags = O_RDWR;
|
||||||
else flags = O_RDONLY;
|
else if (dwDesiredAccess & GENERIC_WRITE)
|
||||||
|
flags = O_WRONLY;
|
||||||
|
else
|
||||||
|
flags = O_RDONLY;
|
||||||
|
|
||||||
switch (dwCreationDisposition)
|
switch (dwCreationDisposition) {
|
||||||
{
|
case CREATE_NEW:
|
||||||
case CREATE_NEW: flags |= O_CREAT | O_EXCL; break;
|
flags |= O_CREAT | O_EXCL;
|
||||||
case CREATE_ALWAYS: flags |= O_CREAT | O_TRUNC; break;
|
break;
|
||||||
case OPEN_EXISTING: break;
|
case CREATE_ALWAYS:
|
||||||
case OPEN_ALWAYS: flags |= O_CREAT; break;
|
flags |= O_CREAT | O_TRUNC;
|
||||||
case TRUNCATE_EXISTING: flags |= O_TRUNC; break;
|
break;
|
||||||
|
case OPEN_EXISTING:
|
||||||
|
break;
|
||||||
|
case OPEN_ALWAYS:
|
||||||
|
flags |= O_CREAT;
|
||||||
|
break;
|
||||||
|
case TRUNCATE_EXISTING:
|
||||||
|
flags |= O_TRUNC;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fd = open(lpFileName, flags, 0644);
|
int fd = open(lpFileName, flags, 0644);
|
||||||
return fd == -1 ? INVALID_HANDLE_VALUE : (HANDLE)(intptr_t)fd;
|
return fd == -1 ? INVALID_HANDLE_VALUE : (HANDLE)(intptr_t)fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HANDLE CreateFileW(const wchar_t *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
static inline HANDLE CreateFileW(const wchar_t* lpFileName,
|
||||||
void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||||
{
|
void* lpSecurityAttributes,
|
||||||
|
DWORD dwCreationDisposition,
|
||||||
|
DWORD dwFlagsAndAttributes,
|
||||||
|
HANDLE hTemplateFile) {
|
||||||
char narrowBuf[1024];
|
char narrowBuf[1024];
|
||||||
wcstombs(narrowBuf, lpFileName, sizeof(narrowBuf));
|
wcstombs(narrowBuf, lpFileName, sizeof(narrowBuf));
|
||||||
narrowBuf[sizeof(narrowBuf) - 1] = '\0';
|
narrowBuf[sizeof(narrowBuf) - 1] = '\0';
|
||||||
return CreateFileA(narrowBuf, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
return CreateFileA(narrowBuf, dwDesiredAccess, dwShareMode,
|
||||||
|
lpSecurityAttributes, dwCreationDisposition,
|
||||||
|
dwFlagsAndAttributes, hTemplateFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HANDLE CreateFile(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
static inline HANDLE CreateFile(const char* lpFileName, DWORD dwDesiredAccess,
|
||||||
void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
DWORD dwShareMode, void* lpSecurityAttributes,
|
||||||
{
|
DWORD dwCreationDisposition,
|
||||||
return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
DWORD dwFlagsAndAttributes,
|
||||||
|
HANDLE hTemplateFile) {
|
||||||
|
return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode,
|
||||||
|
lpSecurityAttributes, dwCreationDisposition,
|
||||||
|
dwFlagsAndAttributes, hTemplateFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HANDLE CreateFile(const wchar_t *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
static inline HANDLE CreateFile(const wchar_t* lpFileName,
|
||||||
void *lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
|
DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||||
{
|
void* lpSecurityAttributes,
|
||||||
return CreateFileW(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
DWORD dwCreationDisposition,
|
||||||
|
DWORD dwFlagsAndAttributes,
|
||||||
|
HANDLE hTemplateFile) {
|
||||||
|
return CreateFileW(lpFileName, dwDesiredAccess, dwShareMode,
|
||||||
|
lpSecurityAttributes, dwCreationDisposition,
|
||||||
|
dwFlagsAndAttributes, hTemplateFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL CloseHandle(HANDLE hObject)
|
static inline BOOL CloseHandle(HANDLE hObject) {
|
||||||
{
|
|
||||||
if (hObject == INVALID_HANDLE_VALUE) return FALSE;
|
if (hObject == INVALID_HANDLE_VALUE) return FALSE;
|
||||||
return close((int)(intptr_t)hObject) == 0;
|
return close((int)(intptr_t)hObject) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD GetFileSize(HANDLE hFile, DWORD *lpFileSizeHigh)
|
static inline DWORD GetFileSize(HANDLE hFile, DWORD* lpFileSizeHigh) {
|
||||||
{
|
|
||||||
struct stat st{};
|
struct stat st{};
|
||||||
if (fstat((int)(intptr_t)hFile, &st) != 0) { if (lpFileSizeHigh) *lpFileSizeHigh = 0; return INVALID_FILE_SIZE; }
|
if (fstat((int)(intptr_t)hFile, &st) != 0) {
|
||||||
if (lpFileSizeHigh) *lpFileSizeHigh = (DWORD)((st.st_size >> 32) & 0xFFFFFFFF);
|
if (lpFileSizeHigh) *lpFileSizeHigh = 0;
|
||||||
|
return INVALID_FILE_SIZE;
|
||||||
|
}
|
||||||
|
if (lpFileSizeHigh)
|
||||||
|
*lpFileSizeHigh = (DWORD)((st.st_size >> 32) & 0xFFFFFFFF);
|
||||||
return (DWORD)(st.st_size & 0xFFFFFFFF);
|
return (DWORD)(st.st_size & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL GetFileSizeEx(HANDLE hFile, LARGE_INTEGER *lpFileSize)
|
static inline BOOL GetFileSizeEx(HANDLE hFile, LARGE_INTEGER* lpFileSize) {
|
||||||
{
|
|
||||||
struct stat st{};
|
struct stat st{};
|
||||||
if (fstat((int)(intptr_t)hFile, &st) != 0) return FALSE;
|
if (fstat((int)(intptr_t)hFile, &st) != 0) return FALSE;
|
||||||
if (lpFileSize) { lpFileSize->QuadPart = st.st_size; lpFileSize->LowPart = (DWORD)(st.st_size & 0xFFFFFFFF); lpFileSize->HighPart = (LONG)(st.st_size >> 32); }
|
if (lpFileSize) {
|
||||||
|
lpFileSize->QuadPart = st.st_size;
|
||||||
|
lpFileSize->LowPart = (DWORD)(st.st_size & 0xFFFFFFFF);
|
||||||
|
lpFileSize->HighPart = (LONG)(st.st_size >> 32);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL ReadFile(HANDLE hFile, void *lpBuffer, DWORD nNumberOfBytesToRead, DWORD *lpNumberOfBytesRead, void *lpOverlapped)
|
static inline BOOL ReadFile(HANDLE hFile, void* lpBuffer,
|
||||||
{
|
DWORD nNumberOfBytesToRead,
|
||||||
|
DWORD* lpNumberOfBytesRead, void* lpOverlapped) {
|
||||||
ssize_t n = read((int)(intptr_t)hFile, lpBuffer, nNumberOfBytesToRead);
|
ssize_t n = read((int)(intptr_t)hFile, lpBuffer, nNumberOfBytesToRead);
|
||||||
if (lpNumberOfBytesRead) *lpNumberOfBytesRead = n >= 0 ? (DWORD)n : 0;
|
if (lpNumberOfBytesRead) *lpNumberOfBytesRead = n >= 0 ? (DWORD)n : 0;
|
||||||
return n >= 0;
|
return n >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL WriteFile(HANDLE hFile, const void *lpBuffer, DWORD nNumberOfBytesToWrite, DWORD *lpNumberOfBytesWritten, void *lpOverlapped)
|
static inline BOOL WriteFile(HANDLE hFile, const void* lpBuffer,
|
||||||
{
|
DWORD nNumberOfBytesToWrite,
|
||||||
|
DWORD* lpNumberOfBytesWritten,
|
||||||
|
void* lpOverlapped) {
|
||||||
ssize_t n = write((int)(intptr_t)hFile, lpBuffer, nNumberOfBytesToWrite);
|
ssize_t n = write((int)(intptr_t)hFile, lpBuffer, nNumberOfBytesToWrite);
|
||||||
if (lpNumberOfBytesWritten) *lpNumberOfBytesWritten = n >= 0 ? (DWORD)n : 0;
|
if (lpNumberOfBytesWritten) *lpNumberOfBytesWritten = n >= 0 ? (DWORD)n : 0;
|
||||||
return n >= 0;
|
return n >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove, LONG *lpDistanceToMoveHigh, DWORD dwMoveMethod)
|
static inline DWORD SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
|
||||||
{
|
LONG* lpDistanceToMoveHigh,
|
||||||
|
DWORD dwMoveMethod) {
|
||||||
off_t offset = lDistanceToMove;
|
off_t offset = lDistanceToMove;
|
||||||
if (lpDistanceToMoveHigh) offset |= ((off_t)*lpDistanceToMoveHigh << 32);
|
if (lpDistanceToMoveHigh) offset |= ((off_t)*lpDistanceToMoveHigh << 32);
|
||||||
off_t result = lseek((int)(intptr_t)hFile, offset, dwMoveMethod);
|
off_t result = lseek((int)(intptr_t)hFile, offset, dwMoveMethod);
|
||||||
if (result == (off_t)-1) { if (lpDistanceToMoveHigh) *lpDistanceToMoveHigh = -1; return INVALID_SET_FILE_POINTER; }
|
if (result == (off_t)-1) {
|
||||||
|
if (lpDistanceToMoveHigh) *lpDistanceToMoveHigh = -1;
|
||||||
|
return INVALID_SET_FILE_POINTER;
|
||||||
|
}
|
||||||
if (lpDistanceToMoveHigh) *lpDistanceToMoveHigh = (LONG)(result >> 32);
|
if (lpDistanceToMoveHigh) *lpDistanceToMoveHigh = (LONG)(result >> 32);
|
||||||
return (DWORD)(result & 0xFFFFFFFF);
|
return (DWORD)(result & 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD GetFileAttributesA(const char *lpFileName)
|
static inline DWORD GetFileAttributesA(const char* lpFileName) {
|
||||||
{
|
|
||||||
struct stat st{};
|
struct stat st{};
|
||||||
if (stat(lpFileName, &st) != 0) return INVALID_FILE_ATTRIBUTES;
|
if (stat(lpFileName, &st) != 0) return INVALID_FILE_ATTRIBUTES;
|
||||||
DWORD attrs = S_ISDIR(st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
|
DWORD attrs =
|
||||||
|
S_ISDIR(st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL;
|
||||||
if (!(st.st_mode & S_IWUSR)) attrs |= FILE_ATTRIBUTE_READONLY;
|
if (!(st.st_mode & S_IWUSR)) attrs |= FILE_ATTRIBUTE_READONLY;
|
||||||
const char *base = strrchr(lpFileName, '/'); base = base ? base + 1 : lpFileName;
|
const char* base = strrchr(lpFileName, '/');
|
||||||
|
base = base ? base + 1 : lpFileName;
|
||||||
if (base[0] == '.') attrs |= FILE_ATTRIBUTE_HIDDEN;
|
if (base[0] == '.') attrs |= FILE_ATTRIBUTE_HIDDEN;
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD GetFileAttributes(const char *lpFileName)
|
static inline DWORD GetFileAttributes(const char* lpFileName) {
|
||||||
{
|
|
||||||
return GetFileAttributesA(lpFileName);
|
return GetFileAttributesA(lpFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL GetFileAttributesExA(const char *lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, void *lpFileInformation)
|
static inline BOOL GetFileAttributesExA(const char* lpFileName,
|
||||||
{
|
GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
||||||
if (fInfoLevelId != GetFileExInfoStandard || !lpFileInformation) return FALSE;
|
void* lpFileInformation) {
|
||||||
|
if (fInfoLevelId != GetFileExInfoStandard || !lpFileInformation)
|
||||||
|
return FALSE;
|
||||||
struct stat st{};
|
struct stat st{};
|
||||||
if (stat(lpFileName, &st) != 0) return FALSE;
|
if (stat(lpFileName, &st) != 0) return FALSE;
|
||||||
WIN32_FILE_ATTRIBUTE_DATA *out = (WIN32_FILE_ATTRIBUTE_DATA *)lpFileInformation;
|
WIN32_FILE_ATTRIBUTE_DATA* out =
|
||||||
|
(WIN32_FILE_ATTRIBUTE_DATA*)lpFileInformation;
|
||||||
out->dwFileAttributes = GetFileAttributesA(lpFileName);
|
out->dwFileAttributes = GetFileAttributesA(lpFileName);
|
||||||
out->ftCreationTime = _TimeToFileTime(st.st_mtime);
|
out->ftCreationTime = _TimeToFileTime(st.st_mtime);
|
||||||
out->ftLastAccessTime = _TimeToFileTime(st.st_atime);
|
out->ftLastAccessTime = _TimeToFileTime(st.st_atime);
|
||||||
|
|
@ -512,57 +544,54 @@ static inline BOOL GetFileAttributesExA(const char *lpFileName, GET_FILEEX_INFO_
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL GetFileAttributesEx(const char *lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, void *lpFileInformation)
|
static inline BOOL GetFileAttributesEx(const char* lpFileName,
|
||||||
{
|
GET_FILEEX_INFO_LEVELS fInfoLevelId,
|
||||||
|
void* lpFileInformation) {
|
||||||
return GetFileAttributesExA(lpFileName, fInfoLevelId, lpFileInformation);
|
return GetFileAttributesExA(lpFileName, fInfoLevelId, lpFileInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL CreateDirectoryA(const char *lpPathName, void *lpSecurityAttributes)
|
static inline BOOL CreateDirectoryA(const char* lpPathName,
|
||||||
{
|
void* lpSecurityAttributes) {
|
||||||
return mkdir(lpPathName, 0755) == 0;
|
return mkdir(lpPathName, 0755) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL CreateDirectory(const char *lpPathName, void *lpSecurityAttributes)
|
static inline BOOL CreateDirectory(const char* lpPathName,
|
||||||
{
|
void* lpSecurityAttributes) {
|
||||||
return CreateDirectoryA(lpPathName, lpSecurityAttributes);
|
return CreateDirectoryA(lpPathName, lpSecurityAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL DeleteFileA(const char *lpFileName)
|
static inline BOOL DeleteFileA(const char* lpFileName) {
|
||||||
{
|
|
||||||
return unlink(lpFileName) == 0;
|
return unlink(lpFileName) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL DeleteFile(const char *lpFileName)
|
static inline BOOL DeleteFile(const char* lpFileName) {
|
||||||
{
|
|
||||||
return DeleteFileA(lpFileName);
|
return DeleteFileA(lpFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL MoveFileA(const char *lpExistingFileName, const char *lpNewFileName)
|
static inline BOOL MoveFileA(const char* lpExistingFileName,
|
||||||
{
|
const char* lpNewFileName) {
|
||||||
return rename(lpExistingFileName, lpNewFileName) == 0;
|
return rename(lpExistingFileName, lpNewFileName) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL MoveFile(const char *lpExistingFileName, const char *lpNewFileName)
|
static inline BOOL MoveFile(const char* lpExistingFileName,
|
||||||
{
|
const char* lpNewFileName) {
|
||||||
return MoveFileA(lpExistingFileName, lpNewFileName);
|
return MoveFileA(lpExistingFileName, lpNewFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilea
|
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilea
|
||||||
static inline HANDLE FindFirstFileA(const char *lpFileName, WIN32_FIND_DATAA *lpFindFileData)
|
static inline HANDLE FindFirstFileA(const char* lpFileName,
|
||||||
{
|
WIN32_FIND_DATAA* lpFindFileData) {
|
||||||
if (!lpFileName || !lpFindFileData) return INVALID_HANDLE_VALUE;
|
if (!lpFileName || !lpFindFileData) return INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
char dirpath[MAX_PATH], pattern[MAX_PATH];
|
char dirpath[MAX_PATH], pattern[MAX_PATH];
|
||||||
const char* sep = strrchr(lpFileName, '/');
|
const char* sep = strrchr(lpFileName, '/');
|
||||||
if (sep)
|
if (sep) {
|
||||||
{
|
|
||||||
size_t len = sep - lpFileName;
|
size_t len = sep - lpFileName;
|
||||||
if (len >= MAX_PATH) return INVALID_HANDLE_VALUE;
|
if (len >= MAX_PATH) return INVALID_HANDLE_VALUE;
|
||||||
strncpy(dirpath, lpFileName, len); dirpath[len] = '\0';
|
strncpy(dirpath, lpFileName, len);
|
||||||
|
dirpath[len] = '\0';
|
||||||
strncpy(pattern, sep + 1, MAX_PATH - 1);
|
strncpy(pattern, sep + 1, MAX_PATH - 1);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
strncpy(dirpath, ".", MAX_PATH - 1);
|
strncpy(dirpath, ".", MAX_PATH - 1);
|
||||||
strncpy(pattern, lpFileName, MAX_PATH - 1);
|
strncpy(pattern, lpFileName, MAX_PATH - 1);
|
||||||
}
|
}
|
||||||
|
|
@ -570,84 +599,98 @@ static inline HANDLE FindFirstFileA(const char *lpFileName, WIN32_FIND_DATAA *lp
|
||||||
DIR* dir = opendir(dirpath);
|
DIR* dir = opendir(dirpath);
|
||||||
if (!dir) return INVALID_HANDLE_VALUE;
|
if (!dir) return INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
_LINUXSTUBS_FIND_HANDLE *fh = (_LINUXSTUBS_FIND_HANDLE *)malloc(sizeof(_LINUXSTUBS_FIND_HANDLE));
|
_LINUXSTUBS_FIND_HANDLE* fh =
|
||||||
if (!fh) { closedir(dir); return INVALID_HANDLE_VALUE; }
|
(_LINUXSTUBS_FIND_HANDLE*)malloc(sizeof(_LINUXSTUBS_FIND_HANDLE));
|
||||||
|
if (!fh) {
|
||||||
|
closedir(dir);
|
||||||
|
return INVALID_HANDLE_VALUE;
|
||||||
|
}
|
||||||
fh->dir = dir;
|
fh->dir = dir;
|
||||||
strncpy(fh->dirpath, dirpath, MAX_PATH - 1);
|
strncpy(fh->dirpath, dirpath, MAX_PATH - 1);
|
||||||
strncpy(fh->pattern, pattern, MAX_PATH - 1);
|
strncpy(fh->pattern, pattern, MAX_PATH - 1);
|
||||||
|
|
||||||
struct dirent* ent;
|
struct dirent* ent;
|
||||||
while ((ent = readdir(fh->dir)) != NULL)
|
while ((ent = readdir(fh->dir)) != NULL) {
|
||||||
{
|
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
||||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue;
|
continue;
|
||||||
if (fnmatch(fh->pattern, ent->d_name, 0) == 0)
|
if (fnmatch(fh->pattern, ent->d_name, 0) == 0) {
|
||||||
{
|
|
||||||
char fullpath[MAX_PATH * 2];
|
char fullpath[MAX_PATH * 2];
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", fh->dirpath, ent->d_name);
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", fh->dirpath,
|
||||||
|
ent->d_name);
|
||||||
struct stat st{};
|
struct stat st{};
|
||||||
if (stat(fullpath, &st) == 0) _FillFindData(ent->d_name, &st, lpFindFileData);
|
if (stat(fullpath, &st) == 0)
|
||||||
else { memset(lpFindFileData, 0, sizeof(*lpFindFileData)); strncpy(lpFindFileData->cFileName, ent->d_name, MAX_PATH - 1); }
|
_FillFindData(ent->d_name, &st, lpFindFileData);
|
||||||
|
else {
|
||||||
|
memset(lpFindFileData, 0, sizeof(*lpFindFileData));
|
||||||
|
strncpy(lpFindFileData->cFileName, ent->d_name, MAX_PATH - 1);
|
||||||
|
}
|
||||||
return (HANDLE)fh;
|
return (HANDLE)fh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(fh->dir); free(fh);
|
closedir(fh->dir);
|
||||||
|
free(fh);
|
||||||
return INVALID_HANDLE_VALUE;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HANDLE FindFirstFile(const char *lpFileName, WIN32_FIND_DATAA *lpFindFileData)
|
static inline HANDLE FindFirstFile(const char* lpFileName,
|
||||||
{
|
WIN32_FIND_DATAA* lpFindFileData) {
|
||||||
return FindFirstFileA(lpFileName, lpFindFileData);
|
return FindFirstFileA(lpFileName, lpFindFileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextfilea
|
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextfilea
|
||||||
static inline BOOL FindNextFileA(HANDLE hFindFile, WIN32_FIND_DATAA *lpFindFileData)
|
static inline BOOL FindNextFileA(HANDLE hFindFile,
|
||||||
{
|
WIN32_FIND_DATAA* lpFindFileData) {
|
||||||
if (hFindFile == INVALID_HANDLE_VALUE || !lpFindFileData) return FALSE;
|
if (hFindFile == INVALID_HANDLE_VALUE || !lpFindFileData) return FALSE;
|
||||||
_LINUXSTUBS_FIND_HANDLE* fh = (_LINUXSTUBS_FIND_HANDLE*)hFindFile;
|
_LINUXSTUBS_FIND_HANDLE* fh = (_LINUXSTUBS_FIND_HANDLE*)hFindFile;
|
||||||
|
|
||||||
struct dirent* ent;
|
struct dirent* ent;
|
||||||
while ((ent = readdir(fh->dir)) != NULL)
|
while ((ent = readdir(fh->dir)) != NULL) {
|
||||||
{
|
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
|
||||||
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue;
|
continue;
|
||||||
if (fnmatch(fh->pattern, ent->d_name, 0) == 0)
|
if (fnmatch(fh->pattern, ent->d_name, 0) == 0) {
|
||||||
{
|
|
||||||
char fullpath[MAX_PATH * 2];
|
char fullpath[MAX_PATH * 2];
|
||||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", fh->dirpath, ent->d_name);
|
snprintf(fullpath, sizeof(fullpath), "%s/%s", fh->dirpath,
|
||||||
|
ent->d_name);
|
||||||
struct stat st{};
|
struct stat st{};
|
||||||
if (stat(fullpath, &st) == 0) _FillFindData(ent->d_name, &st, lpFindFileData);
|
if (stat(fullpath, &st) == 0)
|
||||||
else { memset(lpFindFileData, 0, sizeof(*lpFindFileData)); strncpy(lpFindFileData->cFileName, ent->d_name, MAX_PATH - 1); }
|
_FillFindData(ent->d_name, &st, lpFindFileData);
|
||||||
|
else {
|
||||||
|
memset(lpFindFileData, 0, sizeof(*lpFindFileData));
|
||||||
|
strncpy(lpFindFileData->cFileName, ent->d_name, MAX_PATH - 1);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL FindNextFile(HANDLE hFindFile, WIN32_FIND_DATAA *lpFindFileData)
|
static inline BOOL FindNextFile(HANDLE hFindFile,
|
||||||
{
|
WIN32_FIND_DATAA* lpFindFileData) {
|
||||||
return FindNextFileA(hFindFile, lpFindFileData);
|
return FindNextFileA(hFindFile, lpFindFileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findclose
|
// https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findclose
|
||||||
static inline BOOL FindClose(HANDLE hFindFile)
|
static inline BOOL FindClose(HANDLE hFindFile) {
|
||||||
{
|
|
||||||
if (hFindFile == INVALID_HANDLE_VALUE) return FALSE;
|
if (hFindFile == INVALID_HANDLE_VALUE) return FALSE;
|
||||||
_LINUXSTUBS_FIND_HANDLE* fh = (_LINUXSTUBS_FIND_HANDLE*)hFindFile;
|
_LINUXSTUBS_FIND_HANDLE* fh = (_LINUXSTUBS_FIND_HANDLE*)hFindFile;
|
||||||
closedir(fh->dir); free(fh);
|
closedir(fh->dir);
|
||||||
|
free(fh);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helper: convert FILETIME (100ns since 1601) to time_t (seconds since 1970)
|
// internal helper: convert FILETIME (100ns since 1601) to time_t (seconds since
|
||||||
static inline time_t _FileTimeToTimeT(const FILETIME& ft)
|
// 1970)
|
||||||
{
|
static inline time_t _FileTimeToTimeT(const FILETIME& ft) {
|
||||||
ULONGLONG val = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
|
ULONGLONG val = ((ULONGLONG)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
|
||||||
const ULONGLONG EPOCH_DIFF = 116444736000000000ULL; // 100ns intervals between 1601-01-01 and 1970-01-01
|
const ULONGLONG EPOCH_DIFF =
|
||||||
|
116444736000000000ULL; // 100ns intervals between 1601-01-01 and
|
||||||
|
// 1970-01-01
|
||||||
return (time_t)((val - EPOCH_DIFF) / 10000000ULL);
|
return (time_t)((val - EPOCH_DIFF) / 10000000ULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helper: read the current wall clock into a timespec
|
// internal helper: read the current wall clock into a timespec
|
||||||
static inline void _CurrentTimeSpec(struct timespec *ts)
|
static inline void _CurrentTimeSpec(struct timespec* ts) {
|
||||||
{
|
|
||||||
#ifdef CLOCK_REALTIME
|
#ifdef CLOCK_REALTIME
|
||||||
clock_gettime(CLOCK_REALTIME, ts);
|
clock_gettime(CLOCK_REALTIME, ts);
|
||||||
#else
|
#else
|
||||||
|
|
@ -659,8 +702,8 @@ static inline void _CurrentTimeSpec(struct timespec *ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal helper: fill SYSTEMTIME from a broken-down tm + nanosecond remainder
|
// internal helper: fill SYSTEMTIME from a broken-down tm + nanosecond remainder
|
||||||
static inline void _FillSystemTime(const struct tm *tm, long tv_nsec, LPSYSTEMTIME lpSystemTime)
|
static inline void _FillSystemTime(const struct tm* tm, long tv_nsec,
|
||||||
{
|
LPSYSTEMTIME lpSystemTime) {
|
||||||
lpSystemTime->wYear = tm->tm_year + 1900;
|
lpSystemTime->wYear = tm->tm_year + 1900;
|
||||||
lpSystemTime->wMonth = tm->tm_mon + 1;
|
lpSystemTime->wMonth = tm->tm_mon + 1;
|
||||||
lpSystemTime->wDayOfWeek = tm->tm_wday; // 0 = Sunday
|
lpSystemTime->wDayOfWeek = tm->tm_wday; // 0 = Sunday
|
||||||
|
|
@ -672,24 +715,26 @@ static inline void _FillSystemTime(const struct tm *tm, long tv_nsec, LPSYSTEMTI
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtime
|
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtime
|
||||||
static inline VOID GetSystemTime(LPSYSTEMTIME lpSystemTime)
|
static inline VOID GetSystemTime(LPSYSTEMTIME lpSystemTime) {
|
||||||
{
|
struct timespec ts;
|
||||||
struct timespec ts; _CurrentTimeSpec(&ts);
|
_CurrentTimeSpec(&ts);
|
||||||
struct tm tm; gmtime_r(&ts.tv_sec, &tm); // UTC
|
struct tm tm;
|
||||||
|
gmtime_r(&ts.tv_sec, &tm); // UTC
|
||||||
_FillSystemTime(&tm, ts.tv_nsec, lpSystemTime);
|
_FillSystemTime(&tm, ts.tv_nsec, lpSystemTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlocaltime
|
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlocaltime
|
||||||
static inline VOID GetLocalTime(LPSYSTEMTIME lpSystemTime)
|
static inline VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) {
|
||||||
{
|
struct timespec ts;
|
||||||
struct timespec ts; _CurrentTimeSpec(&ts);
|
_CurrentTimeSpec(&ts);
|
||||||
struct tm tm; localtime_r(&ts.tv_sec, &tm); // local time
|
struct tm tm;
|
||||||
|
localtime_r(&ts.tv_sec, &tm); // local time
|
||||||
_FillSystemTime(&tm, ts.tv_nsec, lpSystemTime);
|
_FillSystemTime(&tm, ts.tv_nsec, lpSystemTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetofiletime
|
// https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-systemtimetofiletime
|
||||||
static inline BOOL SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime, LPFILETIME lpFileTime)
|
static inline BOOL SystemTimeToFileTime(const SYSTEMTIME* lpSystemTime,
|
||||||
{
|
LPFILETIME lpFileTime) {
|
||||||
struct tm tm = {};
|
struct tm tm = {};
|
||||||
tm.tm_year = lpSystemTime->wYear - 1900;
|
tm.tm_year = lpSystemTime->wYear - 1900;
|
||||||
tm.tm_mon = lpSystemTime->wMonth - 1;
|
tm.tm_mon = lpSystemTime->wMonth - 1;
|
||||||
|
|
@ -709,18 +754,19 @@ static inline BOOL SystemTimeToFileTime(const SYSTEMTIME *lpSystemTime, LPFILETI
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-filetimetosystemtime
|
// https://learn.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-filetimetosystemtime
|
||||||
static inline BOOL FileTimeToSystemTime(const FILETIME *lpFileTime, LPSYSTEMTIME lpSystemTime)
|
static inline BOOL FileTimeToSystemTime(const FILETIME* lpFileTime,
|
||||||
{
|
LPSYSTEMTIME lpSystemTime) {
|
||||||
ULONGLONG ft = ((ULONGLONG)lpFileTime->dwHighDateTime << 32) | lpFileTime->dwLowDateTime;
|
ULONGLONG ft = ((ULONGLONG)lpFileTime->dwHighDateTime << 32) |
|
||||||
|
lpFileTime->dwLowDateTime;
|
||||||
time_t t = _FileTimeToTimeT(*lpFileTime);
|
time_t t = _FileTimeToTimeT(*lpFileTime);
|
||||||
long remainder_ns = (long)((ft % 10000000ULL) * 100);
|
long remainder_ns = (long)((ft % 10000000ULL) * 100);
|
||||||
|
|
||||||
struct tm tm; gmtime_r(&t, &tm); // UTC
|
struct tm tm;
|
||||||
|
gmtime_r(&t, &tm); // UTC
|
||||||
_FillSystemTime(&tm, remainder_ns, lpSystemTime);
|
_FillSystemTime(&tm, remainder_ns, lpSystemTime);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
static inline DWORD GetTickCount()
|
static inline DWORD GetTickCount() {
|
||||||
{
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
|
||||||
|
|
@ -728,41 +774,36 @@ static inline DWORD GetTickCount()
|
||||||
return (long long)ts.tv_sec * 1000 + (long long)ts.tv_nsec / 1000000;
|
return (long long)ts.tv_sec * 1000 + (long long)ts.tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency)
|
static inline BOOL QueryPerformanceFrequency(LARGE_INTEGER* lpFrequency) {
|
||||||
{
|
|
||||||
// nanoseconds
|
// nanoseconds
|
||||||
lpFrequency->QuadPart = 1000000000;
|
lpFrequency->QuadPart = 1000000000;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline BOOL QueryPerformanceCounter(LARGE_INTEGER* lpPerformanceCount) {
|
||||||
static inline BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
|
|
||||||
{
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
|
||||||
// nanoseconds
|
// nanoseconds
|
||||||
lpPerformanceCount->QuadPart = ((long long)ts.tv_sec * 1000000000) + (long long)ts.tv_nsec;
|
lpPerformanceCount->QuadPart =
|
||||||
|
((long long)ts.tv_sec * 1000000000) + (long long)ts.tv_nsec;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa
|
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa
|
||||||
static inline VOID OutputDebugStringA(LPCSTR lpOutputString)
|
static inline VOID OutputDebugStringA(LPCSTR lpOutputString) {
|
||||||
{
|
|
||||||
if (!lpOutputString) return;
|
if (!lpOutputString) return;
|
||||||
fputs(lpOutputString, stderr);
|
fputs(lpOutputString, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw
|
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw
|
||||||
static inline VOID OutputDebugStringW(LPCWSTR lpOutputString)
|
static inline VOID OutputDebugStringW(LPCWSTR lpOutputString) {
|
||||||
{
|
|
||||||
if (!lpOutputString) return;
|
if (!lpOutputString) return;
|
||||||
fprintf(stderr, "%ls", lpOutputString);
|
fprintf(stderr, "%ls", lpOutputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VOID OutputDebugString(LPCSTR lpOutputString)
|
static inline VOID OutputDebugString(LPCSTR lpOutputString) {
|
||||||
{
|
|
||||||
return OutputDebugStringA(lpOutputString);
|
return OutputDebugStringA(lpOutputString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -782,7 +823,8 @@ static inline HANDLE CreateEvent(int manual_reset, int initial_state) {
|
||||||
return (HANDLE)ev;
|
return (HANDLE)ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline HANDLE CreateEvent(void*, BOOL manual_reset, BOOL initial_state, void*) {
|
static inline HANDLE CreateEvent(void*, BOOL manual_reset, BOOL initial_state,
|
||||||
|
void*) {
|
||||||
return CreateEvent(manual_reset, initial_state);
|
return CreateEvent(manual_reset, initial_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -791,8 +833,10 @@ static inline BOOL SetEvent(HANDLE hEvent) {
|
||||||
if (!ev) return FALSE;
|
if (!ev) return FALSE;
|
||||||
pthread_mutex_lock(&ev->mutex);
|
pthread_mutex_lock(&ev->mutex);
|
||||||
ev->signaled = 1;
|
ev->signaled = 1;
|
||||||
if (ev->manual_reset) pthread_cond_broadcast(&ev->cond);
|
if (ev->manual_reset)
|
||||||
else pthread_cond_signal(&ev->cond);
|
pthread_cond_broadcast(&ev->cond);
|
||||||
|
else
|
||||||
|
pthread_cond_signal(&ev->cond);
|
||||||
pthread_mutex_unlock(&ev->mutex);
|
pthread_mutex_unlock(&ev->mutex);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
@ -819,7 +863,10 @@ static inline DWORD _WaitForEvent(Event* ev, DWORD dwMilliseconds) {
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
ts.tv_sec += dwMilliseconds / 1000;
|
ts.tv_sec += dwMilliseconds / 1000;
|
||||||
ts.tv_nsec += (dwMilliseconds % 1000) * 1000000;
|
ts.tv_nsec += (dwMilliseconds % 1000) * 1000000;
|
||||||
if (ts.tv_nsec >= 1000000000) { ts.tv_sec++; ts.tv_nsec -= 1000000000; }
|
if (ts.tv_nsec >= 1000000000) {
|
||||||
|
ts.tv_sec++;
|
||||||
|
ts.tv_nsec -= 1000000000;
|
||||||
|
}
|
||||||
while (!ev->signaled) {
|
while (!ev->signaled) {
|
||||||
if (pthread_cond_timedwait(&ev->cond, &ev->mutex, &ts) != 0) {
|
if (pthread_cond_timedwait(&ev->cond, &ev->mutex, &ts) != 0) {
|
||||||
pthread_mutex_unlock(&ev->mutex);
|
pthread_mutex_unlock(&ev->mutex);
|
||||||
|
|
@ -827,7 +874,10 @@ static inline DWORD _WaitForEvent(Event* ev, DWORD dwMilliseconds) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!ev->signaled) { pthread_mutex_unlock(&ev->mutex); return WAIT_TIMEOUT; }
|
if (!ev->signaled) {
|
||||||
|
pthread_mutex_unlock(&ev->mutex);
|
||||||
|
return WAIT_TIMEOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!ev->manual_reset) ev->signaled = 0;
|
if (!ev->manual_reset) ev->signaled = 0;
|
||||||
pthread_mutex_unlock(&ev->mutex);
|
pthread_mutex_unlock(&ev->mutex);
|
||||||
|
|
@ -835,25 +885,32 @@ static inline DWORD _WaitForEvent(Event* ev, DWORD dwMilliseconds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LinuxThread;
|
struct LinuxThread;
|
||||||
static inline DWORD _WaitForThread(struct LinuxThread* lt, DWORD dwMilliseconds);
|
static inline DWORD _WaitForThread(struct LinuxThread* lt,
|
||||||
|
DWORD dwMilliseconds);
|
||||||
|
|
||||||
static inline DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) {
|
static inline DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds) {
|
||||||
if (!hHandle) return WAIT_FAILED;
|
if (!hHandle) return WAIT_FAILED;
|
||||||
// Check if this is a thread handle (LinuxThread has magic number as first field)
|
// Check if this is a thread handle (LinuxThread has magic number as first
|
||||||
|
// field)
|
||||||
if (*(int*)hHandle == HANDLE_TYPE_THREAD) {
|
if (*(int*)hHandle == HANDLE_TYPE_THREAD) {
|
||||||
return _WaitForThread((struct LinuxThread*)hHandle, dwMilliseconds);
|
return _WaitForThread((struct LinuxThread*)hHandle, dwMilliseconds);
|
||||||
}
|
}
|
||||||
return _WaitForEvent((Event*)hHandle, dwMilliseconds);
|
return _WaitForEvent((Event*)hHandle, dwMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD WaitForMultipleObjects(DWORD nCount, const HANDLE* lpHandles, BOOL bWaitAll, DWORD dwMilliseconds) {
|
static inline DWORD WaitForMultipleObjects(DWORD nCount,
|
||||||
|
const HANDLE* lpHandles,
|
||||||
|
BOOL bWaitAll,
|
||||||
|
DWORD dwMilliseconds) {
|
||||||
if (bWaitAll) {
|
if (bWaitAll) {
|
||||||
for (DWORD i = 0; i < nCount; i++) WaitForSingleObject(lpHandles[i], dwMilliseconds);
|
for (DWORD i = 0; i < nCount; i++)
|
||||||
|
WaitForSingleObject(lpHandles[i], dwMilliseconds);
|
||||||
return WAIT_OBJECT_0;
|
return WAIT_OBJECT_0;
|
||||||
}
|
}
|
||||||
for (int pass = 0; pass < 1000; pass++) {
|
for (int pass = 0; pass < 1000; pass++) {
|
||||||
for (DWORD i = 0; i < nCount; i++) {
|
for (DWORD i = 0; i < nCount; i++) {
|
||||||
if (WaitForSingleObject(lpHandles[i], 0) == WAIT_OBJECT_0) return WAIT_OBJECT_0 + i;
|
if (WaitForSingleObject(lpHandles[i], 0) == WAIT_OBJECT_0)
|
||||||
|
return WAIT_OBJECT_0 + i;
|
||||||
}
|
}
|
||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
@ -890,7 +947,8 @@ struct LinuxThread {
|
||||||
static inline void* _linux_thread_entry(void* arg) {
|
static inline void* _linux_thread_entry(void* arg) {
|
||||||
LinuxThread* lt = (LinuxThread*)arg;
|
LinuxThread* lt = (LinuxThread*)arg;
|
||||||
pthread_mutex_lock(<->suspendMutex);
|
pthread_mutex_lock(<->suspendMutex);
|
||||||
while (lt->suspended) pthread_cond_wait(<->suspendCond, <->suspendMutex);
|
while (lt->suspended)
|
||||||
|
pthread_cond_wait(<->suspendCond, <->suspendMutex);
|
||||||
pthread_mutex_unlock(<->suspendMutex);
|
pthread_mutex_unlock(<->suspendMutex);
|
||||||
lt->exitCode = lt->func(lt->param);
|
lt->exitCode = lt->func(lt->param);
|
||||||
// Signal completion
|
// Signal completion
|
||||||
|
|
@ -901,7 +959,8 @@ static inline void* _linux_thread_entry(void* arg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline DWORD _WaitForThread(struct LinuxThread* lt, DWORD dwMilliseconds) {
|
static inline DWORD _WaitForThread(struct LinuxThread* lt,
|
||||||
|
DWORD dwMilliseconds) {
|
||||||
pthread_mutex_lock(<->completionMutex);
|
pthread_mutex_lock(<->completionMutex);
|
||||||
if (lt->completed) {
|
if (lt->completed) {
|
||||||
pthread_mutex_unlock(<->completionMutex);
|
pthread_mutex_unlock(<->completionMutex);
|
||||||
|
|
@ -912,15 +971,20 @@ static inline DWORD _WaitForThread(struct LinuxThread* lt, DWORD dwMilliseconds)
|
||||||
return WAIT_TIMEOUT;
|
return WAIT_TIMEOUT;
|
||||||
}
|
}
|
||||||
if (dwMilliseconds == INFINITE) {
|
if (dwMilliseconds == INFINITE) {
|
||||||
while (!lt->completed) pthread_cond_wait(<->completionCond, <->completionMutex);
|
while (!lt->completed)
|
||||||
|
pthread_cond_wait(<->completionCond, <->completionMutex);
|
||||||
} else {
|
} else {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
ts.tv_sec += dwMilliseconds / 1000;
|
ts.tv_sec += dwMilliseconds / 1000;
|
||||||
ts.tv_nsec += (dwMilliseconds % 1000) * 1000000;
|
ts.tv_nsec += (dwMilliseconds % 1000) * 1000000;
|
||||||
if (ts.tv_nsec >= 1000000000) { ts.tv_sec++; ts.tv_nsec -= 1000000000; }
|
if (ts.tv_nsec >= 1000000000) {
|
||||||
|
ts.tv_sec++;
|
||||||
|
ts.tv_nsec -= 1000000000;
|
||||||
|
}
|
||||||
while (!lt->completed) {
|
while (!lt->completed) {
|
||||||
if (pthread_cond_timedwait(<->completionCond, <->completionMutex, &ts) != 0) {
|
if (pthread_cond_timedwait(<->completionCond,
|
||||||
|
<->completionMutex, &ts) != 0) {
|
||||||
pthread_mutex_unlock(<->completionMutex);
|
pthread_mutex_unlock(<->completionMutex);
|
||||||
return WAIT_TIMEOUT;
|
return WAIT_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
@ -932,7 +996,10 @@ static inline DWORD _WaitForThread(struct LinuxThread* lt, DWORD dwMilliseconds)
|
||||||
|
|
||||||
static DWORD g_nextThreadId = 1000;
|
static DWORD g_nextThreadId = 1000;
|
||||||
|
|
||||||
static inline HANDLE CreateThread(void*, SIZE_T stackSize, LPTHREAD_START_ROUTINE lpStartAddress, void* lpParameter, DWORD dwCreationFlags, DWORD* lpThreadId) {
|
static inline HANDLE CreateThread(void*, SIZE_T stackSize,
|
||||||
|
LPTHREAD_START_ROUTINE lpStartAddress,
|
||||||
|
void* lpParameter, DWORD dwCreationFlags,
|
||||||
|
DWORD* lpThreadId) {
|
||||||
LinuxThread* lt = (LinuxThread*)calloc(1, sizeof(LinuxThread));
|
LinuxThread* lt = (LinuxThread*)calloc(1, sizeof(LinuxThread));
|
||||||
lt->handleType = HANDLE_TYPE_THREAD;
|
lt->handleType = HANDLE_TYPE_THREAD;
|
||||||
lt->func = lpStartAddress;
|
lt->func = lpStartAddress;
|
||||||
|
|
@ -965,7 +1032,8 @@ static inline DWORD ResumeThread(HANDLE hThread) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL SetThreadPriority(HANDLE hThread, int nPriority) {
|
static inline BOOL SetThreadPriority(HANDLE hThread, int nPriority) {
|
||||||
(void)hThread; (void)nPriority;
|
(void)hThread;
|
||||||
|
(void)nPriority;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1020,13 +1088,18 @@ static inline int swprintf_s(wchar_t* buf, size_t sz, const wchar_t* fmt, ...) {
|
||||||
|
|
||||||
static inline HMODULE GetModuleHandle(LPCSTR lpModuleName) { return 0; }
|
static inline HMODULE GetModuleHandle(LPCSTR lpModuleName) { return 0; }
|
||||||
|
|
||||||
static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) {
|
static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize,
|
||||||
|
DWORD flAllocationType, DWORD flProtect) {
|
||||||
// MEM_COMMIT | MEM_RESERVE → mmap anonymous
|
// MEM_COMMIT | MEM_RESERVE → mmap anonymous
|
||||||
int prot = 0;
|
int prot = 0;
|
||||||
if (flProtect == 0x04 /*PAGE_READWRITE*/) prot = PROT_READ | PROT_WRITE;
|
if (flProtect == 0x04 /*PAGE_READWRITE*/)
|
||||||
else if (flProtect == 0x40 /*PAGE_EXECUTE_READWRITE*/) prot = PROT_READ | PROT_WRITE | PROT_EXEC;
|
prot = PROT_READ | PROT_WRITE;
|
||||||
else if (flProtect == 0x02 /*PAGE_READONLY*/) prot = PROT_READ;
|
else if (flProtect == 0x40 /*PAGE_EXECUTE_READWRITE*/)
|
||||||
else prot = PROT_READ | PROT_WRITE; // default
|
prot = PROT_READ | PROT_WRITE | PROT_EXEC;
|
||||||
|
else if (flProtect == 0x02 /*PAGE_READONLY*/)
|
||||||
|
prot = PROT_READ;
|
||||||
|
else
|
||||||
|
prot = PROT_READ | PROT_WRITE; // default
|
||||||
|
|
||||||
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||||
if (lpAddress != NULL) flags |= MAP_FIXED;
|
if (lpAddress != NULL) flags |= MAP_FIXED;
|
||||||
|
|
@ -1036,12 +1109,14 @@ static inline LPVOID VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAlloc
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) {
|
static inline BOOL VirtualFree(LPVOID lpAddress, SIZE_T dwSize,
|
||||||
|
DWORD dwFreeType) {
|
||||||
if (lpAddress == NULL) return FALSE;
|
if (lpAddress == NULL) return FALSE;
|
||||||
// MEM_RELEASE (0x8000) frees the whole region
|
// MEM_RELEASE (0x8000) frees the whole region
|
||||||
if (dwFreeType == 0x8000 /*MEM_RELEASE*/) {
|
if (dwFreeType == 0x8000 /*MEM_RELEASE*/) {
|
||||||
// dwSize should be 0 for MEM_RELEASE per Win32 API, but we don't track allocation sizes
|
// dwSize should be 0 for MEM_RELEASE per Win32 API, but we don't track
|
||||||
// Use dwSize if provided, otherwise this is a best-effort
|
// allocation sizes Use dwSize if provided, otherwise this is a
|
||||||
|
// best-effort
|
||||||
if (dwSize == 0) dwSize = 4096; // minimum page
|
if (dwSize == 0) dwSize = 4096; // minimum page
|
||||||
munmap(lpAddress, dwSize);
|
munmap(lpAddress, dwSize);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,7 @@ typedef long long int int64;
|
||||||
#define XBOX_MINBORDERSAFE 0
|
#define XBOX_MINBORDERSAFE 0
|
||||||
#define XBOX_MAXBORDERSAFE 0
|
#define XBOX_MAXBORDERSAFE 0
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
XK_NULL,
|
XK_NULL,
|
||||||
XK_BUTTON_UP,
|
XK_BUTTON_UP,
|
||||||
XK_BUTTON_DOWN,
|
XK_BUTTON_DOWN,
|
||||||
|
|
@ -101,12 +100,11 @@ typedef DWORD COLORREF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// typedef struct {
|
// typedef struct {
|
||||||
// IN_ADDR ina; // IP address (zero if not static/DHCP)
|
// IN_ADDR ina; // IP address (zero if not
|
||||||
// IN_ADDR inaOnline; // Online IP address (zero if not online)
|
// static/DHCP) IN_ADDR inaOnline; // Online IP address
|
||||||
// WORD wPortOnline; // Online port
|
// (zero if not online) WORD wPortOnline; // Online
|
||||||
// BYTE abEnet[6]; // Ethernet MAC address
|
// port BYTE abEnet[6]; // Ethernet MAC address BYTE
|
||||||
// BYTE abOnline[20]; // Online identification
|
// abOnline[20]; // Online identification } XNADDR;
|
||||||
// } XNADDR;
|
|
||||||
|
|
||||||
typedef int XNADDR;
|
typedef int XNADDR;
|
||||||
typedef uint64 XUID;
|
typedef uint64 XUID;
|
||||||
|
|
@ -119,15 +117,13 @@ typedef struct {
|
||||||
BYTE ab[16]; // xbox to xbox key exchange key
|
BYTE ab[16]; // xbox to xbox key exchange key
|
||||||
} XNKEY;
|
} XNKEY;
|
||||||
|
|
||||||
typedef struct _XSESSION_INFO
|
typedef struct _XSESSION_INFO {
|
||||||
{
|
|
||||||
XNKID sessionID; // 8 bytes
|
XNKID sessionID; // 8 bytes
|
||||||
XNADDR hostAddress; // 36 bytes
|
XNADDR hostAddress; // 36 bytes
|
||||||
XNKEY keyExchangeKey; // 16 bytes
|
XNKEY keyExchangeKey; // 16 bytes
|
||||||
} XSESSION_INFO, *PXSESSION_INFO;
|
} XSESSION_INFO, *PXSESSION_INFO;
|
||||||
|
|
||||||
typedef struct _XSESSION_REGISTRANT
|
typedef struct _XSESSION_REGISTRANT {
|
||||||
{
|
|
||||||
uint64 qwMachineID;
|
uint64 qwMachineID;
|
||||||
DWORD bTrustworthiness;
|
DWORD bTrustworthiness;
|
||||||
DWORD bNumUsers;
|
DWORD bNumUsers;
|
||||||
|
|
@ -135,8 +131,7 @@ typedef struct _XSESSION_REGISTRANT
|
||||||
|
|
||||||
} XSESSION_REGISTRANT;
|
} XSESSION_REGISTRANT;
|
||||||
|
|
||||||
typedef struct _XSESSION_REGISTRATION_RESULTS
|
typedef struct _XSESSION_REGISTRATION_RESULTS {
|
||||||
{
|
|
||||||
DWORD wNumRegistrants;
|
DWORD wNumRegistrants;
|
||||||
XSESSION_REGISTRANT* rgRegistrants;
|
XSESSION_REGISTRANT* rgRegistrants;
|
||||||
} XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS;
|
} XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS;
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,18 @@ void PIXSetMarkerDeprecated(int a, const char* b, ...) {}
|
||||||
|
|
||||||
#include "../Xbox/Network/NetworkPlayerXbox.h"
|
#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; }
|
IQNetPlayer* NetworkPlayerXbox::GetQNetPlayer() { return m_qnetPlayer; }
|
||||||
unsigned char NetworkPlayerXbox::GetSmallId() { return 0; }
|
unsigned char NetworkPlayerXbox::GetSmallId() { return 0; }
|
||||||
void NetworkPlayerXbox::SendData(INetworkPlayer*, const void*, int, bool) {}
|
void NetworkPlayerXbox::SendData(INetworkPlayer*, const void*, int, bool) {}
|
||||||
bool NetworkPlayerXbox::IsSameSystem(INetworkPlayer*) { return false; }
|
bool NetworkPlayerXbox::IsSameSystem(INetworkPlayer*) { return false; }
|
||||||
int NetworkPlayerXbox::GetSendQueueSizeBytes(INetworkPlayer*, bool) { return 0; }
|
int NetworkPlayerXbox::GetSendQueueSizeBytes(INetworkPlayer*, bool) {
|
||||||
int NetworkPlayerXbox::GetSendQueueSizeMessages(INetworkPlayer*, bool) { return 0; }
|
return 0;
|
||||||
|
}
|
||||||
|
int NetworkPlayerXbox::GetSendQueueSizeMessages(INetworkPlayer*, bool) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int NetworkPlayerXbox::GetCurrentRtt() { return 0; }
|
int NetworkPlayerXbox::GetCurrentRtt() { return 0; }
|
||||||
bool NetworkPlayerXbox::IsHost() { return false; }
|
bool NetworkPlayerXbox::IsHost() { return false; }
|
||||||
bool NetworkPlayerXbox::IsGuest() { return false; }
|
bool NetworkPlayerXbox::IsGuest() { return false; }
|
||||||
|
|
|
||||||
|
|
@ -20,80 +20,97 @@
|
||||||
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
|
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
|
||||||
#include "../Network/PlayerConnection.h"
|
#include "../Network/PlayerConnection.h"
|
||||||
|
|
||||||
EntityTracker::EntityTracker(ServerLevel *level)
|
EntityTracker::EntityTracker(ServerLevel* level) {
|
||||||
{
|
|
||||||
this->level = level;
|
this->level = level;
|
||||||
maxRange = level->getServer()->getPlayers()->getMaxRange();
|
maxRange = level->getServer()->getPlayers()->getMaxRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::addEntity(std::shared_ptr<Entity> e)
|
void EntityTracker::addEntity(std::shared_ptr<Entity> e) {
|
||||||
{
|
if (e->GetType() == eTYPE_SERVERPLAYER) {
|
||||||
if (e->GetType() == eTYPE_SERVERPLAYER)
|
|
||||||
{
|
|
||||||
addEntity(e, 32 * 16, 2);
|
addEntity(e, 32 * 16, 2);
|
||||||
std::shared_ptr<ServerPlayer> player = std::dynamic_pointer_cast<ServerPlayer>(e);
|
std::shared_ptr<ServerPlayer> player =
|
||||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
std::dynamic_pointer_cast<ServerPlayer>(e);
|
||||||
{
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
||||||
if( (*it)->e != player )
|
if ((*it)->e != player) {
|
||||||
{
|
|
||||||
(*it)->updatePlayer(this, player);
|
(*it)->updatePlayer(this, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (e->GetType() == eTYPE_FISHINGHOOK)
|
||||||
else if (e->GetType() == eTYPE_FISHINGHOOK) addEntity(e, 16 * 4, 5, true);
|
addEntity(e, 16 * 4, 5, true);
|
||||||
else if (e->GetType() == eTYPE_SMALL_FIREBALL) addEntity(e, 16 * 4, 10, false);
|
else if (e->GetType() == eTYPE_SMALL_FIREBALL)
|
||||||
else if (e->GetType() == eTYPE_DRAGON_FIREBALL) addEntity(e, 16 * 4, 10, false); // 4J Added TU9
|
addEntity(e, 16 * 4, 10, false);
|
||||||
else if (e->GetType() == eTYPE_ARROW) addEntity(e, 16 * 4, 20, false);
|
else if (e->GetType() == eTYPE_DRAGON_FIREBALL)
|
||||||
else if (e->GetType() == eTYPE_FIREBALL) addEntity(e, 16 * 4, 10, false);
|
addEntity(e, 16 * 4, 10, false); // 4J Added TU9
|
||||||
else if (e->GetType() == eTYPE_SNOWBALL) addEntity(e, 16 * 4, 10, true);
|
else if (e->GetType() == eTYPE_ARROW)
|
||||||
else if (e->GetType() == eTYPE_THROWNENDERPEARL) addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 20, false);
|
||||||
else if (e->GetType() == eTYPE_EYEOFENDERSIGNAL ) addEntity(e, 16 * 4, 4, true);
|
else if (e->GetType() == eTYPE_FIREBALL)
|
||||||
else if (e->GetType() == eTYPE_THROWNEGG) addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, false);
|
||||||
else if (e->GetType() == eTYPE_THROWNPOTION ) addEntity(e, 16 * 4, 10, true);
|
else if (e->GetType() == eTYPE_SNOWBALL)
|
||||||
else if (e->GetType() == eTYPE_THROWNEXPBOTTLE) addEntity(e, 16 * 4, 10, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_ITEMENTITY) addEntity(e, 16 * 4, 20, true);
|
else if (e->GetType() == eTYPE_THROWNENDERPEARL)
|
||||||
else if (e->GetType() == eTYPE_MINECART) addEntity(e, 16 * 5, 3, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_BOAT) addEntity(e, 16 * 5, 3, true);
|
else if (e->GetType() == eTYPE_EYEOFENDERSIGNAL)
|
||||||
else if (e->GetType() == eTYPE_SQUID) addEntity(e, 16 * 4, 3, true);
|
addEntity(e, 16 * 4, 4, true);
|
||||||
else if (std::dynamic_pointer_cast<Creature>(e)!=NULL) addEntity(e, 16 * 5, 3, true);
|
else if (e->GetType() == eTYPE_THROWNEGG)
|
||||||
else if (e->GetType() == eTYPE_ENDERDRAGON ) addEntity(e, 16 * 10, 3, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_PRIMEDTNT) addEntity(e, 16 * 10, 10, true);
|
else if (e->GetType() == eTYPE_THROWNPOTION)
|
||||||
else if (e->GetType() == eTYPE_FALLINGTILE) addEntity(e, 16 * 10, 20, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_PAINTING) addEntity(e, 16 * 10, INT_MAX, false);
|
else if (e->GetType() == eTYPE_THROWNEXPBOTTLE)
|
||||||
else if (e->GetType() == eTYPE_EXPERIENCEORB) addEntity(e, 16 * 10, 20, true);
|
addEntity(e, 16 * 4, 10, true);
|
||||||
else if (e->GetType() == eTYPE_ENDER_CRYSTAL) addEntity(e, 16 * 16, INT_MAX, false);
|
else if (e->GetType() == eTYPE_ITEMENTITY)
|
||||||
else if (e->GetType() == eTYPE_ITEM_FRAME) addEntity(e, 16 * 10, INT_MAX, false);
|
addEntity(e, 16 * 4, 20, true);
|
||||||
|
else if (e->GetType() == eTYPE_MINECART)
|
||||||
|
addEntity(e, 16 * 5, 3, true);
|
||||||
|
else if (e->GetType() == eTYPE_BOAT)
|
||||||
|
addEntity(e, 16 * 5, 3, true);
|
||||||
|
else if (e->GetType() == eTYPE_SQUID)
|
||||||
|
addEntity(e, 16 * 4, 3, true);
|
||||||
|
else if (std::dynamic_pointer_cast<Creature>(e) != NULL)
|
||||||
|
addEntity(e, 16 * 5, 3, true);
|
||||||
|
else if (e->GetType() == eTYPE_ENDERDRAGON)
|
||||||
|
addEntity(e, 16 * 10, 3, true);
|
||||||
|
else if (e->GetType() == eTYPE_PRIMEDTNT)
|
||||||
|
addEntity(e, 16 * 10, 10, true);
|
||||||
|
else if (e->GetType() == eTYPE_FALLINGTILE)
|
||||||
|
addEntity(e, 16 * 10, 20, true);
|
||||||
|
else if (e->GetType() == eTYPE_PAINTING)
|
||||||
|
addEntity(e, 16 * 10, INT_MAX, false);
|
||||||
|
else if (e->GetType() == eTYPE_EXPERIENCEORB)
|
||||||
|
addEntity(e, 16 * 10, 20, true);
|
||||||
|
else if (e->GetType() == eTYPE_ENDER_CRYSTAL)
|
||||||
|
addEntity(e, 16 * 16, INT_MAX, false);
|
||||||
|
else if (e->GetType() == eTYPE_ITEM_FRAME)
|
||||||
|
addEntity(e, 16 * 10, INT_MAX, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::addEntity(std::shared_ptr<Entity> e, int range, int updateInterval)
|
void EntityTracker::addEntity(std::shared_ptr<Entity> e, int range,
|
||||||
{
|
int updateInterval) {
|
||||||
addEntity(e, range, updateInterval, false);
|
addEntity(e, range, updateInterval, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::addEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDeltas)
|
void EntityTracker::addEntity(std::shared_ptr<Entity> e, int range,
|
||||||
{
|
int updateInterval, bool trackDeltas) {
|
||||||
if (range > maxRange) range = maxRange;
|
if (range > maxRange) range = maxRange;
|
||||||
if (entityMap.find(e->entityId) != entityMap.end())
|
if (entityMap.find(e->entityId) != entityMap.end()) {
|
||||||
{
|
|
||||||
assert(false); // Entity already tracked
|
assert(false); // Entity already tracked
|
||||||
}
|
}
|
||||||
if( e->entityId >= 2048 )
|
if (e->entityId >= 2048) {
|
||||||
{
|
|
||||||
__debugbreak();
|
__debugbreak();
|
||||||
}
|
}
|
||||||
std::shared_ptr<TrackedEntity> te = std::shared_ptr<TrackedEntity>( new TrackedEntity(e, range, updateInterval, trackDeltas) );
|
std::shared_ptr<TrackedEntity> te = std::shared_ptr<TrackedEntity>(
|
||||||
|
new TrackedEntity(e, range, updateInterval, trackDeltas));
|
||||||
entities.insert(te);
|
entities.insert(te);
|
||||||
entityMap[e->entityId] = te;
|
entityMap[e->entityId] = te;
|
||||||
te->updatePlayers(this, &level->players);
|
te->updatePlayers(this, &level->players);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J - have split removeEntity into two bits - it used to do the equivalent of EntityTracker::removePlayer followed by EntityTracker::removeEntity.
|
// 4J - have split removeEntity into two bits - it used to do the equivalent of
|
||||||
// This is to allow us to now choose to remove the player as a "seenBy" only when the player has actually been removed from the level's own player array
|
// EntityTracker::removePlayer followed by EntityTracker::removeEntity. This is
|
||||||
void EntityTracker::removeEntity(std::shared_ptr<Entity> e)
|
// to allow us to now choose to remove the player as a "seenBy" only when the
|
||||||
{
|
// player has actually been removed from the level's own player array
|
||||||
|
void EntityTracker::removeEntity(std::shared_ptr<Entity> e) {
|
||||||
AUTO_VAR(it, entityMap.find(e->entityId));
|
AUTO_VAR(it, entityMap.find(e->entityId));
|
||||||
if( it != entityMap.end() )
|
if (it != entityMap.end()) {
|
||||||
{
|
|
||||||
std::shared_ptr<TrackedEntity> te = it->second;
|
std::shared_ptr<TrackedEntity> te = it->second;
|
||||||
entityMap.erase(it);
|
entityMap.erase(it);
|
||||||
entities.erase(te);
|
entities.erase(te);
|
||||||
|
|
@ -101,37 +118,34 @@ void EntityTracker::removeEntity(std::shared_ptr<Entity> e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::removePlayer(std::shared_ptr<Entity> e)
|
void EntityTracker::removePlayer(std::shared_ptr<Entity> e) {
|
||||||
{
|
if (e->GetType() == eTYPE_SERVERPLAYER) {
|
||||||
if (e->GetType() == eTYPE_SERVERPLAYER)
|
std::shared_ptr<ServerPlayer> player =
|
||||||
{
|
std::dynamic_pointer_cast<ServerPlayer>(e);
|
||||||
std::shared_ptr<ServerPlayer> player = std::dynamic_pointer_cast<ServerPlayer>(e);
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
||||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
|
||||||
{
|
|
||||||
(*it)->removePlayer(player);
|
(*it)->removePlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::tick()
|
void EntityTracker::tick() {
|
||||||
{
|
|
||||||
std::vector<std::shared_ptr<ServerPlayer> > movedPlayers;
|
std::vector<std::shared_ptr<ServerPlayer> > movedPlayers;
|
||||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
||||||
{
|
|
||||||
std::shared_ptr<TrackedEntity> te = *it;
|
std::shared_ptr<TrackedEntity> te = *it;
|
||||||
te->tick(this, &level->players);
|
te->tick(this, &level->players);
|
||||||
if (te->moved && te->e->GetType() == eTYPE_SERVERPLAYER)
|
if (te->moved && te->e->GetType() == eTYPE_SERVERPLAYER) {
|
||||||
{
|
movedPlayers.push_back(
|
||||||
movedPlayers.push_back(std::dynamic_pointer_cast<ServerPlayer>(te->e));
|
std::dynamic_pointer_cast<ServerPlayer>(te->e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - If one player on a system is updated, then make sure they all are as they all have their
|
// 4J Stu - If one player on a system is updated, then make sure they all
|
||||||
// range extended to include entities visible by any other player on the system
|
// are as they all have their range extended to include entities visible by
|
||||||
// Fix for #11194 - Gameplay: Host player and their split-screen avatars can become invisible and invulnerable to client.
|
// any other player on the system Fix for #11194 - Gameplay: Host player and
|
||||||
|
// their split-screen avatars can become invisible and invulnerable to
|
||||||
|
// client.
|
||||||
MinecraftServer* server = MinecraftServer::getInstance();
|
MinecraftServer* server = MinecraftServer::getInstance();
|
||||||
for( unsigned int i = 0; i < server->getPlayers()->players.size(); i++ )
|
for (unsigned int i = 0; i < server->getPlayers()->players.size(); i++) {
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> ep = server->getPlayers()->players[i];
|
std::shared_ptr<ServerPlayer> ep = server->getPlayers()->players[i];
|
||||||
if (ep->dimension != level->dimension->id) continue;
|
if (ep->dimension != level->dimension->id) continue;
|
||||||
|
|
||||||
|
|
@ -140,16 +154,14 @@ void EntityTracker::tick()
|
||||||
if (thisPlayer == NULL) continue;
|
if (thisPlayer == NULL) continue;
|
||||||
|
|
||||||
bool addPlayer = false;
|
bool addPlayer = false;
|
||||||
for (unsigned int j = 0; j < movedPlayers.size(); j++)
|
for (unsigned int j = 0; j < movedPlayers.size(); j++) {
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> sp = movedPlayers[j];
|
std::shared_ptr<ServerPlayer> sp = movedPlayers[j];
|
||||||
|
|
||||||
if (sp == ep) break;
|
if (sp == ep) break;
|
||||||
|
|
||||||
if (sp->connection == NULL) continue;
|
if (sp->connection == NULL) continue;
|
||||||
INetworkPlayer* otherPlayer = sp->connection->getNetworkPlayer();
|
INetworkPlayer* otherPlayer = sp->connection->getNetworkPlayer();
|
||||||
if( otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer) )
|
if (otherPlayer != NULL && thisPlayer->IsSameSystem(otherPlayer)) {
|
||||||
{
|
|
||||||
addPlayer = true;
|
addPlayer = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -157,72 +169,62 @@ void EntityTracker::tick()
|
||||||
if (addPlayer) movedPlayers.push_back(ep);
|
if (addPlayer) movedPlayers.push_back(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < movedPlayers.size(); i++)
|
for (unsigned int i = 0; i < movedPlayers.size(); i++) {
|
||||||
{
|
|
||||||
std::shared_ptr<ServerPlayer> player = movedPlayers[i];
|
std::shared_ptr<ServerPlayer> player = movedPlayers[i];
|
||||||
if (player->connection == NULL) continue;
|
if (player->connection == NULL) continue;
|
||||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
||||||
{
|
|
||||||
std::shared_ptr<TrackedEntity> te = *it;
|
std::shared_ptr<TrackedEntity> te = *it;
|
||||||
if (te->e != player)
|
if (te->e != player) {
|
||||||
{
|
|
||||||
te->updatePlayer(this, player);
|
te->updatePlayer(this, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - We want to do this for dead players as they don't tick normally
|
// 4J Stu - We want to do this for dead players as they don't tick normally
|
||||||
for(AUTO_VAR(it, level->players.begin()); it != level->players.end(); ++it)
|
for (AUTO_VAR(it, level->players.begin()); it != level->players.end();
|
||||||
{
|
++it) {
|
||||||
std::shared_ptr<ServerPlayer> player = std::dynamic_pointer_cast<ServerPlayer>(*it);
|
std::shared_ptr<ServerPlayer> player =
|
||||||
if(!player->isAlive())
|
std::dynamic_pointer_cast<ServerPlayer>(*it);
|
||||||
{
|
if (!player->isAlive()) {
|
||||||
player->flushEntitiesToRemove();
|
player->flushEntitiesToRemove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::broadcast(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet)
|
void EntityTracker::broadcast(std::shared_ptr<Entity> e,
|
||||||
{
|
std::shared_ptr<Packet> packet) {
|
||||||
AUTO_VAR(it, entityMap.find(e->entityId));
|
AUTO_VAR(it, entityMap.find(e->entityId));
|
||||||
if( it != entityMap.end() )
|
if (it != entityMap.end()) {
|
||||||
{
|
|
||||||
std::shared_ptr<TrackedEntity> te = it->second;
|
std::shared_ptr<TrackedEntity> te = it->second;
|
||||||
te->broadcast(packet);
|
te->broadcast(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::broadcastAndSend(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet)
|
void EntityTracker::broadcastAndSend(std::shared_ptr<Entity> e,
|
||||||
{
|
std::shared_ptr<Packet> packet) {
|
||||||
AUTO_VAR(it, entityMap.find(e->entityId));
|
AUTO_VAR(it, entityMap.find(e->entityId));
|
||||||
if( it != entityMap.end() )
|
if (it != entityMap.end()) {
|
||||||
{
|
|
||||||
std::shared_ptr<TrackedEntity> te = it->second;
|
std::shared_ptr<TrackedEntity> te = it->second;
|
||||||
te->broadcastAndSend(packet);
|
te->broadcastAndSend(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityTracker::clear(std::shared_ptr<ServerPlayer> serverPlayer)
|
void EntityTracker::clear(std::shared_ptr<ServerPlayer> serverPlayer) {
|
||||||
{
|
for (AUTO_VAR(it, entities.begin()); it != entities.end(); it++) {
|
||||||
for( AUTO_VAR(it, entities.begin()); it != entities.end(); it++ )
|
|
||||||
{
|
|
||||||
std::shared_ptr<TrackedEntity> te = *it;
|
std::shared_ptr<TrackedEntity> te = *it;
|
||||||
te->clear(serverPlayer);
|
te->clear(serverPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AP added for Vita so the range can be increased once the level starts
|
// AP added for Vita so the range can be increased once the level starts
|
||||||
void EntityTracker::updateMaxRange()
|
void EntityTracker::updateMaxRange() {
|
||||||
{
|
|
||||||
maxRange = level->getServer()->getPlayers()->getMaxRange();
|
maxRange = level->getServer()->getPlayers()->getMaxRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<TrackedEntity> EntityTracker::getTracker(
|
||||||
std::shared_ptr<TrackedEntity> EntityTracker::getTracker(std::shared_ptr<Entity> e)
|
std::shared_ptr<Entity> e) {
|
||||||
{
|
|
||||||
AUTO_VAR(it, entityMap.find(e->entityId));
|
AUTO_VAR(it, entityMap.find(e->entityId));
|
||||||
if( it != entityMap.end() )
|
if (it != entityMap.end()) {
|
||||||
{
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,30 @@ class TrackedEntity;
|
||||||
class MinecraftServer;
|
class MinecraftServer;
|
||||||
class Packet;
|
class Packet;
|
||||||
|
|
||||||
|
class EntityTracker {
|
||||||
|
|
||||||
class EntityTracker
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
ServerLevel* level;
|
ServerLevel* level;
|
||||||
std::unordered_set<std::shared_ptr<TrackedEntity> > entities;
|
std::unordered_set<std::shared_ptr<TrackedEntity> > entities;
|
||||||
std::unordered_map<int, std::shared_ptr<TrackedEntity> , IntKeyHash2, IntKeyEq> entityMap; // was IntHashMap
|
std::unordered_map<int, std::shared_ptr<TrackedEntity>, IntKeyHash2,
|
||||||
|
IntKeyEq>
|
||||||
|
entityMap; // was IntHashMap
|
||||||
int maxRange;
|
int maxRange;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EntityTracker(ServerLevel* level);
|
EntityTracker(ServerLevel* level);
|
||||||
void addEntity(std::shared_ptr<Entity> e);
|
void addEntity(std::shared_ptr<Entity> e);
|
||||||
void addEntity(std::shared_ptr<Entity> e, int range, int updateInterval);
|
void addEntity(std::shared_ptr<Entity> e, int range, int updateInterval);
|
||||||
void addEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDeltas);
|
void addEntity(std::shared_ptr<Entity> e, int range, int updateInterval,
|
||||||
|
bool trackDeltas);
|
||||||
void removeEntity(std::shared_ptr<Entity> e);
|
void removeEntity(std::shared_ptr<Entity> e);
|
||||||
void removePlayer(std::shared_ptr<Entity> e); // 4J added
|
void removePlayer(std::shared_ptr<Entity> e); // 4J added
|
||||||
void tick();
|
void tick();
|
||||||
void broadcast(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet);
|
void broadcast(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet);
|
||||||
void broadcastAndSend(std::shared_ptr<Entity> e, std::shared_ptr<Packet> packet);
|
void broadcastAndSend(std::shared_ptr<Entity> e,
|
||||||
|
std::shared_ptr<Packet> packet);
|
||||||
void clear(std::shared_ptr<ServerPlayer> serverPlayer);
|
void clear(std::shared_ptr<ServerPlayer> serverPlayer);
|
||||||
void updateMaxRange(); // AP added for Vita
|
void updateMaxRange(); // AP added for Vita
|
||||||
|
|
||||||
|
|
||||||
// 4J-JEV: Added, needed access to tracked entity of a riders mount.
|
// 4J-JEV: Added, needed access to tracked entity of a riders mount.
|
||||||
std::shared_ptr<TrackedEntity> getTracker(std::shared_ptr<Entity> entity);
|
std::shared_ptr<TrackedEntity> getTracker(std::shared_ptr<Entity> entity);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -14,17 +14,15 @@ class Input;
|
||||||
class Stat;
|
class Stat;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Time in seconds before the players presence is update to Idle
|
// Time in seconds before the players presence is update to Idle
|
||||||
#define PLAYER_IDLE_TIME 300
|
#define PLAYER_IDLE_TIME 300
|
||||||
|
|
||||||
class LocalPlayer : public Player
|
class LocalPlayer : public Player {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static const int SPRINT_DURATION = 20 * 30;
|
static const int SPRINT_DURATION = 20 * 30;
|
||||||
|
|
||||||
Input* input;
|
Input* input;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Minecraft* minecraft;
|
Minecraft* minecraft;
|
||||||
int sprintTriggerTime;
|
int sprintTriggerTime;
|
||||||
|
|
@ -47,18 +45,24 @@ public:
|
||||||
LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension);
|
LocalPlayer(Minecraft* minecraft, Level* level, User* user, int dimension);
|
||||||
virtual ~LocalPlayer();
|
virtual ~LocalPlayer();
|
||||||
|
|
||||||
void move(double xa, double ya, double za, bool noEntityCubes=false); // 4J - added noEntityCubes parameter
|
void move(
|
||||||
|
double xa, double ya, double za,
|
||||||
|
bool noEntityCubes = false); // 4J - added noEntityCubes parameter
|
||||||
|
|
||||||
|
int m_iScreenSection; // assuming 4player splitscreen for now, or -1 for
|
||||||
int m_iScreenSection; // assuming 4player splitscreen for now, or -1 for single player
|
// single player
|
||||||
__uint64 ullButtonsPressed; // Stores the button presses, since the inputmanager can be ticked faster than the minecraft
|
__uint64
|
||||||
// player tick, and a button press and release combo can be missed in the minecraft::tick
|
ullButtonsPressed; // Stores the button presses, since the inputmanager
|
||||||
|
// can be ticked faster than the minecraft player
|
||||||
|
// tick, and a button press and release combo can be
|
||||||
|
// missed in the minecraft::tick
|
||||||
|
|
||||||
__uint64 ullDpad_last;
|
__uint64 ullDpad_last;
|
||||||
__uint64 ullDpad_this;
|
__uint64 ullDpad_this;
|
||||||
__uint64 ullDpad_filtered;
|
__uint64 ullDpad_filtered;
|
||||||
|
|
||||||
// 4J-PB - moved these in from the minecraft structure, since they are per player things for splitscreen
|
// 4J-PB - moved these in from the minecraft structure, since they are per
|
||||||
|
// player things for splitscreen
|
||||||
// int ticks;
|
// int ticks;
|
||||||
int missTime;
|
int missTime;
|
||||||
int lastClickTick[2];
|
int lastClickTick[2];
|
||||||
|
|
@ -101,13 +105,17 @@ public:
|
||||||
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
||||||
virtual void closeContainer();
|
virtual void closeContainer();
|
||||||
virtual void openTextEdit(std::shared_ptr<SignTileEntity> sign);
|
virtual void openTextEdit(std::shared_ptr<SignTileEntity> sign);
|
||||||
virtual bool openContainer(std::shared_ptr<Container> container); // 4J added bool return
|
virtual bool openContainer(
|
||||||
|
std::shared_ptr<Container> container); // 4J added bool return
|
||||||
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
|
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool startRepairing(int x, int y, int z);
|
virtual bool startRepairing(int x, int y, int z);
|
||||||
virtual bool openFurnace(std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
virtual bool openFurnace(
|
||||||
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return
|
std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
||||||
virtual bool openTrap(std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity>
|
||||||
|
brewingStand); // 4J added bool return
|
||||||
|
virtual bool openTrap(
|
||||||
|
std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
||||||
virtual bool openTrading(std::shared_ptr<Merchant> traderTarget);
|
virtual bool openTrading(std::shared_ptr<Merchant> traderTarget);
|
||||||
virtual void crit(std::shared_ptr<Entity> e);
|
virtual void crit(std::shared_ptr<Entity> e);
|
||||||
virtual void magicCrit(std::shared_ptr<Entity> e);
|
virtual void magicCrit(std::shared_ptr<Entity> e);
|
||||||
|
|
@ -121,12 +129,15 @@ public:
|
||||||
virtual void displayClientMessage(int messageId);
|
virtual void displayClientMessage(int messageId);
|
||||||
virtual void awardStat(Stat* stat, byteArray param);
|
virtual void awardStat(Stat* stat, byteArray param);
|
||||||
virtual int ThirdPersonView() { return m_iThirdPersonView; }
|
virtual int ThirdPersonView() { return m_iThirdPersonView; }
|
||||||
// 4J - have changed 3rd person view to be 0 if not enabled, 1 for mode like original, 2 reversed mode
|
// 4J - have changed 3rd person view to be 0 if not enabled, 1 for mode like
|
||||||
|
// original, 2 reversed mode
|
||||||
virtual void SetThirdPersonView(int val) { m_iThirdPersonView = val; }
|
virtual void SetThirdPersonView(int val) { m_iThirdPersonView = val; }
|
||||||
|
|
||||||
void ResetInactiveTicks() { m_uiInactiveTicks = 0; }
|
void ResetInactiveTicks() { m_uiInactiveTicks = 0; }
|
||||||
unsigned int GetInactiveTicks() { return m_uiInactiveTicks; }
|
unsigned int GetInactiveTicks() { return m_uiInactiveTicks; }
|
||||||
void IncrementInactiveTicks() { if(m_uiInactiveTicks<255) m_uiInactiveTicks++;}
|
void IncrementInactiveTicks() {
|
||||||
|
if (m_uiInactiveTicks < 255) m_uiInactiveTicks++;
|
||||||
|
}
|
||||||
|
|
||||||
void mapPlayerChunk(unsigned int);
|
void mapPlayerChunk(unsigned int);
|
||||||
// 4J-PB - xbox pad for this player
|
// 4J-PB - xbox pad for this player
|
||||||
|
|
@ -135,7 +146,8 @@ public:
|
||||||
void SetPlayerRespawned(bool bVal) { m_bPlayerRespawned = bVal; }
|
void SetPlayerRespawned(bool bVal) { m_bPlayerRespawned = bVal; }
|
||||||
bool GetPlayerRespawned() { return m_bPlayerRespawned; }
|
bool GetPlayerRespawned() { return m_bPlayerRespawned; }
|
||||||
|
|
||||||
// 4J-PB - Moved these in here from the minecraft structure since they are local player related
|
// 4J-PB - Moved these in here from the minecraft structure since they are
|
||||||
|
// local player related
|
||||||
void handleMouseDown(int button, bool down);
|
void handleMouseDown(int button, bool down);
|
||||||
bool handleMouseClick(int button);
|
bool handleMouseClick(int button);
|
||||||
|
|
||||||
|
|
@ -147,8 +159,7 @@ public:
|
||||||
float lastClickdX;
|
float lastClickdX;
|
||||||
float lastClickdY;
|
float lastClickdY;
|
||||||
float lastClickdZ;
|
float lastClickdZ;
|
||||||
enum eLastClickState
|
enum eLastClickState {
|
||||||
{
|
|
||||||
lastClick_invalid,
|
lastClick_invalid,
|
||||||
lastClick_init,
|
lastClick_init,
|
||||||
lastClick_moving,
|
lastClick_moving,
|
||||||
|
|
@ -159,7 +170,8 @@ public:
|
||||||
float lastClickTolerance;
|
float lastClickTolerance;
|
||||||
int lastClickState;
|
int lastClickState;
|
||||||
|
|
||||||
// 4J Stu - Added to allow callback to tutorial to stay within Minecraft.Client
|
// 4J Stu - Added to allow callback to tutorial to stay within
|
||||||
|
// Minecraft.Client
|
||||||
virtual void onCrafted(std::shared_ptr<ItemInstance> item);
|
virtual void onCrafted(std::shared_ptr<ItemInstance> item);
|
||||||
|
|
||||||
virtual void setAndBroadcastCustomSkin(std::uint32_t skinId);
|
virtual void setAndBroadcastCustomSkin(std::uint32_t skinId);
|
||||||
|
|
@ -174,7 +186,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setSprinting(bool value);
|
void setSprinting(bool value);
|
||||||
void setExperienceValues(float experienceProgress, int totalExp, int experienceLevel);
|
void setExperienceValues(float experienceProgress, int totalExp,
|
||||||
|
int experienceLevel);
|
||||||
|
|
||||||
bool hasPermission(EGameCommand command);
|
bool hasPermission(EGameCommand command);
|
||||||
|
|
||||||
|
|
@ -191,10 +204,9 @@ public:
|
||||||
float getAndResetChangeDimensionTimer();
|
float getAndResetChangeDimensionTimer();
|
||||||
|
|
||||||
virtual void handleCollectItem(std::shared_ptr<ItemInstance> item);
|
virtual void handleCollectItem(std::shared_ptr<ItemInstance> item);
|
||||||
void SetPlayerAdditionalModelParts(std::vector<ModelPart *>pAdditionalModelParts);
|
void SetPlayerAdditionalModelParts(
|
||||||
|
std::vector<ModelPart*> pAdditionalModelParts);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<ModelPart*> m_pAdditionalModelParts;
|
std::vector<ModelPart*> m_pAdditionalModelParts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,8 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.inventory.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.inventory.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.h"
|
||||||
|
|
||||||
MultiPlayerGameMode::MultiPlayerGameMode(Minecraft *minecraft, ClientConnection *connection)
|
MultiPlayerGameMode::MultiPlayerGameMode(Minecraft* minecraft,
|
||||||
{
|
ClientConnection* connection) {
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
xDestroyBlock = -1;
|
xDestroyBlock = -1;
|
||||||
yDestroyBlock = -1;
|
yDestroyBlock = -1;
|
||||||
|
|
@ -30,44 +30,35 @@ MultiPlayerGameMode::MultiPlayerGameMode(Minecraft *minecraft, ClientConnection
|
||||||
this->connection = connection;
|
this->connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::creativeDestroyBlock(Minecraft *minecraft, MultiPlayerGameMode *gameMode, int x, int y, int z, int face)
|
void MultiPlayerGameMode::creativeDestroyBlock(Minecraft* minecraft,
|
||||||
{
|
MultiPlayerGameMode* gameMode,
|
||||||
if (!minecraft->level->extinguishFire(minecraft->player, x, y, z, face))
|
int x, int y, int z, int face) {
|
||||||
{
|
if (!minecraft->level->extinguishFire(minecraft->player, x, y, z, face)) {
|
||||||
gameMode->destroyBlock(x, y, z, face);
|
gameMode->destroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::adjustPlayer(std::shared_ptr<Player> player)
|
void MultiPlayerGameMode::adjustPlayer(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
localPlayerMode->updatePlayerAbilities(&player->abilities);
|
localPlayerMode->updatePlayerAbilities(&player->abilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::isCutScene()
|
bool MultiPlayerGameMode::isCutScene() { return false; }
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiPlayerGameMode::setLocalMode(GameType *mode)
|
void MultiPlayerGameMode::setLocalMode(GameType* mode) {
|
||||||
{
|
|
||||||
localPlayerMode = mode;
|
localPlayerMode = mode;
|
||||||
localPlayerMode->updatePlayerAbilities(&minecraft->player->abilities);
|
localPlayerMode->updatePlayerAbilities(&minecraft->player->abilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::initPlayer(std::shared_ptr<Player> player)
|
void MultiPlayerGameMode::initPlayer(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
player->yRot = -180;
|
player->yRot = -180;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::canHurtPlayer()
|
bool MultiPlayerGameMode::canHurtPlayer() {
|
||||||
{
|
|
||||||
return localPlayerMode->isSurvival();
|
return localPlayerMode->isSurvival();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
|
bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
if (localPlayerMode->isReadOnly()) {
|
||||||
if (localPlayerMode->isReadOnly())
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,23 +67,22 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
|
||||||
|
|
||||||
if (oldTile == NULL) return false;
|
if (oldTile == NULL) return false;
|
||||||
|
|
||||||
level->levelEvent(LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, oldTile->id + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
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);
|
int data = level->getData(x, y, z);
|
||||||
bool changed = level->setTile(x, y, z, 0);
|
bool changed = level->setTile(x, y, z, 0);
|
||||||
if (changed)
|
if (changed) {
|
||||||
{
|
|
||||||
oldTile->destroy(level, x, y, z, data);
|
oldTile->destroy(level, x, y, z, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!localPlayerMode->isCreative())
|
if (!localPlayerMode->isCreative()) {
|
||||||
{
|
std::shared_ptr<ItemInstance> item =
|
||||||
std::shared_ptr<ItemInstance> item = minecraft->player->getSelectedItem();
|
minecraft->player->getSelectedItem();
|
||||||
if (item != NULL)
|
if (item != NULL) {
|
||||||
{
|
|
||||||
item->mineBlock(level, oldTile->id, x, y, z, minecraft->player);
|
item->mineBlock(level, oldTile->id, x, y, z, minecraft->player);
|
||||||
if (item->count == 0)
|
if (item->count == 0) {
|
||||||
{
|
|
||||||
minecraft->player->removeSelectedItem();
|
minecraft->player->removeSelectedItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -101,35 +91,35 @@ bool MultiPlayerGameMode::destroyBlock(int x, int y, int z, int face)
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
if (!minecraft->player->isAllowedToMine()) return;
|
if (!minecraft->player->isAllowedToMine()) return;
|
||||||
if (localPlayerMode->isReadOnly())
|
if (localPlayerMode->isReadOnly()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localPlayerMode->isCreative())
|
if (localPlayerMode->isCreative()) {
|
||||||
{
|
connection->send(
|
||||||
connection->send(std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ));
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
|
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
||||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
}
|
} else if (!isDestroying || x != xDestroyBlock || y != yDestroyBlock ||
|
||||||
else if (!isDestroying || x != xDestroyBlock || y != yDestroyBlock || z != zDestroyBlock)
|
z != zDestroyBlock) {
|
||||||
{
|
connection->send(
|
||||||
connection->send( std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) );
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
|
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
||||||
int t = minecraft->level->getTile(x, y, z);
|
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 && destroyProgress == 0)
|
||||||
|
Tile::tiles[t]->attack(minecraft->level, x, y, z,
|
||||||
|
minecraft->player);
|
||||||
if (t > 0 &&
|
if (t > 0 &&
|
||||||
(Tile::tiles[t]->getDestroyProgress(minecraft->player, minecraft->player->level, x, y, z) >= 1 ||
|
(Tile::tiles[t]->getDestroyProgress(
|
||||||
(app.DebugSettingsOn() && app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad())&(1L<<eDebugSetting_InstantDestroy))
|
minecraft->player, minecraft->player->level, x, y, z) >= 1 ||
|
||||||
)
|
(app.DebugSettingsOn() &&
|
||||||
)
|
app.GetGameSettingsDebugMask(ProfileManager.GetPrimaryPad()) &
|
||||||
{
|
(1L << eDebugSetting_InstantDestroy)))) {
|
||||||
destroyBlock(x, y, z, face);
|
destroyBlock(x, y, z, face);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
isDestroying = true;
|
isDestroying = true;
|
||||||
xDestroyBlock = x;
|
xDestroyBlock = x;
|
||||||
yDestroyBlock = y;
|
yDestroyBlock = y;
|
||||||
|
|
@ -137,72 +127,78 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
oDestroyProgress = 0;
|
||||||
destroyTicks = 0;
|
destroyTicks = 0;
|
||||||
minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, (int)(destroyProgress * 10) - 1);
|
minecraft->level->destroyTileProgress(
|
||||||
|
minecraft->player->entityId, xDestroyBlock, yDestroyBlock,
|
||||||
|
zDestroyBlock, (int)(destroyProgress * 10) - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
void MultiPlayerGameMode::stopDestroyBlock() {
|
||||||
|
if (isDestroying) {
|
||||||
void MultiPlayerGameMode::stopDestroyBlock()
|
connection->send(
|
||||||
{
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
if (isDestroying)
|
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
|
||||||
{
|
yDestroyBlock, zDestroyBlock, -1)));
|
||||||
connection->send(std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isDestroying = false;
|
isDestroying = false;
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1);
|
minecraft->level->destroyTileProgress(minecraft->player->entityId,
|
||||||
|
xDestroyBlock, yDestroyBlock,
|
||||||
|
zDestroyBlock, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face)
|
void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
if (!minecraft->player->isAllowedToMine()) return;
|
if (!minecraft->player->isAllowedToMine()) return;
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
// connection.send(new PlayerActionPacket(PlayerActionPacket.CONTINUE_DESTROY_BLOCK, x, y, z, face));
|
// connection.send(new
|
||||||
|
// PlayerActionPacket(PlayerActionPacket.CONTINUE_DESTROY_BLOCK, x,
|
||||||
|
// y, z, face));
|
||||||
|
|
||||||
if (destroyDelay > 0)
|
if (destroyDelay > 0) {
|
||||||
{
|
|
||||||
destroyDelay--;
|
destroyDelay--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localPlayerMode->isCreative())
|
if (localPlayerMode->isCreative()) {
|
||||||
{
|
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
connection->send(std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face) ) );
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
|
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)));
|
||||||
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
creativeDestroyBlock(minecraft, this, x, y, z, face);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock)
|
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
|
||||||
{
|
|
||||||
int t = minecraft->level->getTile(x, y, z);
|
int t = minecraft->level->getTile(x, y, z);
|
||||||
if (t == 0)
|
if (t == 0) {
|
||||||
{
|
|
||||||
isDestroying = false;
|
isDestroying = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Tile* tile = Tile::tiles[t];
|
Tile* tile = Tile::tiles[t];
|
||||||
|
|
||||||
destroyProgress += tile->getDestroyProgress(minecraft->player, minecraft->player->level, x, y, z);
|
destroyProgress += tile->getDestroyProgress(
|
||||||
|
minecraft->player, minecraft->player->level, x, y, z);
|
||||||
|
|
||||||
if (destroyTicks % 4 == 0)
|
if (destroyTicks % 4 == 0) {
|
||||||
{
|
if (tile != NULL) {
|
||||||
if (tile != NULL)
|
|
||||||
{
|
|
||||||
int iStepSound = tile->soundType->getStepSound();
|
int iStepSound = tile->soundType->getStepSound();
|
||||||
|
|
||||||
minecraft->soundEngine->play(iStepSound, x + 0.5f, y + 0.5f, z + 0.5f, (tile->soundType->getVolume() + 1) / 8, tile->soundType->getPitch() * 0.5f);
|
minecraft->soundEngine->play(
|
||||||
|
iStepSound, x + 0.5f, y + 0.5f, z + 0.5f,
|
||||||
|
(tile->soundType->getVolume() + 1) / 8,
|
||||||
|
tile->soundType->getPitch() * 0.5f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyTicks++;
|
destroyTicks++;
|
||||||
|
|
||||||
if (destroyProgress >= 1)
|
if (destroyProgress >= 1) {
|
||||||
{
|
|
||||||
isDestroying = false;
|
isDestroying = false;
|
||||||
connection->send( std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face) ) );
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
|
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)));
|
||||||
destroyBlock(x, y, z, face);
|
destroyBlock(x, y, z, face);
|
||||||
destroyProgress = 0;
|
destroyProgress = 0;
|
||||||
oDestroyProgress = 0;
|
oDestroyProgress = 0;
|
||||||
|
|
@ -210,48 +206,45 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face)
|
||||||
destroyDelay = 5;
|
destroyDelay = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, (int)(destroyProgress * 10) - 1);
|
minecraft->level->destroyTileProgress(
|
||||||
}
|
minecraft->player->entityId, xDestroyBlock, yDestroyBlock,
|
||||||
else
|
zDestroyBlock, (int)(destroyProgress * 10) - 1);
|
||||||
{
|
} else {
|
||||||
startDestroyBlock(x, y, z, face);
|
startDestroyBlock(x, y, z, face);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float MultiPlayerGameMode::getPickRange()
|
float MultiPlayerGameMode::getPickRange() {
|
||||||
{
|
if (localPlayerMode->isCreative()) {
|
||||||
if (localPlayerMode->isCreative())
|
|
||||||
{
|
|
||||||
return 5.0f;
|
return 5.0f;
|
||||||
}
|
}
|
||||||
return 4.5f;
|
return 4.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::tick()
|
void MultiPlayerGameMode::tick() {
|
||||||
{
|
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
oDestroyProgress = destroyProgress;
|
oDestroyProgress = destroyProgress;
|
||||||
// minecraft->soundEngine->playMusicTick();
|
// minecraft->soundEngine->playMusicTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::ensureHasSentCarriedItem()
|
void MultiPlayerGameMode::ensureHasSentCarriedItem() {
|
||||||
{
|
|
||||||
int newItem = minecraft->player->inventory->selected;
|
int newItem = minecraft->player->inventory->selected;
|
||||||
if (newItem != carriedItem)
|
if (newItem != carriedItem) {
|
||||||
{
|
|
||||||
carriedItem = newItem;
|
carriedItem = newItem;
|
||||||
connection->send( std::shared_ptr<SetCarriedItemPacket>( new SetCarriedItemPacket(carriedItem) ) );
|
connection->send(std::shared_ptr<SetCarriedItemPacket>(
|
||||||
|
new SetCarriedItemPacket(carriedItem)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly, bool *pbUsedItem)
|
bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player,
|
||||||
{
|
Level* level,
|
||||||
|
std::shared_ptr<ItemInstance> item, int x,
|
||||||
|
int y, int z, int face, Vec3* hit,
|
||||||
|
bool bTestUseOnly, bool* pbUsedItem) {
|
||||||
if (pbUsedItem) *pbUsedItem = false; // Did we actually use the held item?
|
if (pbUsedItem) *pbUsedItem = false; // Did we actually use the held item?
|
||||||
|
|
||||||
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||||
if(!bTestUseOnly)
|
if (!bTestUseOnly) {
|
||||||
{
|
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
}
|
}
|
||||||
float clickX = (float)hit->x - x;
|
float clickX = (float)hit->x - x;
|
||||||
|
|
@ -260,19 +253,16 @@ bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *level
|
||||||
bool didSomething = false;
|
bool didSomething = false;
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
|
|
||||||
if (t > 0 && player->isAllowedToUse(Tile::tiles[t]))
|
if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) {
|
||||||
{
|
if (bTestUseOnly) {
|
||||||
if(bTestUseOnly)
|
switch (t) {
|
||||||
{
|
|
||||||
switch(t)
|
|
||||||
{
|
|
||||||
case Tile::recordPlayer_Id:
|
case Tile::recordPlayer_Id:
|
||||||
case Tile::bed_Id: // special case for a bed
|
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;
|
return true;
|
||||||
}
|
} else if (t == Tile::bed_Id) // 4J-JEV: You can still use
|
||||||
else if (t==Tile::bed_Id) // 4J-JEV: You can still use items on record players (ie. set fire to them).
|
// items on record players
|
||||||
|
// (ie. set fire to them).
|
||||||
{
|
{
|
||||||
// bed is too far away, or something
|
// bed is too far away, or something
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -282,197 +272,206 @@ bool MultiPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *level
|
||||||
if (Tile::tiles[t]->TestUse()) return true;
|
if (Tile::tiles[t]->TestUse()) return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX,
|
||||||
{
|
clickY, clickZ))
|
||||||
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX, clickY, clickZ)) didSomething = true;
|
didSomething = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didSomething && item != NULL && dynamic_cast<TileItem *>(item->getItem()))
|
if (!didSomething && item != NULL &&
|
||||||
{
|
dynamic_cast<TileItem*>(item->getItem())) {
|
||||||
TileItem* tile = dynamic_cast<TileItem*>(item->getItem());
|
TileItem* tile = dynamic_cast<TileItem*>(item->getItem());
|
||||||
if (!tile->mayPlace(level, x, y, z, face, player, item)) return false;
|
if (!tile->mayPlace(level, x, y, z, face, player, item)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - In Java we send the use packet before the above check for item being NULL
|
// 4J Stu - In Java we send the use packet before the above check for item
|
||||||
// so the following never gets executed but the packet still gets sent (for opening chests etc)
|
// being NULL so the following never gets executed but the packet still gets
|
||||||
if(item != NULL)
|
// sent (for opening chests etc)
|
||||||
{
|
if (item != NULL) {
|
||||||
if(!didSomething && player->isAllowedToUse(item))
|
if (!didSomething && player->isAllowedToUse(item)) {
|
||||||
{
|
if (localPlayerMode->isCreative()) {
|
||||||
if (localPlayerMode->isCreative())
|
|
||||||
{
|
|
||||||
int aux = item->getAuxValue();
|
int aux = item->getAuxValue();
|
||||||
int count = item->count;
|
int count = item->count;
|
||||||
didSomething = item->useOn(player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnly);
|
didSomething = item->useOn(player, level, x, y, z, face, clickX,
|
||||||
|
clickY, clickZ, bTestUseOnly);
|
||||||
item->setAuxValue(aux);
|
item->setAuxValue(aux);
|
||||||
item->count = count;
|
item->count = count;
|
||||||
|
} else {
|
||||||
|
didSomething = item->useOn(player, level, x, y, z, face, clickX,
|
||||||
|
clickY, clickZ, bTestUseOnly);
|
||||||
}
|
}
|
||||||
else
|
if (didSomething) {
|
||||||
{
|
|
||||||
didSomething = item->useOn(player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnly);
|
|
||||||
}
|
|
||||||
if( didSomething )
|
|
||||||
{
|
|
||||||
if (pbUsedItem) *pbUsedItem = true;
|
if (pbUsedItem) *pbUsedItem = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
// 4J - Bit of a hack, however seems preferable to any larger changes
|
||||||
{
|
// which would have more chance of causing unwanted side effects. If we
|
||||||
// 4J - Bit of a hack, however seems preferable to any larger changes which would have more chance of causing unwanted side effects.
|
// aren't going to be actually performing the use method locally, then
|
||||||
// If we aren't going to be actually performing the use method locally, then call this method with its "soundOnly" parameter set to true.
|
// call this method with its "soundOnly" parameter set to true. This is
|
||||||
// This is an addition from the java version, and as its name suggests, doesn't actually perform the use locally but just makes any sounds that
|
// an addition from the java version, and as its name suggests, doesn't
|
||||||
// are meant to be directly caused by this. If we don't do this, then the sounds never happen as the tile's use method is only called on the
|
// actually perform the use locally but just makes any sounds that are
|
||||||
// server, and that won't allow any sounds that are directly made, or broadcast back level events to us that would make the sound, since we are
|
// meant to be directly caused by this. If we don't do this, then the
|
||||||
// the source of the event.
|
// sounds never happen as the tile's use method is only called on the
|
||||||
if( ( t > 0 ) && ( !bTestUseOnly ) && player->isAllowedToUse(Tile::tiles[t]) )
|
// server, and that won't allow any sounds that are directly made, or
|
||||||
{
|
// broadcast back level events to us that would make the sound, since we
|
||||||
Tile::tiles[t]->use(level, x, y, z, player, face, clickX, clickY, clickZ, true);
|
// are the source of the event.
|
||||||
|
if ((t > 0) && (!bTestUseOnly) &&
|
||||||
|
player->isAllowedToUse(Tile::tiles[t])) {
|
||||||
|
Tile::tiles[t]->use(level, x, y, z, player, face, clickX, clickY,
|
||||||
|
clickZ, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - Do the action before we send the packet, so that our predicted count is sent in the packet and the server
|
// 4J Stu - Do the action before we send the packet, so that our predicted
|
||||||
// doesn't think it has to update us
|
// count is sent in the packet and the server doesn't think it has to update
|
||||||
// Fix for #7904 - Gameplay: Players can dupe torches by throwing them repeatedly into water.
|
// us Fix for #7904 - Gameplay: Players can dupe torches by throwing them
|
||||||
if(!bTestUseOnly)
|
// repeatedly into water.
|
||||||
{
|
if (!bTestUseOnly) {
|
||||||
connection->send( std::shared_ptr<UseItemPacket>( new UseItemPacket(x, y, z, face, player->inventory->getSelected(), clickX, clickY, clickZ) ) );
|
connection->send(std::shared_ptr<UseItemPacket>(
|
||||||
|
new UseItemPacket(x, y, z, face, player->inventory->getSelected(),
|
||||||
|
clickX, clickY, clickZ)));
|
||||||
}
|
}
|
||||||
return didSomething;
|
return didSomething;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
|
bool MultiPlayerGameMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
{
|
std::shared_ptr<ItemInstance> item,
|
||||||
|
bool bTestUseOnly) {
|
||||||
if (!player->isAllowedToUse(item)) return false;
|
if (!player->isAllowedToUse(item)) return false;
|
||||||
|
|
||||||
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||||
if(!bTestUseOnly)
|
if (!bTestUseOnly) {
|
||||||
{
|
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - Do the action before we send the packet, so that our predicted count is sent in the packet and the server
|
// 4J Stu - Do the action before we send the packet, so that our predicted
|
||||||
// doesn't think it has to update us, or can update us if we are wrong
|
// count is sent in the packet and the server doesn't think it has to update
|
||||||
// Fix for #13120 - Using a bucket of water or lava in the spawn area (centre of the map) causes the inventory to get out of sync
|
// us, or can update us if we are wrong Fix for #13120 - Using a bucket of
|
||||||
|
// water or lava in the spawn area (centre of the map) causes the inventory
|
||||||
|
// to get out of sync
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
// 4J-PB added for tooltips to test use only
|
// 4J-PB added for tooltips to test use only
|
||||||
if(bTestUseOnly)
|
if (bTestUseOnly) {
|
||||||
{
|
|
||||||
result = item->TestUse(level, player);
|
result = item->TestUse(level, player);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int oldCount = item->count;
|
int oldCount = item->count;
|
||||||
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
||||||
if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount))
|
if ((itemInstance != NULL && itemInstance != item) ||
|
||||||
{
|
(itemInstance != NULL && itemInstance->count != oldCount)) {
|
||||||
player->inventory->items[player->inventory->selected] = itemInstance;
|
player->inventory->items[player->inventory->selected] =
|
||||||
if (itemInstance->count == 0)
|
itemInstance;
|
||||||
{
|
if (itemInstance->count == 0) {
|
||||||
player->inventory->items[player->inventory->selected] = nullptr;
|
player->inventory->items[player->inventory->selected] = nullptr;
|
||||||
}
|
}
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bTestUseOnly)
|
if (!bTestUseOnly) {
|
||||||
{
|
connection->send(std::shared_ptr<UseItemPacket>(new UseItemPacket(
|
||||||
connection->send( std::shared_ptr<UseItemPacket>( new UseItemPacket(-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0) ) );
|
-1, -1, -1, 255, player->inventory->getSelected(), 0, 0, 0)));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MultiplayerLocalPlayer> MultiPlayerGameMode::createPlayer(Level *level)
|
std::shared_ptr<MultiplayerLocalPlayer> MultiPlayerGameMode::createPlayer(
|
||||||
{
|
Level* level) {
|
||||||
return std::shared_ptr<MultiplayerLocalPlayer>( new MultiplayerLocalPlayer(minecraft, level, minecraft->user, connection) );
|
return std::shared_ptr<MultiplayerLocalPlayer>(new MultiplayerLocalPlayer(
|
||||||
|
minecraft, level, minecraft->user, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
void MultiPlayerGameMode::attack(std::shared_ptr<Player> player,
|
||||||
{
|
std::shared_ptr<Entity> entity) {
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
connection->send( std::shared_ptr<InteractPacket>( new InteractPacket(player->entityId, entity->entityId, InteractPacket::ATTACK) ) );
|
connection->send(std::shared_ptr<InteractPacket>(new InteractPacket(
|
||||||
|
player->entityId, entity->entityId, InteractPacket::ATTACK)));
|
||||||
player->attack(entity);
|
player->attack(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity)
|
bool MultiPlayerGameMode::interact(std::shared_ptr<Player> player,
|
||||||
{
|
std::shared_ptr<Entity> entity) {
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
connection->send(std::shared_ptr<InteractPacket>( new InteractPacket(player->entityId, entity->entityId, InteractPacket::INTERACT) ) );
|
connection->send(std::shared_ptr<InteractPacket>(new InteractPacket(
|
||||||
|
player->entityId, entity->entityId, InteractPacket::INTERACT)));
|
||||||
return player->interact(entity);
|
return player->interact(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ItemInstance> MultiPlayerGameMode::handleInventoryMouseClick(int containerId, int slotNum, int buttonNum, bool quickKeyHeld, std::shared_ptr<Player> player)
|
std::shared_ptr<ItemInstance> MultiPlayerGameMode::handleInventoryMouseClick(
|
||||||
{
|
int containerId, int slotNum, int buttonNum, bool quickKeyHeld,
|
||||||
|
std::shared_ptr<Player> player) {
|
||||||
short changeUid = player->containerMenu->backup(player->inventory);
|
short changeUid = player->containerMenu->backup(player->inventory);
|
||||||
|
|
||||||
std::shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(slotNum, buttonNum, quickKeyHeld?AbstractContainerMenu::CLICK_QUICK_MOVE:AbstractContainerMenu::CLICK_PICKUP, player);
|
std::shared_ptr<ItemInstance> clicked = player->containerMenu->clicked(
|
||||||
connection->send( std::shared_ptr<ContainerClickPacket>( new ContainerClickPacket(containerId, slotNum, buttonNum, quickKeyHeld, clicked, changeUid) ) );
|
slotNum, buttonNum,
|
||||||
|
quickKeyHeld ? AbstractContainerMenu::CLICK_QUICK_MOVE
|
||||||
|
: AbstractContainerMenu::CLICK_PICKUP,
|
||||||
|
player);
|
||||||
|
connection->send(std::shared_ptr<ContainerClickPacket>(
|
||||||
|
new ContainerClickPacket(containerId, slotNum, buttonNum, quickKeyHeld,
|
||||||
|
clicked, changeUid)));
|
||||||
|
|
||||||
return clicked;
|
return clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::handleInventoryButtonClick(int containerId, int buttonId)
|
void MultiPlayerGameMode::handleInventoryButtonClick(int containerId,
|
||||||
{
|
int buttonId) {
|
||||||
connection->send(std::shared_ptr<ContainerButtonClickPacket>( new ContainerButtonClickPacket(containerId, buttonId) ));
|
connection->send(std::shared_ptr<ContainerButtonClickPacket>(
|
||||||
|
new ContainerButtonClickPacket(containerId, buttonId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int slot)
|
void MultiPlayerGameMode::handleCreativeModeItemAdd(
|
||||||
{
|
std::shared_ptr<ItemInstance> clicked, int slot) {
|
||||||
if (localPlayerMode->isCreative())
|
if (localPlayerMode->isCreative()) {
|
||||||
{
|
connection->send(std::shared_ptr<SetCreativeModeSlotPacket>(
|
||||||
connection->send(std::shared_ptr<SetCreativeModeSlotPacket>( new SetCreativeModeSlotPacket(slot, clicked) ) );
|
new SetCreativeModeSlotPacket(slot, clicked)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked)
|
void MultiPlayerGameMode::handleCreativeModeItemDrop(
|
||||||
{
|
std::shared_ptr<ItemInstance> clicked) {
|
||||||
if (localPlayerMode->isCreative() && clicked != NULL)
|
if (localPlayerMode->isCreative() && clicked != NULL) {
|
||||||
{
|
connection->send(std::shared_ptr<SetCreativeModeSlotPacket>(
|
||||||
connection->send(std::shared_ptr<SetCreativeModeSlotPacket>( new SetCreativeModeSlotPacket(-1, clicked) ) );
|
new SetCreativeModeSlotPacket(-1, clicked)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::releaseUsingItem(std::shared_ptr<Player> player)
|
void MultiPlayerGameMode::releaseUsingItem(std::shared_ptr<Player> player) {
|
||||||
{
|
|
||||||
ensureHasSentCarriedItem();
|
ensureHasSentCarriedItem();
|
||||||
connection->send(std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255) ) );
|
connection->send(std::shared_ptr<PlayerActionPacket>(new PlayerActionPacket(
|
||||||
|
PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 255)));
|
||||||
player->releaseUsingItem();
|
player->releaseUsingItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::hasExperience()
|
bool MultiPlayerGameMode::hasExperience() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MultiPlayerGameMode::hasMissTime()
|
bool MultiPlayerGameMode::hasMissTime() {
|
||||||
{
|
|
||||||
return !localPlayerMode->isCreative();
|
return !localPlayerMode->isCreative();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::hasInfiniteItems()
|
bool MultiPlayerGameMode::hasInfiniteItems() {
|
||||||
{
|
|
||||||
return localPlayerMode->isCreative();
|
return localPlayerMode->isCreative();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::hasFarPickRange()
|
bool MultiPlayerGameMode::hasFarPickRange() {
|
||||||
{
|
|
||||||
return localPlayerMode->isCreative();
|
return localPlayerMode->isCreative();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiPlayerGameMode::handleCraftItem(int recipe, std::shared_ptr<Player> player)
|
bool MultiPlayerGameMode::handleCraftItem(int recipe,
|
||||||
{
|
std::shared_ptr<Player> player) {
|
||||||
short changeUid = player->containerMenu->backup(player->inventory);
|
short changeUid = player->containerMenu->backup(player->inventory);
|
||||||
|
|
||||||
connection->send( std::shared_ptr<CraftItemPacket>( new CraftItemPacket(recipe, changeUid) ) );
|
connection->send(std::shared_ptr<CraftItemPacket>(
|
||||||
|
new CraftItemPacket(recipe, changeUid)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player)
|
void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal,
|
||||||
{
|
std::shared_ptr<Player> player) {
|
||||||
player->SetDebugOptions(uiVal);
|
player->SetDebugOptions(uiVal);
|
||||||
connection->send( std::shared_ptr<DebugOptionsPacket>( new DebugOptionsPacket(uiVal) ) );
|
connection->send(
|
||||||
|
std::shared_ptr<DebugOptionsPacket>(new DebugOptionsPacket(uiVal)));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ class ClientConnection;
|
||||||
class GameType;
|
class GameType;
|
||||||
class Vec3;
|
class Vec3;
|
||||||
|
|
||||||
class MultiPlayerGameMode
|
class MultiPlayerGameMode {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
int xDestroyBlock;
|
int xDestroyBlock;
|
||||||
int yDestroyBlock;
|
int yDestroyBlock;
|
||||||
|
|
@ -24,7 +23,9 @@ protected:
|
||||||
public:
|
public:
|
||||||
MultiPlayerGameMode(Minecraft* minecraft, ClientConnection* connection);
|
MultiPlayerGameMode(Minecraft* minecraft, ClientConnection* connection);
|
||||||
virtual ~MultiPlayerGameMode() {}
|
virtual ~MultiPlayerGameMode() {}
|
||||||
static void creativeDestroyBlock(Minecraft *minecraft, MultiPlayerGameMode *gameMode, int x, int y, int z, int face);
|
static void creativeDestroyBlock(Minecraft* minecraft,
|
||||||
|
MultiPlayerGameMode* gameMode, int x,
|
||||||
|
int y, int z, int face);
|
||||||
void adjustPlayer(std::shared_ptr<Player> player);
|
void adjustPlayer(std::shared_ptr<Player> player);
|
||||||
bool isCutScene();
|
bool isCutScene();
|
||||||
void setLocalMode(GameType* mode);
|
void setLocalMode(GameType* mode);
|
||||||
|
|
@ -36,21 +37,34 @@ public:
|
||||||
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
virtual void continueDestroyBlock(int x, int y, int z, int face);
|
||||||
virtual float getPickRange();
|
virtual float getPickRange();
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int carriedItem;
|
int carriedItem;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ensureHasSentCarriedItem();
|
void ensureHasSentCarriedItem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, Vec3 *hit, bool bTestUseOnly=false, bool *pbUsedItem=NULL);
|
virtual bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||||
virtual bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
|
std::shared_ptr<ItemInstance> item, int x, int y,
|
||||||
|
int z, int face, Vec3* hit,
|
||||||
|
bool bTestUseOnly = false, bool* pbUsedItem = NULL);
|
||||||
|
virtual bool useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
|
std::shared_ptr<ItemInstance> item,
|
||||||
|
bool bTestUseOnly = false);
|
||||||
virtual std::shared_ptr<MultiplayerLocalPlayer> createPlayer(Level* level);
|
virtual std::shared_ptr<MultiplayerLocalPlayer> createPlayer(Level* level);
|
||||||
virtual void attack(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
virtual void attack(std::shared_ptr<Player> player,
|
||||||
virtual bool interact(std::shared_ptr<Player> player, std::shared_ptr<Entity> entity);
|
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 bool interact(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 handleInventoryButtonClick(int containerId, int buttonId);
|
virtual void handleInventoryButtonClick(int containerId, int buttonId);
|
||||||
virtual void handleCreativeModeItemAdd(std::shared_ptr<ItemInstance> clicked, int slot);
|
virtual void handleCreativeModeItemAdd(
|
||||||
virtual void handleCreativeModeItemDrop(std::shared_ptr<ItemInstance> clicked);
|
std::shared_ptr<ItemInstance> clicked, int slot);
|
||||||
|
virtual void handleCreativeModeItemDrop(
|
||||||
|
std::shared_ptr<ItemInstance> clicked);
|
||||||
virtual void releaseUsingItem(std::shared_ptr<Player> player);
|
virtual void releaseUsingItem(std::shared_ptr<Player> player);
|
||||||
virtual bool hasExperience();
|
virtual bool hasExperience();
|
||||||
virtual bool hasMissTime();
|
virtual bool hasMissTime();
|
||||||
|
|
@ -59,7 +73,8 @@ public:
|
||||||
|
|
||||||
// 4J Stu - Added so we can send packets for this in the network game
|
// 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 bool handleCraftItem(int recipe, std::shared_ptr<Player> player);
|
||||||
virtual void handleDebugOptions(unsigned int uiVal, std::shared_ptr<Player> player);
|
virtual void handleDebugOptions(unsigned int uiVal,
|
||||||
|
std::shared_ptr<Player> player);
|
||||||
|
|
||||||
// 4J Stu - Added for tutorial checks
|
// 4J Stu - Added for tutorial checks
|
||||||
virtual bool isInputAllowed(int mapping) { return true; }
|
virtual bool isInputAllowed(int mapping) { return true; }
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,10 @@
|
||||||
#include "../../Minecraft.World/Level/LevelData.h"
|
#include "../../Minecraft.World/Level/LevelData.h"
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.entity.item.h"
|
||||||
|
|
||||||
|
MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft* minecraft,
|
||||||
|
Level* level, User* user,
|
||||||
|
ClientConnection* connection)
|
||||||
MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft *minecraft, Level *level, User *user, ClientConnection *connection) : LocalPlayer(minecraft, level, user, level->dimension->id)
|
: LocalPlayer(minecraft, level, user, level->dimension->id) {
|
||||||
{
|
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
flashOnSetHealth = false;
|
flashOnSetHealth = false;
|
||||||
xLast = yLast1 = yLast2 = zLast = 0;
|
xLast = yLast1 = yLast2 = zLast = 0;
|
||||||
|
|
@ -31,26 +30,28 @@ MultiplayerLocalPlayer::MultiplayerLocalPlayer(Minecraft *minecraft, Level *leve
|
||||||
this->connection = connection;
|
this->connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiplayerLocalPlayer::hurt(DamageSource *source, int dmg)
|
bool MultiplayerLocalPlayer::hurt(DamageSource* source, int dmg) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::heal(int heal)
|
void MultiplayerLocalPlayer::heal(int heal) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::tick()
|
void MultiplayerLocalPlayer::tick() {
|
||||||
{
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
// 4J-PB - changing this to a game host option ot hide gamertags
|
// 4J-PB - changing this to a game host option ot hide gamertags
|
||||||
//bool bIsisPrimaryHost=g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad()==m_iPad);
|
// bool bIsisPrimaryHost=g_NetworkManager.IsHost() &&
|
||||||
|
// (ProfileManager.GetPrimaryPad()==m_iPad);
|
||||||
|
|
||||||
/*if((app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) != m_bShownOnMaps)
|
/*if((app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0) !=
|
||||||
|
m_bShownOnMaps)
|
||||||
{
|
{
|
||||||
m_bShownOnMaps = (app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0);
|
m_bShownOnMaps =
|
||||||
if (m_bShownOnMaps) connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::SHOW_ON_MAPS) ) );
|
(app.GetGameSettings(m_iPad,eGameSetting_PlayerVisibleInMap)!=0); if
|
||||||
else connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::HIDE_ON_MAPS) ) );
|
(m_bShownOnMaps) connection->send( std::shared_ptr<PlayerCommandPacket>( new
|
||||||
|
PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::SHOW_ON_MAPS) )
|
||||||
|
); else connection->send( std::shared_ptr<PlayerCommandPacket>( new
|
||||||
|
PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::HIDE_ON_MAPS) )
|
||||||
|
);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return;
|
if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return;
|
||||||
|
|
@ -58,43 +59,58 @@ void MultiplayerLocalPlayer::tick()
|
||||||
double tempX = x, tempY = y, tempZ = z;
|
double tempX = x, tempY = y, tempZ = z;
|
||||||
LocalPlayer::tick();
|
LocalPlayer::tick();
|
||||||
|
|
||||||
//if( !minecraft->localgameModes[m_iPad]->isTutorial() || minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(tempX, tempY, tempZ, x, y, z) )
|
// if( !minecraft->localgameModes[m_iPad]->isTutorial() ||
|
||||||
if(minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(tempX, tempY, tempZ, x, y, z))
|
// minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(tempX,
|
||||||
{
|
// tempY, tempZ, x, y, z) )
|
||||||
|
if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(
|
||||||
|
tempX, tempY, tempZ, x, y, z)) {
|
||||||
sendPosition();
|
sendPosition();
|
||||||
}
|
} else {
|
||||||
else
|
// app.Debugprintf("Cannot move to position (%f, %f, %f), falling back
|
||||||
{
|
// to (%f, %f, %f)\n", x, y, z, tempX, y, tempZ);
|
||||||
//app.Debugprintf("Cannot move to position (%f, %f, %f), falling back to (%f, %f, %f)\n", x, y, z, tempX, y, tempZ);
|
|
||||||
this->setPos(tempX, y, tempZ);
|
this->setPos(tempX, y, tempZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::sendPosition()
|
void MultiplayerLocalPlayer::sendPosition() {
|
||||||
{
|
|
||||||
bool sprinting = isSprinting();
|
bool sprinting = isSprinting();
|
||||||
if (sprinting != lastSprinting)
|
if (sprinting != lastSprinting) {
|
||||||
{
|
if (sprinting)
|
||||||
if (sprinting) connection->send(std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SPRINTING)));
|
connection->send(
|
||||||
else connection->send(std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)));
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::START_SPRINTING)));
|
||||||
|
else
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)));
|
||||||
|
|
||||||
lastSprinting = sprinting;
|
lastSprinting = sprinting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sneaking = isSneaking();
|
bool sneaking = isSneaking();
|
||||||
if (sneaking != lastSneaked)
|
if (sneaking != lastSneaked) {
|
||||||
{
|
if (sneaking)
|
||||||
if (sneaking) connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_SNEAKING) ) );
|
connection->send(
|
||||||
else connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SNEAKING) ) );
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::START_SNEAKING)));
|
||||||
|
else
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::STOP_SNEAKING)));
|
||||||
|
|
||||||
lastSneaked = sneaking;
|
lastSneaked = sneaking;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool idle = isIdle();
|
bool idle = isIdle();
|
||||||
if (idle != lastIdle)
|
if (idle != lastIdle) {
|
||||||
{
|
if (idle)
|
||||||
if (idle) connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::START_IDLEANIM) ) );
|
connection->send(
|
||||||
else connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM) ) );
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::START_IDLEANIM)));
|
||||||
|
else
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM)));
|
||||||
|
|
||||||
lastIdle = idle;
|
lastIdle = idle;
|
||||||
}
|
}
|
||||||
|
|
@ -106,207 +122,176 @@ void MultiplayerLocalPlayer::sendPosition()
|
||||||
double rydd = yRot - yRotLast;
|
double rydd = yRot - yRotLast;
|
||||||
double rxdd = xRot - xRotLast;
|
double rxdd = xRot - xRotLast;
|
||||||
|
|
||||||
bool move = (xdd * xdd + ydd1 * ydd1 + zdd * zdd) > 0.03 * 0.03 || positionReminder >= POSITION_REMINDER_INTERVAL;
|
bool move = (xdd * xdd + ydd1 * ydd1 + zdd * zdd) > 0.03 * 0.03 ||
|
||||||
|
positionReminder >= POSITION_REMINDER_INTERVAL;
|
||||||
bool rot = rydd != 0 || rxdd != 0;
|
bool rot = rydd != 0 || rxdd != 0;
|
||||||
if (riding != NULL)
|
if (riding != NULL) {
|
||||||
{
|
connection->send(
|
||||||
connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying) ) );
|
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::PosRot(
|
||||||
|
xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying)));
|
||||||
move = false;
|
move = false;
|
||||||
}
|
} else {
|
||||||
else
|
if (move && rot) {
|
||||||
{
|
connection->send(
|
||||||
if (move && rot)
|
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::PosRot(
|
||||||
{
|
x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying)));
|
||||||
connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::PosRot(x, bb->y0, y, z, yRot, xRot, onGround, abilities.flying) ) );
|
} else if (move) {
|
||||||
}
|
connection->send(
|
||||||
else if (move)
|
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::Pos(
|
||||||
{
|
x, bb->y0, y, z, onGround, abilities.flying)));
|
||||||
connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::Pos(x, bb->y0, y, z, onGround, abilities.flying) ) );
|
} else if (rot) {
|
||||||
}
|
connection->send(
|
||||||
else if (rot)
|
std::shared_ptr<MovePlayerPacket>(new MovePlayerPacket::Rot(
|
||||||
{
|
yRot, xRot, onGround, abilities.flying)));
|
||||||
connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket::Rot(yRot, xRot, onGround, abilities.flying) ) );
|
} else {
|
||||||
}
|
connection->send(std::shared_ptr<MovePlayerPacket>(
|
||||||
else
|
new MovePlayerPacket(onGround, abilities.flying)));
|
||||||
{
|
|
||||||
connection->send( std::shared_ptr<MovePlayerPacket>( new MovePlayerPacket(onGround, abilities.flying) ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
positionReminder++;
|
positionReminder++;
|
||||||
lastOnGround = onGround;
|
lastOnGround = onGround;
|
||||||
|
|
||||||
if (move)
|
if (move) {
|
||||||
{
|
|
||||||
xLast = x;
|
xLast = x;
|
||||||
yLast1 = bb->y0;
|
yLast1 = bb->y0;
|
||||||
yLast2 = y;
|
yLast2 = y;
|
||||||
zLast = z;
|
zLast = z;
|
||||||
positionReminder = 0;
|
positionReminder = 0;
|
||||||
}
|
}
|
||||||
if (rot)
|
if (rot) {
|
||||||
{
|
|
||||||
yRotLast = yRot;
|
yRotLast = yRot;
|
||||||
xRotLast = xRot;
|
xRotLast = xRot;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ItemEntity> MultiplayerLocalPlayer::drop()
|
std::shared_ptr<ItemEntity> MultiplayerLocalPlayer::drop() {
|
||||||
{
|
connection->send(std::shared_ptr<PlayerActionPacket>(
|
||||||
connection->send( std::shared_ptr<PlayerActionPacket>( new PlayerActionPacket(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0) ) );
|
new PlayerActionPacket(PlayerActionPacket::DROP_ITEM, 0, 0, 0, 0)));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::reallyDrop(std::shared_ptr<ItemEntity> itemEntity)
|
void MultiplayerLocalPlayer::reallyDrop(
|
||||||
{
|
std::shared_ptr<ItemEntity> itemEntity) {}
|
||||||
}
|
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::chat(const std::wstring& message)
|
void MultiplayerLocalPlayer::chat(const std::wstring& message) {
|
||||||
{
|
|
||||||
connection->send(std::shared_ptr<ChatPacket>(new ChatPacket(message)));
|
connection->send(std::shared_ptr<ChatPacket>(new ChatPacket(message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::swing()
|
void MultiplayerLocalPlayer::swing() {
|
||||||
{
|
|
||||||
LocalPlayer::swing();
|
LocalPlayer::swing();
|
||||||
connection->send( std::shared_ptr<AnimatePacket>( new AnimatePacket(shared_from_this(), AnimatePacket::SWING) ) );
|
connection->send(std::shared_ptr<AnimatePacket>(
|
||||||
|
new AnimatePacket(shared_from_this(), AnimatePacket::SWING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::respawn()
|
void MultiplayerLocalPlayer::respawn() {
|
||||||
{
|
connection->send(std::shared_ptr<ClientCommandPacket>(
|
||||||
connection->send( std::shared_ptr<ClientCommandPacket>( new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN)));
|
new ClientCommandPacket(ClientCommandPacket::PERFORM_RESPAWN)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiplayerLocalPlayer::actuallyHurt(DamageSource* source, int dmg) {
|
||||||
void MultiplayerLocalPlayer::actuallyHurt(DamageSource *source, int dmg)
|
|
||||||
{
|
|
||||||
setHealth(getHealth() - dmg);
|
setHealth(getHealth() - dmg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Added override to capture event for tutorial messages
|
// 4J Added override to capture event for tutorial messages
|
||||||
void MultiplayerLocalPlayer::completeUsingItem()
|
void MultiplayerLocalPlayer::completeUsingItem() {
|
||||||
{
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
if(useItem != NULL && pMinecraft->localgameModes[m_iPad] != NULL )
|
if (useItem != NULL && pMinecraft->localgameModes[m_iPad] != NULL) {
|
||||||
{
|
TutorialMode* gameMode =
|
||||||
TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
|
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||||
Tutorial* tutorial = gameMode->getTutorial();
|
Tutorial* tutorial = gameMode->getTutorial();
|
||||||
tutorial->completeUsingItem(useItem);
|
tutorial->completeUsingItem(useItem);
|
||||||
}
|
}
|
||||||
Player::completeUsingItem();
|
Player::completeUsingItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance *effect)
|
void MultiplayerLocalPlayer::onEffectAdded(MobEffectInstance* effect) {
|
||||||
{
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
if(pMinecraft->localgameModes[m_iPad] != NULL )
|
if (pMinecraft->localgameModes[m_iPad] != NULL) {
|
||||||
{
|
TutorialMode* gameMode =
|
||||||
TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
|
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||||
Tutorial* tutorial = gameMode->getTutorial();
|
Tutorial* tutorial = gameMode->getTutorial();
|
||||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||||
}
|
}
|
||||||
Player::onEffectAdded(effect);
|
Player::onEffectAdded(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance* effect) {
|
||||||
void MultiplayerLocalPlayer::onEffectUpdated(MobEffectInstance *effect)
|
|
||||||
{
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
if(pMinecraft->localgameModes[m_iPad] != NULL )
|
if (pMinecraft->localgameModes[m_iPad] != NULL) {
|
||||||
{
|
TutorialMode* gameMode =
|
||||||
TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
|
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||||
Tutorial* tutorial = gameMode->getTutorial();
|
Tutorial* tutorial = gameMode->getTutorial();
|
||||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
tutorial->onEffectChanged(MobEffect::effects[effect->getId()]);
|
||||||
}
|
}
|
||||||
Player::onEffectUpdated(effect);
|
Player::onEffectUpdated(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance* effect) {
|
||||||
void MultiplayerLocalPlayer::onEffectRemoved(MobEffectInstance *effect)
|
|
||||||
{
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
if(pMinecraft->localgameModes[m_iPad] != NULL )
|
if (pMinecraft->localgameModes[m_iPad] != NULL) {
|
||||||
{
|
TutorialMode* gameMode =
|
||||||
TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
|
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||||
Tutorial* tutorial = gameMode->getTutorial();
|
Tutorial* tutorial = gameMode->getTutorial();
|
||||||
tutorial->onEffectChanged(MobEffect::effects[effect->getId()], true);
|
tutorial->onEffectChanged(MobEffect::effects[effect->getId()], true);
|
||||||
}
|
}
|
||||||
Player::onEffectRemoved(effect);
|
Player::onEffectRemoved(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::closeContainer()
|
void MultiplayerLocalPlayer::closeContainer() {
|
||||||
{
|
connection->send(std::shared_ptr<ContainerClosePacket>(
|
||||||
connection->send( std::shared_ptr<ContainerClosePacket>( new ContainerClosePacket(containerMenu->containerId) ) );
|
new ContainerClosePacket(containerMenu->containerId)));
|
||||||
inventory->setCarried(nullptr);
|
inventory->setCarried(nullptr);
|
||||||
LocalPlayer::closeContainer();
|
LocalPlayer::closeContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::hurtTo(int newHealth, ETelemetryChallenges damageSource)
|
void MultiplayerLocalPlayer::hurtTo(int newHealth,
|
||||||
{
|
ETelemetryChallenges damageSource) {
|
||||||
if (flashOnSetHealth)
|
if (flashOnSetHealth) {
|
||||||
{
|
|
||||||
LocalPlayer::hurtTo(newHealth, damageSource);
|
LocalPlayer::hurtTo(newHealth, damageSource);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
setHealth(newHealth);
|
setHealth(newHealth);
|
||||||
flashOnSetHealth = true;
|
flashOnSetHealth = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::awardStat(Stat *stat, byteArray param)
|
void MultiplayerLocalPlayer::awardStat(Stat* stat, byteArray param) {
|
||||||
{
|
if (stat == NULL) {
|
||||||
if (stat == NULL)
|
|
||||||
{
|
|
||||||
delete[] param.data;
|
delete[] param.data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat->awardLocallyOnly)
|
if (stat->awardLocallyOnly) {
|
||||||
{
|
|
||||||
LocalPlayer::awardStat(stat, param);
|
LocalPlayer::awardStat(stat, param);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
delete[] param.data;
|
delete[] param.data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::awardStatFromServer(Stat *stat, byteArray param)
|
void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat, byteArray param) {
|
||||||
{
|
if (stat != NULL && !stat->awardLocallyOnly) {
|
||||||
if ( stat != NULL && !stat->awardLocallyOnly )
|
|
||||||
{
|
|
||||||
LocalPlayer::awardStat(stat, param);
|
LocalPlayer::awardStat(stat, param);
|
||||||
}
|
} else
|
||||||
else delete [] param.data;
|
delete[] param.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::onUpdateAbilities()
|
void MultiplayerLocalPlayer::onUpdateAbilities() {
|
||||||
{
|
connection->send(std::shared_ptr<PlayerAbilitiesPacket>(
|
||||||
connection->send(std::shared_ptr<PlayerAbilitiesPacket>(new PlayerAbilitiesPacket(&abilities)));
|
new PlayerAbilitiesPacket(&abilities)));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MultiplayerLocalPlayer::isLocalPlayer()
|
bool MultiplayerLocalPlayer::isLocalPlayer() { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e)
|
void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
|
||||||
{
|
|
||||||
bool wasRiding = riding != NULL;
|
bool wasRiding = riding != NULL;
|
||||||
LocalPlayer::ride(e);
|
LocalPlayer::ride(e);
|
||||||
bool isRiding = riding != NULL;
|
bool isRiding = riding != NULL;
|
||||||
|
|
||||||
if( isRiding )
|
if (isRiding) {
|
||||||
{
|
|
||||||
ETelemetryChallenges eventType = eTelemetryChallenges_Unknown;
|
ETelemetryChallenges eventType = eTelemetryChallenges_Unknown;
|
||||||
if( this->riding != NULL )
|
if (this->riding != NULL) {
|
||||||
{
|
switch (riding->GetType()) {
|
||||||
switch(riding->GetType())
|
|
||||||
{
|
|
||||||
case eTYPE_BOAT:
|
case eTYPE_BOAT:
|
||||||
eventType = eTelemetryInGame_Ride_Boat;
|
eventType = eTelemetryInGame_Ride_Boat;
|
||||||
break;
|
break;
|
||||||
|
|
@ -320,52 +305,61 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e)
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
TelemetryManager->RecordEnemyKilledOrOvercome(GetXboxPad(), 0, y, 0, 0, 0, 0, eventType);
|
TelemetryManager->RecordEnemyKilledOrOvercome(GetXboxPad(), 0, y, 0, 0,
|
||||||
|
0, 0, eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRichPresence();
|
updateRichPresence();
|
||||||
|
|
||||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||||
|
|
||||||
if( pMinecraft->localgameModes[m_iPad] != NULL )
|
if (pMinecraft->localgameModes[m_iPad] != NULL) {
|
||||||
{
|
TutorialMode* gameMode =
|
||||||
TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
|
(TutorialMode*)pMinecraft->localgameModes[m_iPad];
|
||||||
if(wasRiding && !isRiding)
|
if (wasRiding && !isRiding) {
|
||||||
{
|
gameMode->getTutorial()->changeTutorialState(
|
||||||
gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Gameplay);
|
e_Tutorial_State_Gameplay);
|
||||||
}
|
} else if (!wasRiding && isRiding) {
|
||||||
else if (!wasRiding && isRiding)
|
|
||||||
{
|
|
||||||
if (std::dynamic_pointer_cast<Minecart>(e) != NULL)
|
if (std::dynamic_pointer_cast<Minecart>(e) != NULL)
|
||||||
gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Riding_Minecart);
|
gameMode->getTutorial()->changeTutorialState(
|
||||||
|
e_Tutorial_State_Riding_Minecart);
|
||||||
else if (std::dynamic_pointer_cast<Boat>(e) != NULL)
|
else if (std::dynamic_pointer_cast<Boat>(e) != NULL)
|
||||||
gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Riding_Boat);
|
gameMode->getTutorial()->changeTutorialState(
|
||||||
|
e_Tutorial_State_Riding_Boat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::StopSleeping()
|
void MultiplayerLocalPlayer::StopSleeping() {
|
||||||
{
|
connection->send(
|
||||||
connection->send( std::shared_ptr<PlayerCommandPacket>( new PlayerCommandPacket(shared_from_this(), PlayerCommandPacket::STOP_SLEEPING) ) );
|
std::shared_ptr<PlayerCommandPacket>(new PlayerCommandPacket(
|
||||||
|
shared_from_this(), PlayerCommandPacket::STOP_SLEEPING)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId)
|
void MultiplayerLocalPlayer::setAndBroadcastCustomSkin(std::uint32_t skinId) {
|
||||||
{
|
|
||||||
std::uint32_t oldSkinIndex = getCustomSkin();
|
std::uint32_t oldSkinIndex = getCustomSkin();
|
||||||
LocalPlayer::setCustomSkin(skinId);
|
LocalPlayer::setCustomSkin(skinId);
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
wprintf(L"Skin for local player %ls has changed to %ls (%d)\n", name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin() );
|
wprintf(L"Skin for local player %ls has changed to %ls (%d)\n",
|
||||||
|
name.c_str(), customTextureUrl.c_str(), getPlayerDefaultSkin());
|
||||||
#endif
|
#endif
|
||||||
if(getCustomSkin() != oldSkinIndex) connection->send( std::shared_ptr<TextureAndGeometryChangePacket>( new TextureAndGeometryChangePacket( shared_from_this(), app.GetPlayerSkinName(GetXboxPad()) ) ) );
|
if (getCustomSkin() != oldSkinIndex)
|
||||||
|
connection->send(std::shared_ptr<TextureAndGeometryChangePacket>(
|
||||||
|
new TextureAndGeometryChangePacket(
|
||||||
|
shared_from_this(), app.GetPlayerSkinName(GetXboxPad()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId)
|
void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) {
|
||||||
{
|
|
||||||
std::uint32_t oldCapeIndex = getCustomCape();
|
std::uint32_t oldCapeIndex = getCustomCape();
|
||||||
LocalPlayer::setCustomCape(capeId);
|
LocalPlayer::setCustomCape(capeId);
|
||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(), customTextureUrl2.c_str());
|
wprintf(L"Cape for local player %ls has changed to %ls\n", name.c_str(),
|
||||||
|
customTextureUrl2.c_str());
|
||||||
#endif
|
#endif
|
||||||
if(getCustomCape() != oldCapeIndex) connection->send( std::shared_ptr<TextureChangePacket>( new TextureChangePacket( shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad()) ) ) );
|
if (getCustomCape() != oldCapeIndex)
|
||||||
|
connection->send(
|
||||||
|
std::shared_ptr<TextureChangePacket>(new TextureChangePacket(
|
||||||
|
shared_from_this(), TextureChangePacket::e_TextureChange_Cape,
|
||||||
|
app.GetPlayerCapeName(GetXboxPad()))));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,40 +7,51 @@ class ClientConnection;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
class Level;
|
class Level;
|
||||||
|
|
||||||
class MultiplayerLocalPlayer : public LocalPlayer
|
class MultiplayerLocalPlayer : public LocalPlayer {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int POSITION_REMINDER_INTERVAL = SharedConstants::TICKS_PER_SECOND;
|
static const int POSITION_REMINDER_INTERVAL =
|
||||||
|
SharedConstants::TICKS_PER_SECOND;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClientConnection* connection;
|
ClientConnection* connection;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool flashOnSetHealth;
|
bool flashOnSetHealth;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiplayerLocalPlayer(Minecraft *minecraft, Level *level, User *user, ClientConnection *connection);
|
MultiplayerLocalPlayer(Minecraft* minecraft, Level* level, User* user,
|
||||||
|
ClientConnection* connection);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double xLast, yLast1, yLast2, zLast;
|
double xLast, yLast1, yLast2, zLast;
|
||||||
float yRotLast, xRotLast;
|
float yRotLast, xRotLast;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool hurt(DamageSource* source, int dmg);
|
virtual bool hurt(DamageSource* source, int dmg);
|
||||||
virtual void heal(int heal);
|
virtual void heal(int heal);
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool lastOnGround;
|
bool lastOnGround;
|
||||||
bool lastSneaked;
|
bool lastSneaked;
|
||||||
bool lastIdle;
|
bool lastIdle;
|
||||||
bool lastSprinting;
|
bool lastSprinting;
|
||||||
int positionReminder;
|
int positionReminder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void sendPosition();
|
void sendPosition();
|
||||||
|
|
||||||
using Player::drop;
|
using Player::drop;
|
||||||
virtual std::shared_ptr<ItemEntity> drop();
|
virtual std::shared_ptr<ItemEntity> drop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void reallyDrop(std::shared_ptr<ItemEntity> itemEntity);
|
virtual void reallyDrop(std::shared_ptr<ItemEntity> itemEntity);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void chat(const std::wstring& message);
|
virtual void chat(const std::wstring& message);
|
||||||
virtual void swing();
|
virtual void swing();
|
||||||
virtual void respawn();
|
virtual void respawn();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void actuallyHurt(DamageSource* source, int dmg);
|
virtual void actuallyHurt(DamageSource* source, int dmg);
|
||||||
|
|
||||||
|
|
@ -51,6 +62,7 @@ protected:
|
||||||
virtual void onEffectAdded(MobEffectInstance* effect);
|
virtual void onEffectAdded(MobEffectInstance* effect);
|
||||||
virtual void onEffectUpdated(MobEffectInstance* effect);
|
virtual void onEffectUpdated(MobEffectInstance* effect);
|
||||||
virtual void onEffectRemoved(MobEffectInstance* effect);
|
virtual void onEffectRemoved(MobEffectInstance* effect);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void closeContainer();
|
virtual void closeContainer();
|
||||||
virtual void hurtTo(int newHealth, ETelemetryChallenges damageSource);
|
virtual void hurtTo(int newHealth, ETelemetryChallenges damageSource);
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
#include "../../Minecraft.World/Headers/net.minecraft.world.item.h"
|
||||||
#include "../../Minecraft.World/Util/Mth.h"
|
#include "../../Minecraft.World/Util/Mth.h"
|
||||||
|
|
||||||
RemotePlayer::RemotePlayer(Level *level, const std::wstring& name) : Player(level)
|
RemotePlayer::RemotePlayer(Level* level, const std::wstring& name)
|
||||||
{
|
: Player(level) {
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
hasStartedUsingItem = false;
|
hasStartedUsingItem = false;
|
||||||
lSteps = 0;
|
lSteps = 0;
|
||||||
|
|
@ -17,9 +17,9 @@ RemotePlayer::RemotePlayer(Level *level, const std::wstring& name) : Player(leve
|
||||||
|
|
||||||
heightOffset = 0;
|
heightOffset = 0;
|
||||||
this->footSize = 0;
|
this->footSize = 0;
|
||||||
if (name.length() > 0)
|
if (name.length() > 0) {
|
||||||
{
|
customTextureUrl = L""; // L"http://s3.amazonaws.com/MinecraftSkins/" +
|
||||||
customTextureUrl = L"";//L"http://s3.amazonaws.com/MinecraftSkins/" + name + L".png";
|
// name + L".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
this->noPhysics = true;
|
this->noPhysics = true;
|
||||||
|
|
@ -29,18 +29,12 @@ RemotePlayer::RemotePlayer(Level *level, const std::wstring& name) : Player(leve
|
||||||
this->viewScale = 10;
|
this->viewScale = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlayer::setDefaultHeadHeight()
|
void RemotePlayer::setDefaultHeadHeight() { heightOffset = 0; }
|
||||||
{
|
|
||||||
heightOffset = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RemotePlayer::hurt(DamageSource *source, int dmg)
|
bool RemotePlayer::hurt(DamageSource* source, int dmg) { return true; }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemotePlayer::lerpTo(double x, double y, double z, float yRot, float xRot, int steps)
|
void RemotePlayer::lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||||
{
|
int steps) {
|
||||||
// heightOffset = 0;
|
// heightOffset = 0;
|
||||||
lx = x;
|
lx = x;
|
||||||
ly = y;
|
ly = y;
|
||||||
|
|
@ -51,8 +45,7 @@ void RemotePlayer::lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||||
lSteps = steps;
|
lSteps = steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlayer::tick()
|
void RemotePlayer::tick() {
|
||||||
{
|
|
||||||
bedOffsetY = 0 / 16.0f;
|
bedOffsetY = 0 / 16.0f;
|
||||||
Player::tick();
|
Player::tick();
|
||||||
|
|
||||||
|
|
@ -64,14 +57,14 @@ void RemotePlayer::tick()
|
||||||
walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f;
|
walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f;
|
||||||
walkAnimPos += walkAnimSpeed;
|
walkAnimPos += walkAnimSpeed;
|
||||||
|
|
||||||
if (!hasStartedUsingItem && isUsingItemFlag() && inventory->items[inventory->selected] != NULL)
|
if (!hasStartedUsingItem && isUsingItemFlag() &&
|
||||||
{
|
inventory->items[inventory->selected] != NULL) {
|
||||||
std::shared_ptr<ItemInstance> item = inventory->items[inventory->selected];
|
std::shared_ptr<ItemInstance> item =
|
||||||
startUsingItem(inventory->items[inventory->selected], Item::items[item->id]->getUseDuration(item));
|
inventory->items[inventory->selected];
|
||||||
|
startUsingItem(inventory->items[inventory->selected],
|
||||||
|
Item::items[item->id]->getUseDuration(item));
|
||||||
hasStartedUsingItem = true;
|
hasStartedUsingItem = true;
|
||||||
}
|
} else if (hasStartedUsingItem && !isUsingItemFlag()) {
|
||||||
else if (hasStartedUsingItem && !isUsingItemFlag())
|
|
||||||
{
|
|
||||||
stopUsingItem();
|
stopUsingItem();
|
||||||
hasStartedUsingItem = false;
|
hasStartedUsingItem = false;
|
||||||
}
|
}
|
||||||
|
|
@ -89,25 +82,18 @@ void RemotePlayer::tick()
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
float RemotePlayer::getShadowHeightOffs()
|
float RemotePlayer::getShadowHeightOffs() { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemotePlayer::aiStep()
|
void RemotePlayer::aiStep() {
|
||||||
{
|
|
||||||
Player::serverAiStep();
|
Player::serverAiStep();
|
||||||
if (lSteps > 0)
|
if (lSteps > 0) {
|
||||||
{
|
|
||||||
double xt = x + (lx - x) / lSteps;
|
double xt = x + (lx - x) / lSteps;
|
||||||
double yt = y + (ly - y) / lSteps;
|
double yt = y + (ly - y) / lSteps;
|
||||||
double zt = z + (lz - z) / lSteps;
|
double zt = z + (lz - z) / lSteps;
|
||||||
|
|
||||||
double yrd = lyr - yRot;
|
double yrd = lyr - yRot;
|
||||||
while (yrd < -180)
|
while (yrd < -180) yrd += 360;
|
||||||
yrd += 360;
|
while (yrd >= 180) yrd -= 360;
|
||||||
while (yrd >= 180)
|
|
||||||
yrd -= 360;
|
|
||||||
|
|
||||||
yRot += (float)((yrd) / lSteps);
|
yRot += (float)((yrd) / lSteps);
|
||||||
xRot += (float)((lxr - xRot) / lSteps);
|
xRot += (float)((lxr - xRot) / lSteps);
|
||||||
|
|
@ -125,28 +111,22 @@ void RemotePlayer::aiStep()
|
||||||
if (onGround || getHealth() <= 0) tTilt = 0;
|
if (onGround || getHealth() <= 0) tTilt = 0;
|
||||||
bob += (tBob - bob) * 0.4f;
|
bob += (tBob - bob) * 0.4f;
|
||||||
tilt += (tTilt - tilt) * 0.8f;
|
tilt += (tTilt - tilt) * 0.8f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
|
// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer
|
||||||
void RemotePlayer::setEquippedSlot(int slot, std::shared_ptr<ItemInstance> item)
|
// Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for
|
||||||
{
|
// other players in online game
|
||||||
if (slot == 0)
|
void RemotePlayer::setEquippedSlot(int slot,
|
||||||
{
|
std::shared_ptr<ItemInstance> item) {
|
||||||
|
if (slot == 0) {
|
||||||
inventory->items[inventory->selected] = item;
|
inventory->items[inventory->selected] = item;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
inventory->armor[slot - 1] = item;
|
inventory->armor[slot - 1] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemotePlayer::animateRespawn()
|
void RemotePlayer::animateRespawn() {
|
||||||
{
|
|
||||||
// Player.animateRespawn(this, level);
|
// Player.animateRespawn(this, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
float RemotePlayer::getHeadHeight()
|
float RemotePlayer::getHeadHeight() { return 1.82f; }
|
||||||
{
|
|
||||||
return 1.82f;
|
|
||||||
}
|
|
||||||
|
|
@ -4,29 +4,38 @@
|
||||||
|
|
||||||
class Input;
|
class Input;
|
||||||
|
|
||||||
class RemotePlayer : public Player
|
class RemotePlayer : public Player {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
bool hasStartedUsingItem;
|
bool hasStartedUsingItem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Input* input;
|
Input* input;
|
||||||
RemotePlayer(Level* level, const std::wstring& name);
|
RemotePlayer(Level* level, const std::wstring& name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setDefaultHeadHeight();
|
virtual void setDefaultHeadHeight();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool hurt(DamageSource* source, int dmg);
|
virtual bool hurt(DamageSource* source, int dmg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int lSteps;
|
int lSteps;
|
||||||
double lx, ly, lz, lyr, lxr;
|
double lx, ly, lz, lyr, lxr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void lerpTo(double x, double y, double z, float yRot, float xRot, int steps);
|
virtual void lerpTo(double x, double y, double z, float yRot, float xRot,
|
||||||
|
int steps);
|
||||||
float fallTime;
|
float fallTime;
|
||||||
|
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
virtual float getShadowHeightOffs();
|
virtual float getShadowHeightOffs();
|
||||||
virtual void aiStep();
|
virtual void aiStep();
|
||||||
virtual void setEquippedSlot(int slot, std::shared_ptr<ItemInstance> item);// 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer Encountered: TU7: Content: Art: Aura of enchanted item is not displayed for other players in online game
|
virtual void setEquippedSlot(
|
||||||
|
int slot, std::shared_ptr<ItemInstance>
|
||||||
|
item); // 4J Stu - Brought forward change from 1.3 to fix
|
||||||
|
// #64688 - Customer Encountered: TU7: Content:
|
||||||
|
// Art: Aura of enchanted item is not displayed
|
||||||
|
// for other players in online game
|
||||||
virtual void animateRespawn();
|
virtual void animateRespawn();
|
||||||
virtual float getHeadHeight();
|
virtual float getHeadHeight();
|
||||||
bool hasPermission(EGameCommand command) { return false; }
|
bool hasPermission(EGameCommand command) { return false; }
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -12,9 +12,8 @@ class Entity;
|
||||||
class BrewingStandTileEntity;
|
class BrewingStandTileEntity;
|
||||||
class Merchant;
|
class Merchant;
|
||||||
|
|
||||||
|
class ServerPlayer : public Player,
|
||||||
class ServerPlayer : public Player, public net_minecraft_world_inventory::ContainerListener
|
public net_minecraft_world_inventory::ContainerListener {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
eINSTANCEOF GetType() { return eTYPE_SERVERPLAYER; }
|
eINSTANCEOF GetType() { return eTYPE_SERVERPLAYER; }
|
||||||
std::shared_ptr<PlayerConnection> connection;
|
std::shared_ptr<PlayerConnection> connection;
|
||||||
|
|
@ -39,9 +38,11 @@ private:
|
||||||
int lastBrupSendTickCount; // 4J Added
|
int lastBrupSendTickCount; // 4J Added
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerPlayer(MinecraftServer *server, Level *level, const std::wstring& name, ServerPlayerGameMode *gameMode);
|
ServerPlayer(MinecraftServer* server, Level* level,
|
||||||
|
const std::wstring& name, ServerPlayerGameMode* gameMode);
|
||||||
~ServerPlayer();
|
~ServerPlayer();
|
||||||
void flagEntitiesToBeRemoved(unsigned int *flags, bool *removedFound); // 4J added
|
void flagEntitiesToBeRemoved(unsigned int* flags,
|
||||||
|
bool* removedFound); // 4J added
|
||||||
|
|
||||||
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
virtual void readAdditionalSaveData(CompoundTag* entityTag);
|
||||||
virtual void addAdditonalSaveData(CompoundTag* entityTag);
|
virtual void addAdditonalSaveData(CompoundTag* entityTag);
|
||||||
|
|
@ -53,8 +54,10 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ItemInstanceArray getEquipmentSlots();
|
virtual ItemInstanceArray getEquipmentSlots();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void setDefaultHeadHeight();
|
virtual void setDefaultHeadHeight();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual float getHeadHeight();
|
virtual float getHeadHeight();
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
@ -63,27 +66,36 @@ public:
|
||||||
virtual void die(DamageSource* source);
|
virtual void die(DamageSource* source);
|
||||||
virtual bool hurt(DamageSource* dmgSource, int dmg);
|
virtual bool hurt(DamageSource* dmgSource, int dmg);
|
||||||
virtual bool isPlayerVersusPlayer();
|
virtual bool isPlayerVersusPlayer();
|
||||||
void doTick(bool sendChunks, bool dontDelayChunks = false, bool ignorePortal = false);
|
void doTick(bool sendChunks, bool dontDelayChunks = false,
|
||||||
|
bool ignorePortal = false);
|
||||||
void doTickA();
|
void doTickA();
|
||||||
void doChunkSendingTick(bool dontDelayChunks);
|
void doChunkSendingTick(bool dontDelayChunks);
|
||||||
void doTickB(bool ignorePortal);
|
void doTickB(bool ignorePortal);
|
||||||
virtual void changeDimension(int i);
|
virtual void changeDimension(int i);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void broadcast(std::shared_ptr<TileEntity> te, bool delay = false);
|
void broadcast(std::shared_ptr<TileEntity> te, bool delay = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void take(std::shared_ptr<Entity> e, int orgCount);
|
virtual void take(std::shared_ptr<Entity> e, int orgCount);
|
||||||
virtual void swing();
|
virtual void swing();
|
||||||
virtual BedSleepingResult startSleepInBed(int x, int y, int z, bool bTestUse = false);
|
virtual BedSleepingResult startSleepInBed(int x, int y, int z,
|
||||||
|
bool bTestUse = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, bool saveRespawnPoint);
|
virtual void stopSleepInBed(bool forcefulWakeUp, bool updateLevelList,
|
||||||
|
bool saveRespawnPoint);
|
||||||
virtual void ride(std::shared_ptr<Entity> e);
|
virtual void ride(std::shared_ptr<Entity> e);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void checkFallDamage(double ya, bool onGround);
|
virtual void checkFallDamage(double ya, bool onGround);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void doCheckFallDamage(double ya, bool onGround);
|
void doCheckFallDamage(double ya, bool onGround);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int containerCounter;
|
int containerCounter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool ignoreSlotUpdateHack;
|
bool ignoreSlotUpdateHack;
|
||||||
int latency;
|
int latency;
|
||||||
|
|
@ -97,19 +109,29 @@ public:
|
||||||
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
virtual bool startCrafting(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
|
virtual bool startEnchanting(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool startRepairing(int x, int y, int z); // 4J added bool return
|
virtual bool startRepairing(int x, int y, int z); // 4J added bool return
|
||||||
virtual bool openContainer(std::shared_ptr<Container> container); // 4J added bool return
|
virtual bool openContainer(
|
||||||
virtual bool openFurnace(std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
std::shared_ptr<Container> container); // 4J added bool return
|
||||||
virtual bool openTrap(std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
virtual bool openFurnace(
|
||||||
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity> brewingStand); // 4J added bool return
|
std::shared_ptr<FurnaceTileEntity> furnace); // 4J added bool return
|
||||||
virtual bool openTrading(std::shared_ptr<Merchant> traderTarget); // 4J added bool return
|
virtual bool openTrap(
|
||||||
virtual void slotChanged(AbstractContainerMenu *container, int slotIndex, std::shared_ptr<ItemInstance> item);
|
std::shared_ptr<DispenserTileEntity> trap); // 4J added bool return
|
||||||
|
virtual bool openBrewingStand(std::shared_ptr<BrewingStandTileEntity>
|
||||||
|
brewingStand); // 4J added bool return
|
||||||
|
virtual bool openTrading(
|
||||||
|
std::shared_ptr<Merchant> traderTarget); // 4J added bool return
|
||||||
|
virtual void slotChanged(AbstractContainerMenu* container, int slotIndex,
|
||||||
|
std::shared_ptr<ItemInstance> item);
|
||||||
void refreshContainer(AbstractContainerMenu* menu);
|
void refreshContainer(AbstractContainerMenu* menu);
|
||||||
virtual void refreshContainer(AbstractContainerMenu *container, std::vector<std::shared_ptr<ItemInstance> > *items);
|
virtual void refreshContainer(
|
||||||
virtual void setContainerData(AbstractContainerMenu *container, int id, int value);
|
AbstractContainerMenu* container,
|
||||||
|
std::vector<std::shared_ptr<ItemInstance> >* items);
|
||||||
|
virtual void setContainerData(AbstractContainerMenu* container, int id,
|
||||||
|
int value);
|
||||||
virtual void closeContainer();
|
virtual void closeContainer();
|
||||||
void broadcastCarriedItem();
|
void broadcastCarriedItem();
|
||||||
void doCloseContainer();
|
void doCloseContainer();
|
||||||
void setPlayerInput(float xa, float ya, bool jumping, bool sneaking, float xRot, float yRot);
|
void setPlayerInput(float xa, float ya, bool jumping, bool sneaking,
|
||||||
|
float xRot, float yRot);
|
||||||
|
|
||||||
virtual void awardStat(Stat* stat, byteArray param);
|
virtual void awardStat(Stat* stat, byteArray param);
|
||||||
|
|
||||||
|
|
@ -121,8 +143,10 @@ protected:
|
||||||
virtual void completeUsingItem();
|
virtual void completeUsingItem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void startUsingItem(std::shared_ptr<ItemInstance> instance, int duration);
|
virtual void startUsingItem(std::shared_ptr<ItemInstance> instance,
|
||||||
virtual void restoreFrom(std::shared_ptr<Player> oldPlayer, bool restoreAll);
|
int duration);
|
||||||
|
virtual void restoreFrom(std::shared_ptr<Player> oldPlayer,
|
||||||
|
bool restoreAll);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void onEffectAdded(MobEffectInstance* effect);
|
virtual void onEffectAdded(MobEffectInstance* effect);
|
||||||
|
|
@ -137,7 +161,10 @@ public:
|
||||||
void onUpdateAbilities();
|
void onUpdateAbilities();
|
||||||
ServerLevel* getLevel();
|
ServerLevel* getLevel();
|
||||||
void setGameMode(GameType* mode);
|
void setGameMode(GameType* mode);
|
||||||
void sendMessage(const std::wstring& message, ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom, int customData = -1, const std::wstring& additionalMessage = L"");
|
void sendMessage(
|
||||||
|
const std::wstring& message,
|
||||||
|
ChatPacket::EChatPacketMessage type = ChatPacket::e_ChatCustom,
|
||||||
|
int customData = -1, const std::wstring& additionalMessage = L"");
|
||||||
bool hasPermission(EGameCommand command);
|
bool hasPermission(EGameCommand command);
|
||||||
// 4J - Don't use
|
// 4J - Don't use
|
||||||
// void updateOptions(std::shared_ptr<ClientInformationPacket> packet);
|
// void updateOptions(std::shared_ptr<ClientInformationPacket> packet);
|
||||||
|
|
@ -146,9 +173,11 @@ public:
|
||||||
// int getChatVisibility();
|
// int getChatVisibility();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static int getFlagIndexForChunk(const ChunkPos& pos,
|
||||||
static int getFlagIndexForChunk(const ChunkPos& pos, int dimension); // 4J - added
|
int dimension); // 4J - added
|
||||||
int getPlayerViewDistanceModifier(); // 4J Added, returns a number which is subtracted from the default view distance
|
int getPlayerViewDistanceModifier(); // 4J Added, returns a number which is
|
||||||
|
// subtracted from the default view
|
||||||
|
// distance
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 4J Stu - Added hooks for the game rules
|
// 4J Stu - Added hooks for the game rules
|
||||||
|
|
@ -159,6 +188,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 4J Added to record telemetry of player deaths, this should store the last source of damage
|
// 4J Added to record telemetry of player deaths, this should store the last
|
||||||
|
// source of damage
|
||||||
ETelemetryChallenges m_lastDamageSource;
|
ETelemetryChallenges m_lastDamageSource;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@
|
||||||
#include "../Level/MultiPlayerLevel.h"
|
#include "../Level/MultiPlayerLevel.h"
|
||||||
#include "../Rendering/LevelRenderer.h"
|
#include "../Rendering/LevelRenderer.h"
|
||||||
|
|
||||||
ServerPlayerGameMode::ServerPlayerGameMode(Level *level)
|
ServerPlayerGameMode::ServerPlayerGameMode(Level* level) {
|
||||||
{
|
|
||||||
// 4J - added initialisers
|
// 4J - added initialisers
|
||||||
isDestroyingBlock = false;
|
isDestroyingBlock = false;
|
||||||
destroyProgressStart = 0;
|
destroyProgressStart = 0;
|
||||||
|
|
@ -32,113 +31,99 @@ ServerPlayerGameMode::ServerPlayerGameMode(Level *level)
|
||||||
m_gameRules = NULL;
|
m_gameRules = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerPlayerGameMode::~ServerPlayerGameMode()
|
ServerPlayerGameMode::~ServerPlayerGameMode() {
|
||||||
{
|
|
||||||
if (m_gameRules != NULL) delete m_gameRules;
|
if (m_gameRules != NULL) delete m_gameRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::setGameModeForPlayer(GameType *gameModeForPlayer)
|
void ServerPlayerGameMode::setGameModeForPlayer(GameType* gameModeForPlayer) {
|
||||||
{
|
|
||||||
this->gameModeForPlayer = gameModeForPlayer;
|
this->gameModeForPlayer = gameModeForPlayer;
|
||||||
|
|
||||||
gameModeForPlayer->updatePlayerAbilities(&(player->abilities));
|
gameModeForPlayer->updatePlayerAbilities(&(player->abilities));
|
||||||
player->onUpdateAbilities();
|
player->onUpdateAbilities();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameType *ServerPlayerGameMode::getGameModeForPlayer()
|
GameType* ServerPlayerGameMode::getGameModeForPlayer() {
|
||||||
{
|
|
||||||
return gameModeForPlayer;
|
return gameModeForPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::isSurvival()
|
bool ServerPlayerGameMode::isSurvival() {
|
||||||
{
|
|
||||||
return gameModeForPlayer->isSurvival();
|
return gameModeForPlayer->isSurvival();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::isCreative()
|
bool ServerPlayerGameMode::isCreative() {
|
||||||
{
|
|
||||||
return gameModeForPlayer->isCreative();
|
return gameModeForPlayer->isCreative();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::updateGameMode(GameType *gameType)
|
void ServerPlayerGameMode::updateGameMode(GameType* gameType) {
|
||||||
{
|
if (gameModeForPlayer == GameType::NOT_SET) {
|
||||||
if (gameModeForPlayer == GameType::NOT_SET)
|
|
||||||
{
|
|
||||||
gameModeForPlayer = gameType;
|
gameModeForPlayer = gameType;
|
||||||
}
|
}
|
||||||
setGameModeForPlayer(gameModeForPlayer);
|
setGameModeForPlayer(gameModeForPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::tick()
|
void ServerPlayerGameMode::tick() {
|
||||||
{
|
|
||||||
gameTicks++;
|
gameTicks++;
|
||||||
|
|
||||||
if (hasDelayedDestroy)
|
if (hasDelayedDestroy) {
|
||||||
{
|
|
||||||
int ticksSpentDestroying = gameTicks - delayedTickStart;
|
int ticksSpentDestroying = gameTicks - delayedTickStart;
|
||||||
int t = level->getTile(delayedDestroyX, delayedDestroyY, delayedDestroyZ);
|
int t =
|
||||||
if (t == 0)
|
level->getTile(delayedDestroyX, delayedDestroyY, delayedDestroyZ);
|
||||||
{
|
if (t == 0) {
|
||||||
hasDelayedDestroy = false;
|
hasDelayedDestroy = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Tile* tile = Tile::tiles[t];
|
Tile* tile = Tile::tiles[t];
|
||||||
float destroyProgress = tile->getDestroyProgress(player, player->level, delayedDestroyX, delayedDestroyY, delayedDestroyZ) * (ticksSpentDestroying + 1);
|
float destroyProgress =
|
||||||
|
tile->getDestroyProgress(player, player->level, delayedDestroyX,
|
||||||
|
delayedDestroyY, delayedDestroyZ) *
|
||||||
|
(ticksSpentDestroying + 1);
|
||||||
int state = (int)(destroyProgress * 10);
|
int state = (int)(destroyProgress * 10);
|
||||||
|
|
||||||
if (state != lastSentState)
|
if (state != lastSentState) {
|
||||||
{
|
level->destroyTileProgress(player->entityId, delayedDestroyX,
|
||||||
level->destroyTileProgress(player->entityId, delayedDestroyX, delayedDestroyY, delayedDestroyZ, state);
|
delayedDestroyY, delayedDestroyZ,
|
||||||
|
state);
|
||||||
lastSentState = state;
|
lastSentState = state;
|
||||||
}
|
}
|
||||||
if (destroyProgress >= 1)
|
if (destroyProgress >= 1) {
|
||||||
{
|
|
||||||
hasDelayedDestroy = false;
|
hasDelayedDestroy = false;
|
||||||
destroyBlock(delayedDestroyX, delayedDestroyY, delayedDestroyZ);
|
destroyBlock(delayedDestroyX, delayedDestroyY, delayedDestroyZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (isDestroyingBlock) {
|
||||||
else if (isDestroyingBlock)
|
|
||||||
{
|
|
||||||
int t = level->getTile(xDestroyBlock, yDestroyBlock, zDestroyBlock);
|
int t = level->getTile(xDestroyBlock, yDestroyBlock, zDestroyBlock);
|
||||||
Tile* tile = Tile::tiles[t];
|
Tile* tile = Tile::tiles[t];
|
||||||
|
|
||||||
if (tile == NULL)
|
if (tile == NULL) {
|
||||||
{
|
level->destroyTileProgress(player->entityId, xDestroyBlock,
|
||||||
level->destroyTileProgress(player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1);
|
yDestroyBlock, zDestroyBlock, -1);
|
||||||
lastSentState = -1;
|
lastSentState = -1;
|
||||||
isDestroyingBlock = false;
|
isDestroyingBlock = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
int ticksSpentDestroying = gameTicks - destroyProgressStart;
|
int ticksSpentDestroying = gameTicks - destroyProgressStart;
|
||||||
float destroyProgress = tile->getDestroyProgress(player, player->level, xDestroyBlock, yDestroyBlock, zDestroyBlock) * (ticksSpentDestroying + 1);
|
float destroyProgress =
|
||||||
|
tile->getDestroyProgress(player, player->level, xDestroyBlock,
|
||||||
|
yDestroyBlock, zDestroyBlock) *
|
||||||
|
(ticksSpentDestroying + 1);
|
||||||
int state = (int)(destroyProgress * 10);
|
int state = (int)(destroyProgress * 10);
|
||||||
|
|
||||||
if (state != lastSentState)
|
if (state != lastSentState) {
|
||||||
{
|
level->destroyTileProgress(player->entityId, xDestroyBlock,
|
||||||
level->destroyTileProgress(player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, state);
|
yDestroyBlock, zDestroyBlock, state);
|
||||||
lastSentState = state;
|
lastSentState = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||||
{
|
|
||||||
if (!player->isAllowedToMine()) return;
|
if (!player->isAllowedToMine()) return;
|
||||||
|
|
||||||
if (gameModeForPlayer->isReadOnly())
|
if (gameModeForPlayer->isReadOnly()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCreative())
|
if (isCreative()) {
|
||||||
{
|
if (!level->extinguishFire(nullptr, x, y, z, face)) {
|
||||||
if(!level->extinguishFire(nullptr, x, y, z, face))
|
|
||||||
{
|
|
||||||
destroyBlock(x, y, z);
|
destroyBlock(x, y, z);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -147,18 +132,17 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
||||||
destroyProgressStart = gameTicks;
|
destroyProgressStart = gameTicks;
|
||||||
float progress = 1.0f;
|
float progress = 1.0f;
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0)
|
if (t > 0) {
|
||||||
{
|
|
||||||
Tile::tiles[t]->attack(level, x, y, z, player);
|
Tile::tiles[t]->attack(level, x, y, z, player);
|
||||||
progress = Tile::tiles[t]->getDestroyProgress(player, player->level, x, y, z);
|
progress =
|
||||||
|
Tile::tiles[t]->getDestroyProgress(player, player->level, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > 0 && (progress >= 1 || (app.DebugSettingsOn() && (player->GetDebugOptions()&(1L<<eDebugSetting_InstantDestroy) ) )))
|
if (t > 0 && (progress >= 1 || (app.DebugSettingsOn() &&
|
||||||
{
|
(player->GetDebugOptions() &
|
||||||
|
(1L << eDebugSetting_InstantDestroy))))) {
|
||||||
destroyBlock(x, y, z);
|
destroyBlock(x, y, z);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
isDestroyingBlock = true;
|
isDestroyingBlock = true;
|
||||||
xDestroyBlock = x;
|
xDestroyBlock = x;
|
||||||
yDestroyBlock = y;
|
yDestroyBlock = y;
|
||||||
|
|
@ -169,21 +153,22 @@ void ServerPlayerGameMode::startDestroyBlock(int x, int y, int z, int face)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z)
|
void ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z) {
|
||||||
{
|
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
|
||||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock)
|
|
||||||
{
|
|
||||||
// int ticksSpentDestroying = gameTicks - destroyProgressStart;
|
// int ticksSpentDestroying = gameTicks - destroyProgressStart;
|
||||||
|
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
if (t != 0)
|
if (t != 0) {
|
||||||
{
|
|
||||||
Tile* tile = Tile::tiles[t];
|
Tile* tile = Tile::tiles[t];
|
||||||
|
|
||||||
// MGH - removed checking for the destroy progress here, it has already been checked on the client before it sent the packet.
|
// MGH - removed checking for the destroy progress here, it has
|
||||||
// fixes issues with this failing to destroy because of packets bunching up
|
// already been checked on the client before it sent the packet.
|
||||||
// float destroyProgress = tile->getDestroyProgress(player, player->level, x, y, z) * (ticksSpentDestroying + 1);
|
// fixes issues with this failing to destroy
|
||||||
// if (destroyProgress >= .7f || bIgnoreDestroyProgress)
|
//because of packets bunching up
|
||||||
|
// float destroyProgress =
|
||||||
|
// tile->getDestroyProgress(player, player->level, x, y,
|
||||||
|
// z) * (ticksSpentDestroying + 1); if (destroyProgress
|
||||||
|
// >= .7f || bIgnoreDestroyProgress)
|
||||||
{
|
{
|
||||||
isDestroyingBlock = false;
|
isDestroyingBlock = false;
|
||||||
level->destroyTileProgress(player->entityId, x, y, z, -1);
|
level->destroyTileProgress(player->entityId, x, y, z, -1);
|
||||||
|
|
@ -202,63 +187,65 @@ void ServerPlayerGameMode::stopDestroyBlock(int x, int y, int z)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::abortDestroyBlock(int x, int y, int z)
|
void ServerPlayerGameMode::abortDestroyBlock(int x, int y, int z) {
|
||||||
{
|
|
||||||
isDestroyingBlock = false;
|
isDestroyingBlock = false;
|
||||||
level->destroyTileProgress(player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1);
|
level->destroyTileProgress(player->entityId, xDestroyBlock, yDestroyBlock,
|
||||||
|
zDestroyBlock, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::superDestroyBlock(int x, int y, int z)
|
bool ServerPlayerGameMode::superDestroyBlock(int x, int y, int z) {
|
||||||
{
|
|
||||||
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
|
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
|
||||||
int data = level->getData(x, y, z);
|
int data = level->getData(x, y, z);
|
||||||
|
|
||||||
if (oldTile != NULL)
|
if (oldTile != NULL) {
|
||||||
{
|
|
||||||
oldTile->playerWillDestroy(level, x, y, z, data, player);
|
oldTile->playerWillDestroy(level, x, y, z, data, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed = level->setTile(x, y, z, 0);
|
bool changed = level->setTile(x, y, z, 0);
|
||||||
if (oldTile != NULL && changed)
|
if (oldTile != NULL && changed) {
|
||||||
{
|
|
||||||
oldTile->destroy(level, x, y, z, data);
|
oldTile->destroy(level, x, y, z, data);
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
bool ServerPlayerGameMode::destroyBlock(int x, int y, int z) {
|
||||||
{
|
if (gameModeForPlayer->isReadOnly()) {
|
||||||
if (gameModeForPlayer->isReadOnly())
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
int data = level->getData(x, y, z);
|
int data = level->getData(x, y, z);
|
||||||
|
|
||||||
level->levelEvent(player, LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z, t + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
level->levelEvent(player, LevelEvent::PARTICLES_DESTROY_BLOCK, x, y, z,
|
||||||
|
t + (level->getData(x, y, z) << Tile::TILE_NUM_SHIFT));
|
||||||
|
|
||||||
// 4J - In creative mode, the point where we need to tell the renderer that we are about to destroy a tile via destroyingTileAt is quite complicated.
|
// 4J - In creative mode, the point where we need to tell the renderer that
|
||||||
// If the player being told is remote, then we always want the client to do it as it does the final update. If the player being told is local,
|
// we are about to destroy a tile via destroyingTileAt is quite complicated.
|
||||||
// then we need to update the renderer Here if we are sharing data between host & client as this is the final point where the original data is still intact.
|
// If the player being told is remote, then we always want the client to do
|
||||||
// If the player being told is local, and we aren't sharing data between host & client, then we can just treat it as if it is a remote player and
|
// it as it does the final update. If the player being told is local, then
|
||||||
// it can update the renderer.
|
// we need to update the renderer Here if we are sharing data between host &
|
||||||
|
// client as this is the final point where the original data is still
|
||||||
|
// intact. If the player being told is local, and we aren't sharing data
|
||||||
|
// between host & client, then we can just treat it as if it is a remote
|
||||||
|
// player and it can update the renderer.
|
||||||
bool clientToUpdateRenderer = false;
|
bool clientToUpdateRenderer = false;
|
||||||
if( isCreative() )
|
if (isCreative()) {
|
||||||
{
|
|
||||||
clientToUpdateRenderer = true;
|
clientToUpdateRenderer = true;
|
||||||
if( std::dynamic_pointer_cast<ServerPlayer>(player)->connection->isLocal() )
|
if (std::dynamic_pointer_cast<ServerPlayer>(player)
|
||||||
{
|
->connection->isLocal()) {
|
||||||
// Establish whether we are sharing this chunk between client & server
|
// Establish whether we are sharing this chunk between client &
|
||||||
MultiPlayerLevel *clientLevel = Minecraft::GetInstance()->getLevel(level->dimension->id);
|
// server
|
||||||
if( clientLevel )
|
MultiPlayerLevel* clientLevel =
|
||||||
{
|
Minecraft::GetInstance()->getLevel(level->dimension->id);
|
||||||
|
if (clientLevel) {
|
||||||
LevelChunk* lc = clientLevel->getChunkAt(x, z);
|
LevelChunk* lc = clientLevel->getChunkAt(x, z);
|
||||||
#ifdef SHARING_ENABLED
|
#ifdef SHARING_ENABLED
|
||||||
if( lc->sharingTilesAndData )
|
if (lc->sharingTilesAndData) {
|
||||||
{
|
// We are sharing - this is the last point we can tell the
|
||||||
// We are sharing - this is the last point we can tell the renderer
|
// renderer
|
||||||
Minecraft::GetInstance()->levelRenderer->destroyedTileManager->destroyingTileAt( clientLevel, x, y, z );
|
Minecraft::GetInstance()
|
||||||
|
->levelRenderer->destroyedTileManager->destroyingTileAt(
|
||||||
|
clientLevel, x, y, z);
|
||||||
|
|
||||||
// Don't need to ask the client to do this too
|
// Don't need to ask the client to do this too
|
||||||
clientToUpdateRenderer = false;
|
clientToUpdateRenderer = false;
|
||||||
|
|
@ -270,76 +257,72 @@ bool ServerPlayerGameMode::destroyBlock(int x, int y, int z)
|
||||||
|
|
||||||
bool changed = superDestroyBlock(x, y, z);
|
bool changed = superDestroyBlock(x, y, z);
|
||||||
|
|
||||||
if (isCreative())
|
if (isCreative()) {
|
||||||
{
|
std::shared_ptr<TileUpdatePacket> tup =
|
||||||
std::shared_ptr<TileUpdatePacket> tup = std::shared_ptr<TileUpdatePacket>( new TileUpdatePacket(x, y, z, level) );
|
std::shared_ptr<TileUpdatePacket>(
|
||||||
// 4J - a bit of a hack here, but if we want to tell the client that it needs to inform the renderer of a block being destroyed, then send a block 255 instead of a 0. This is handled in ClientConnection::handleTileUpdate
|
new TileUpdatePacket(x, y, z, level));
|
||||||
if( tup->block == 0 )
|
// 4J - a bit of a hack here, but if we want to tell the client that it
|
||||||
{
|
// needs to inform the renderer of a block being destroyed, then send a
|
||||||
|
// block 255 instead of a 0. This is handled in
|
||||||
|
// ClientConnection::handleTileUpdate
|
||||||
|
if (tup->block == 0) {
|
||||||
if (clientToUpdateRenderer) tup->block = 255;
|
if (clientToUpdateRenderer) tup->block = 255;
|
||||||
}
|
}
|
||||||
player->connection->send(tup);
|
player->connection->send(tup);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
std::shared_ptr<ItemInstance> item = player->getSelectedItem();
|
std::shared_ptr<ItemInstance> item = player->getSelectedItem();
|
||||||
bool canDestroy = player->canDestroy(Tile::tiles[t]);
|
bool canDestroy = player->canDestroy(Tile::tiles[t]);
|
||||||
if (item != NULL)
|
if (item != NULL) {
|
||||||
{
|
|
||||||
item->mineBlock(level, t, x, y, z, player);
|
item->mineBlock(level, t, x, y, z, player);
|
||||||
if (item->count == 0)
|
if (item->count == 0) {
|
||||||
{
|
|
||||||
player->removeSelectedItem();
|
player->removeSelectedItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed && canDestroy)
|
if (changed && canDestroy) {
|
||||||
{
|
|
||||||
Tile::tiles[t]->playerDestroy(level, player, x, y, z, data);
|
Tile::tiles[t]->playerDestroy(level, player, x, y, z, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return changed;
|
return changed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly)
|
bool ServerPlayerGameMode::useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
{
|
std::shared_ptr<ItemInstance> item,
|
||||||
|
bool bTestUseOnly) {
|
||||||
if (!player->isAllowedToUse(item)) return false;
|
if (!player->isAllowedToUse(item)) return false;
|
||||||
|
|
||||||
int oldCount = item->count;
|
int oldCount = item->count;
|
||||||
int oldAux = item->getAuxValue();
|
int oldAux = item->getAuxValue();
|
||||||
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
std::shared_ptr<ItemInstance> itemInstance = item->use(level, player);
|
||||||
if ((itemInstance != NULL && itemInstance != item) || (itemInstance != NULL && itemInstance->count != oldCount) || (itemInstance != NULL && itemInstance->getUseDuration() > 0))
|
if ((itemInstance != NULL && itemInstance != item) ||
|
||||||
{
|
(itemInstance != NULL && itemInstance->count != oldCount) ||
|
||||||
|
(itemInstance != NULL && itemInstance->getUseDuration() > 0)) {
|
||||||
player->inventory->items[player->inventory->selected] = itemInstance;
|
player->inventory->items[player->inventory->selected] = itemInstance;
|
||||||
if (isCreative())
|
if (isCreative()) {
|
||||||
{
|
|
||||||
itemInstance->count = oldCount;
|
itemInstance->count = oldCount;
|
||||||
itemInstance->setAuxValue(oldAux);
|
itemInstance->setAuxValue(oldAux);
|
||||||
}
|
}
|
||||||
if (itemInstance->count == 0)
|
if (itemInstance->count == 0) {
|
||||||
{
|
|
||||||
player->inventory->items[player->inventory->selected] = nullptr;
|
player->inventory->items[player->inventory->selected] = nullptr;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServerPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly, bool *pbUsedItem)
|
bool ServerPlayerGameMode::useItemOn(std::shared_ptr<Player> player,
|
||||||
{
|
Level* level,
|
||||||
|
std::shared_ptr<ItemInstance> item, int x,
|
||||||
|
int y, int z, int face, float clickX,
|
||||||
|
float clickY, float clickZ,
|
||||||
|
bool bTestUseOnOnly, bool* pbUsedItem) {
|
||||||
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
||||||
int t = level->getTile(x, y, z);
|
int t = level->getTile(x, y, z);
|
||||||
if (t > 0 && player->isAllowedToUse(Tile::tiles[t]))
|
if (t > 0 && player->isAllowedToUse(Tile::tiles[t])) {
|
||||||
{
|
if (bTestUseOnOnly) {
|
||||||
if(bTestUseOnOnly)
|
|
||||||
{
|
|
||||||
if (Tile::tiles[t]->TestUse()) return true;
|
if (Tile::tiles[t]->TestUse()) return true;
|
||||||
}
|
} else {
|
||||||
else
|
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX,
|
||||||
{
|
clickY, clickZ)) {
|
||||||
if (Tile::tiles[t]->use(level, x, y, z, player, face, clickX, clickY, clickZ))
|
|
||||||
{
|
|
||||||
if (m_gameRules != NULL) m_gameRules->onUseTile(t, x, y, z);
|
if (m_gameRules != NULL) m_gameRules->onUseTile(t, x, y, z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -347,29 +330,24 @@ bool ServerPlayerGameMode::useItemOn(std::shared_ptr<Player> player, Level *leve
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item == NULL || !player->isAllowedToUse(item)) return false;
|
if (item == NULL || !player->isAllowedToUse(item)) return false;
|
||||||
if (isCreative())
|
if (isCreative()) {
|
||||||
{
|
|
||||||
int aux = item->getAuxValue();
|
int aux = item->getAuxValue();
|
||||||
int count = item->count;
|
int count = item->count;
|
||||||
bool success = item->useOn(player, level, x, y, z, face, clickX, clickY, clickZ);
|
bool success =
|
||||||
|
item->useOn(player, level, x, y, z, face, clickX, clickY, clickZ);
|
||||||
item->setAuxValue(aux);
|
item->setAuxValue(aux);
|
||||||
item->count = count;
|
item->count = count;
|
||||||
return success;
|
return success;
|
||||||
}
|
} else {
|
||||||
else
|
return item->useOn(player, level, x, y, z, face, clickX, clickY, clickZ,
|
||||||
{
|
bTestUseOnOnly);
|
||||||
return item->useOn(player, level, x, y, z, face, clickX, clickY, clickZ, bTestUseOnOnly);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerPlayerGameMode::setLevel(ServerLevel *newLevel)
|
void ServerPlayerGameMode::setLevel(ServerLevel* newLevel) { level = newLevel; }
|
||||||
{
|
|
||||||
level = newLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4J Added
|
// 4J Added
|
||||||
void ServerPlayerGameMode::setGameRules(GameRulesInstance *rules)
|
void ServerPlayerGameMode::setGameRules(GameRulesInstance* rules) {
|
||||||
{
|
|
||||||
if (m_gameRules != NULL) delete m_gameRules;
|
if (m_gameRules != NULL) delete m_gameRules;
|
||||||
m_gameRules = rules;
|
m_gameRules = rules;
|
||||||
}
|
}
|
||||||
|
|
@ -6,8 +6,7 @@ class ServerLevel;
|
||||||
class GameRulesInstance;
|
class GameRulesInstance;
|
||||||
class GameType;
|
class GameType;
|
||||||
|
|
||||||
class ServerPlayerGameMode
|
class ServerPlayerGameMode {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
Level* level;
|
Level* level;
|
||||||
std::shared_ptr<ServerPlayer> player;
|
std::shared_ptr<ServerPlayer> player;
|
||||||
|
|
@ -29,6 +28,7 @@ private:
|
||||||
private:
|
private:
|
||||||
// 4J Added
|
// 4J Added
|
||||||
GameRulesInstance* m_gameRules;
|
GameRulesInstance* m_gameRules;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setGameRules(GameRulesInstance* rules);
|
void setGameRules(GameRulesInstance* rules);
|
||||||
GameRulesInstance* getGameRules() { return m_gameRules; }
|
GameRulesInstance* getGameRules() { return m_gameRules; }
|
||||||
|
|
@ -53,8 +53,12 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool destroyBlock(int x, int y, int z);
|
bool destroyBlock(int x, int y, int z);
|
||||||
bool useItem(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, bool bTestUseOnly=false);
|
bool useItem(std::shared_ptr<Player> player, Level* level,
|
||||||
bool useItemOn(std::shared_ptr<Player> player, Level *level, std::shared_ptr<ItemInstance> item, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly=false, bool *pbUsedItem=NULL);
|
std::shared_ptr<ItemInstance> item, bool bTestUseOnly = false);
|
||||||
|
bool useItemOn(std::shared_ptr<Player> player, Level* level,
|
||||||
|
std::shared_ptr<ItemInstance> item, int x, int y, int z,
|
||||||
|
int face, float clickX, float clickY, float clickZ,
|
||||||
|
bool bTestUseOnOnly = false, bool* pbUsedItem = NULL);
|
||||||
|
|
||||||
void setLevel(ServerLevel* newLevel);
|
void setLevel(ServerLevel* newLevel);
|
||||||
};
|
};
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -4,13 +4,11 @@ class Entity;
|
||||||
#include "ServerPlayer.h"
|
#include "ServerPlayer.h"
|
||||||
class Packet;
|
class Packet;
|
||||||
|
|
||||||
|
|
||||||
class EntityTracker;
|
class EntityTracker;
|
||||||
|
|
||||||
#define TRACKED_ENTITY_MINIMUM_VIEW_DISTANCE 4
|
#define TRACKED_ENTITY_MINIMUM_VIEW_DISTANCE 4
|
||||||
|
|
||||||
class TrackedEntity
|
class TrackedEntity {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
static const int TOLERANCE_LEVEL = 4;
|
static const int TOLERANCE_LEVEL = 4;
|
||||||
|
|
||||||
|
|
@ -32,11 +30,15 @@ private:
|
||||||
public:
|
public:
|
||||||
bool moved;
|
bool moved;
|
||||||
|
|
||||||
std::unordered_set<std::shared_ptr<ServerPlayer> , PlayerKeyHash, PlayerKeyEq > seenBy;
|
std::unordered_set<std::shared_ptr<ServerPlayer>, PlayerKeyHash,
|
||||||
|
PlayerKeyEq>
|
||||||
|
seenBy;
|
||||||
|
|
||||||
TrackedEntity(std::shared_ptr<Entity> e, int range, int updateInterval, bool trackDelta);
|
TrackedEntity(std::shared_ptr<Entity> e, int range, int updateInterval,
|
||||||
|
bool trackDelta);
|
||||||
|
|
||||||
void tick(EntityTracker *tracker, std::vector<std::shared_ptr<Player> > *players);
|
void tick(EntityTracker* tracker,
|
||||||
|
std::vector<std::shared_ptr<Player> >* players);
|
||||||
void broadcast(std::shared_ptr<Packet> packet);
|
void broadcast(std::shared_ptr<Packet> packet);
|
||||||
void broadcastAndSend(std::shared_ptr<Packet> packet);
|
void broadcastAndSend(std::shared_ptr<Packet> packet);
|
||||||
void broadcastRemoved();
|
void broadcastRemoved();
|
||||||
|
|
@ -45,21 +47,25 @@ public:
|
||||||
private:
|
private:
|
||||||
bool canBySeenBy(std::shared_ptr<ServerPlayer> player);
|
bool canBySeenBy(std::shared_ptr<ServerPlayer> player);
|
||||||
|
|
||||||
enum eVisibility
|
enum eVisibility {
|
||||||
{
|
|
||||||
eVisibility_NotVisible = 0,
|
eVisibility_NotVisible = 0,
|
||||||
eVisibility_IsVisible = 1,
|
eVisibility_IsVisible = 1,
|
||||||
eVisibility_SeenAndVisible = 2,
|
eVisibility_SeenAndVisible = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
eVisibility isVisible(EntityTracker *tracker, std::shared_ptr<ServerPlayer> sp, bool forRider = false); // 4J Added forRider
|
eVisibility isVisible(EntityTracker* tracker,
|
||||||
|
std::shared_ptr<ServerPlayer> sp,
|
||||||
|
bool forRider = false); // 4J Added forRider
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void updatePlayer(EntityTracker* tracker, std::shared_ptr<ServerPlayer> sp);
|
void updatePlayer(EntityTracker* tracker, std::shared_ptr<ServerPlayer> sp);
|
||||||
void updatePlayers(EntityTracker *tracker, std::vector<std::shared_ptr<Player> > *players);
|
void updatePlayers(EntityTracker* tracker,
|
||||||
|
std::vector<std::shared_ptr<Player> >* players);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void sendEntityData(std::shared_ptr<PlayerConnection> conn);
|
void sendEntityData(std::shared_ptr<PlayerConnection> conn);
|
||||||
std::shared_ptr<Packet> getAddEntityPacket();
|
std::shared_ptr<Packet> getAddEntityPacket();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void clear(std::shared_ptr<ServerPlayer> sp);
|
void clear(std::shared_ptr<ServerPlayer> sp);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue