text:
#include "game.h"
#include "localplayer.h"
#include "map.h"
#include "tile.h"
#include "creature.h"
#include "container.h"
#include "statictext.h"
#include <framework/core/eventdispatcher.h>
#include <framework/ui/uimanager.h>
#include <framework/core/application.h>
#include "luavaluecasts.h"
#include "protocolgame.h"
#include "protocolcodes.h"

Game g_game;

Game::Game()
{
    m_protocolVersion = 0;
    m_clientCustomOs = -1;
    m_clientVersion = 0;
    m_online = false;
    m_denyBotCall = false;
    m_dead = false;
    m_serverBeat = 50;
    m_seq = 0;
    m_ping = -1;
    m_pingDelay = 1000;
    m_canReportBugs = false;
    m_fightMode = Otc::FightBalanced;
    m_chaseMode = Otc::DontChase;
    m_pvpMode = Otc::WhiteDove;
    m_safeFight = true;
}

void Game::init()
{
    resetGameStates();
}

void Game::terminate()
{
    resetGameStates();
    m_protocolGame = nullptr;
}

void Game::resetGameStates()
{
    m_online = false;
    m_denyBotCall = false;
    m_dead = false;
    m_serverBeat = 50;
    m_seq = 0;
    m_ping = -1;
    m_canReportBugs = false;
    m_fightMode = Otc::FightBalanced;
    m_chaseMode = Otc::DontChase;
    m_pvpMode = Otc::WhiteDove;
    m_safeFight = true;
    m_followingCreature = nullptr;
    m_attackingCreature = nullptr;
    m_localPlayer = nullptr;
    m_pingSent = 0;
    m_pingReceived = 0;
    m_unjustifiedPoints = UnjustifiedPoints();

    for(auto& it : m_containers) {
        const ContainerPtr& container = it.second;
        if(container)
            container->onClose();
    }

    if(m_pingEvent) {
        m_pingEvent->cancel();
        m_pingEvent = nullptr;
    }

    if(m_walkEvent) {
        m_walkEvent->cancel();
        m_walkEvent = nullptr;
    }

    if(m_checkConnectionEvent) {
        m_checkConnectionEvent->cancel();
        m_checkConnectionEvent = nullptr;
    }

    m_containers.clear();
    m_vips.clear();
    m_gmActions.clear();
    g_map.resetAwareRange();
}

void Game::processConnectionError(const boost::system::error_code& ec)
{
    // connection errors only have meaning if we still have a protocol
    if(m_protocolGame) {
        // eof = end of file, a clean disconnect
        if(ec != asio::error::eof)
            g_lua.callGlobalField("g_game", "onConnectionError", ec.message(), ec.value());

        processDisconnect();
    }
}

void Game::processDisconnect()
{
    if(isOnline())
        processGameEnd();

    if(m_protocolGame) {
        m_protocolGame->disconnect();
        m_protocolGame = nullptr;
    }
}

void Game::processUpdateNeeded(const std::string& signature)
{
    g_lua.callGlobalField("g_game", "onUpdateNeeded", signature);
}

void Game::processLoginError(const std::string& error)
{
    g_lua.callGlobalField("g_game", "onLoginError", error);
}

void Game::processLoginAdvice(const std::string& message)
{
    g_lua.callGlobalField("g_game", "onLoginAdvice", message);
}

void Game::processLoginWait(const std::string& message, int time)
{
    g_lua.callGlobalField("g_game", "onLoginWait", message, time);
}

void Game::processLoginToken(bool unknown)
{
    g_lua.callGlobalField("g_game", "onLoginToken", unknown);
}

void Game::processLogin()
{
    g_lua.callGlobalField("g_game", "onLogin");
}

void Game::processPendingGame()
{
    m_localPlayer->setPendingGame(true);
    g_lua.callGlobalField("g_game", "onPendingGame");
    m_protocolGame->sendEnterGame();
}

void Game::processEnterGame()
{
    m_localPlayer->setPendingGame(false);
    g_lua.callGlobalField("g_game", "onEnterGame");
}

void Game::processGameStart()
{
    m_online = true;

    // synchronize fight modes with the server
    m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);

    // NOTE: the entire map description and local player information is not known yet (bot call is allowed here)
    enableBotCall();
    g_lua.callGlobalField("g_game", "onGameStart");
    disableBotCall();

    if(g_game.getFeature(Otc::GameClientPing) || g_game.getFeature(Otc::GameExtendedClientPing)) {
        m_pingEvent = g_dispatcher.scheduleEvent([this] {
            g_game.ping();
        }, m_pingDelay);
    }

    m_checkConnectionEvent = g_dispatcher.cycleEvent([this] {
        if(!g_game.isConnectionOk() && !m_connectionFailWarned) {
            g_lua.callGlobalField("g_game", "onConnectionFailing", true);
            m_connectionFailWarned = true;
        } else if(g_game.isConnectionOk() && m_connectionFailWarned) {
            g_lua.callGlobalField("g_game", "onConnectionFailing", false);
            m_connectionFailWarned = false;
        }
    }, 1000);
}

void Game::processGameEnd()
{
    m_online = false;
    g_lua.callGlobalField("g_game", "onGameEnd");

    if(m_connectionFailWarned) {
        g_lua.callGlobalField("g_game", "onConnectionFailing", false);
        m_connectionFailWarned = false;
    }

    // reset game state
    resetGameStates();

    m_worldName = "";
    m_characterName = "";

    // clean map creatures
    g_map.cleanDynamicThings();
}

void Game::processDeath(int deathType, int penality)
{
    m_dead = true;
    m_localPlayer->stopWalk();

    g_lua.callGlobalField("g_game", "onDeath", deathType, penality);
}

void Game::processGMActions(const std::vector<uint8>& actions)
{
    m_gmActions = actions;
    g_lua.callGlobalField("g_game", "onGMActions", actions);
}

void Game::processPlayerHelpers(int helpers)
{
    g_lua.callGlobalField("g_game", "onPlayerHelpersUpdate", helpers);
}

void Game::processPlayerModes(Otc::FightModes fightMode, Otc::ChaseModes chaseMode, bool safeMode, Otc::PVPModes pvpMode)
{
    m_fightMode = fightMode;
    m_chaseMode = chaseMode;
    m_safeFight = safeMode;
    m_pvpMode = pvpMode;

    g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
    g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
    g_lua.callGlobalField("g_game", "onSafeFightChange", safeMode);
    g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
}

void Game::processPing()
{
    g_lua.callGlobalField("g_game", "onPing");
    enableBotCall();
    m_protocolGame->sendPingBack();
    disableBotCall();
}

void Game::processPingBack()
{
    m_pingReceived++;

    if(m_pingReceived == m_pingSent)
        m_ping = m_pingTimer.elapsed_millis();
    else
        g_logger.error("got an invalid ping from server");

    g_lua.callGlobalField("g_game", "onPingBack", m_ping);

    m_pingEvent = g_dispatcher.scheduleEvent([this] {
        g_game.ping();
    }, m_pingDelay);
}

void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
{
    g_lua.callGlobalField("g_game", "onTextMessage", mode, text);
}

void Game::processTalk(const std::string& name, int level, Otc::MessageMode mode, const std::string& text, int channelId, const Position& pos)
{
    g_lua.callGlobalField("g_game", "onTalk", name, level, mode, text, channelId, pos);
}

void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, const std::string& name, int capacity, bool hasParent, const std::vector<ItemPtr>& items, bool isUnlocked, bool hasPages, int containerSize, int firstIndex)
{
    ContainerPtr previousContainer = getContainer(containerId);
    ContainerPtr container = ContainerPtr(new Container(containerId, capacity, name, containerItem, hasParent, isUnlocked, hasPages, containerSize, firstIndex));
    m_containers[containerId] = container;
    container->onAddItems(items);

    // we might want to close a container here
    enableBotCall();
    container->onOpen(previousContainer);
    disableBotCall();

    if(previousContainer)
        previousContainer->onClose();
}

void Game::processCloseContainer(int containerId)
{
    ContainerPtr container = getContainer(containerId);
    if(!container) {
        return;
    }

    m_containers[containerId] = nullptr;
    container->onClose();
}

void Game::processContainerAddItem(int containerId, const ItemPtr& item, int slot)
{
    ContainerPtr container = getContainer(containerId);
    if(!container) {
        return;
    }

    container->onAddItem(item, slot);
}

void Game::processContainerUpdateItem(int containerId, int slot, const ItemPtr& item)
{
    ContainerPtr container = getContainer(containerId);
    if(!container) {
        return;
    }

    container->onUpdateItem(slot, item);
}

void Game::processContainerRemoveItem(int containerId, int slot, const ItemPtr& lastItem)
{
    ContainerPtr container = getContainer(containerId);
    if(!container) {
        return;
    }

    container->onRemoveItem(slot, lastItem);
}

void Game::processInventoryChange(int slot, const ItemPtr& item)
{
    if(item)
        item->setPosition(Position(65535, slot, 0));

    m_localPlayer->setInventoryItem((Otc::InventorySlot)slot, item);
}

void Game::processChannelList(const std::vector<std::tuple<int, std::string> >& channelList)
{
    g_lua.callGlobalField("g_game", "onChannelList", channelList);
}

void Game::processOpenChannel(int channelId, const std::string& name)
{
    g_lua.callGlobalField("g_game", "onOpenChannel", channelId, name);
}

void Game::processOpenPrivateChannel(const std::string& name)
{
    g_lua.callGlobalField("g_game", "onOpenPrivateChannel", name);
}

void Game::processOpenOwnPrivateChannel(int channelId, const std::string& name)
{
    g_lua.callGlobalField("g_game", "onOpenOwnPrivateChannel", channelId, name);
}

void Game::processCloseChannel(int channelId)
{
    g_lua.callGlobalField("g_game", "onCloseChannel", channelId);
}

void Game::processRuleViolationChannel(int channelId)
{
    g_lua.callGlobalField("g_game", "onRuleViolationChannel", channelId);
}

void Game::processRuleViolationRemove(const std::string& name)
{
    g_lua.callGlobalField("g_game", "onRuleViolationRemove", name);
}

void Game::processRuleViolationCancel(const std::string& name)
{
    g_lua.callGlobalField("g_game", "onRuleViolationCancel", name);
}

void Game::processRuleViolationLock()
{
    g_lua.callGlobalField("g_game", "onRuleViolationLock");
}

void Game::processVipAdd(uint id, const std::string& name, uint status, const std::string& description, int iconId, bool notifyLogin)
{
    m_vips[id] = Vip(name, status, description, iconId, notifyLogin);
    g_lua.callGlobalField("g_game", "onAddVip", id, name, status, description, iconId, notifyLogin);
}

void Game::processVipStateChange(uint id, uint status)
{
    std::get<1>(m_vips[id]) = status;
    g_lua.callGlobalField("g_game", "onVipStateChange", id, status);
}

void Game::processTutorialHint(int id)
{
    g_lua.callGlobalField("g_game", "onTutorialHint", id);
}

void Game::processAddAutomapFlag(const Position& pos, int icon, const std::string& message)
{
    g_lua.callGlobalField("g_game", "onAddAutomapFlag", pos, icon, message);
}

void Game::processRemoveAutomapFlag(const Position& pos, int icon, const std::string& message)
{
    g_lua.callGlobalField("g_game", "onRemoveAutomapFlag", pos, icon, message);
}

void Game::processOpenOutfitWindow(const Outfit& currentOufit, const std::vector<std::tuple<int, std::string, int> >& outfitList,
                                   const std::vector<std::tuple<int, std::string> >& mountList)
{
    // create virtual creature outfit
    CreaturePtr virtualOutfitCreature = CreaturePtr(new Creature);
    virtualOutfitCreature->setDirection(Otc::South);

    Outfit outfit = currentOufit;
    outfit.setMount(0);
    virtualOutfitCreature->setOutfit(outfit);

    // creature virtual mount outfit
    CreaturePtr virtualMountCreature = nullptr;
    if(getFeature(Otc::GamePlayerMounts))
    {
        virtualMountCreature = CreaturePtr(new Creature);
        virtualMountCreature->setDirection(Otc::South);

        Outfit mountOutfit;
        mountOutfit.setId(0);

        int mount = currentOufit.getMount();
        if(mount > 0)
            mountOutfit.setId(mount);

        virtualMountCreature->setOutfit(mountOutfit);
    }

    g_lua.callGlobalField("g_game", "onOpenOutfitWindow", virtualOutfitCreature, outfitList, virtualMountCreature, mountList);
}

void Game::processOpenNpcTrade(const std::vector<std::tuple<ItemPtr, std::string, int, int, int> >& items)
{
    g_lua.callGlobalField("g_game", "onOpenNpcTrade", items);
}

void Game::processPlayerGoods(int money, const std::vector<std::tuple<ItemPtr, int> >& goods)
{
    g_lua.callGlobalField("g_game", "onPlayerGoods", money, goods);
}

void Game::processCloseNpcTrade()
{
    g_lua.callGlobalField("g_game", "onCloseNpcTrade");
}

void Game::processOwnTrade(const std::string& name, const std::vector<ItemPtr>& items)
{
    g_lua.callGlobalField("g_game", "onOwnTrade", name, items);
}

void Game::processCounterTrade(const std::string& name, const std::vector<ItemPtr>& items)
{
    g_lua.callGlobalField("g_game", "onCounterTrade", name, items);
}

void Game::processCloseTrade()
{
    g_lua.callGlobalField("g_game", "onCloseTrade");
}

void Game::processEditText(uint id, int itemId, int maxLength, const std::string& text, const std::string& writer, const std::string& date)
{
    g_lua.callGlobalField("g_game", "onEditText", id, itemId, maxLength, text, writer, date);
}

void Game::processEditList(uint id, int doorId, const std::string& text)
{
    g_lua.callGlobalField("g_game", "onEditList", id, doorId, text);
}

void Game::processQuestLog(const std::vector<std::tuple<int, std::string, bool> >& questList)
{
    g_lua.callGlobalField("g_game", "onQuestLog", questList);
}

void Game::processQuestLine(int questId, const std::vector<std::tuple<std::string, std::string> >& questMissions)
{
    g_lua.callGlobalField("g_game", "onQuestLine", questId, questMissions);
}

void Game::processModalDialog(uint32 id, std::string title, std::string message, std::vector<std::tuple<int, std::string> > buttonList, int enterButton, int escapeButton, std::vector<std::tuple<int, std::string> > choiceList, bool priority)
{
    g_lua.callGlobalField("g_game", "onModalDialog", id, title, message, buttonList, enterButton, escapeButton, choiceList, priority);
}

void Game::processAttackCancel(uint seq)
{
    if(isAttacking() && (seq == 0 || m_seq == seq))
        cancelAttack();
}

void Game::processWalkCancel(Otc::Direction direction)
{
    m_localPlayer->cancelWalk(direction);
}

void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
{
    if(m_protocolGame || isOnline())
        stdext::throw_exception("Unable to login into a world while already online or logging.");

    if(m_protocolVersion == 0)
        stdext::throw_exception("Must set a valid game protocol version before logging.");

    // reset the new game state
    resetGameStates();

    m_localPlayer = LocalPlayerPtr(new LocalPlayer);
    m_localPlayer->setName(characterName);

    m_protocolGame = ProtocolGamePtr(new ProtocolGame);
    m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken, sessionKey);
    m_characterName = characterName;
    m_worldName = worldName;
}

void Game::cancelLogin()
{
    // send logout even if the game has not started yet, to make sure that the player doesn't stay logged there
    if(m_protocolGame)
        m_protocolGame->sendLogout();

    processDisconnect();
}

void Game::forceLogout()
{
    if(!isOnline())
        return;

    m_protocolGame->sendLogout();
    processDisconnect();
}

void Game::safeLogout()
{
    if(!isOnline())
        return;

    m_protocolGame->sendLogout();
}

bool Game::walk(Otc::Direction direction, bool dash)
{
    if(!canPerformGameAction())
        return false;

    // must cancel follow before any new walk
    if(isFollowing())
        cancelFollow();

    // must cancel auto walking, and wait next try
    if(m_localPlayer->isAutoWalking() || m_localPlayer->isServerWalking()) {
        m_protocolGame->sendStop();
        if(m_localPlayer->isAutoWalking())
            m_localPlayer->stopAutoWalk();
        return false;
    }

    if(dash) {
        if(m_localPlayer->isWalking() && m_dashTimer.ticksElapsed() < std::max<int>(m_localPlayer->getStepDuration(false, direction) - m_ping, 30))
            return false;
    }
    else {
        // check we can walk and add new walk event if false
        if(!m_localPlayer->canWalk(direction)) {
            if(m_lastWalkDir != direction) {
                // must add a new walk event
                float ticks = m_localPlayer->getStepTicksLeft();
                if(ticks <= 0) { ticks = 1; }

                if(m_walkEvent) {
                    m_walkEvent->cancel();
                    m_walkEvent = nullptr;
                }
                m_walkEvent = g_dispatcher.scheduleEvent([=] { walk(direction, false); }, ticks);
            }
            return false;
        }
    }

    Position toPos = m_localPlayer->getPosition().translatedToDirection(direction);
    TilePtr toTile = g_map.getTile(toPos);
    // only do prewalks to walkable tiles (like grounds and not walls)
    if(toTile && toTile->isWalkable()) {
        m_localPlayer->preWalk(direction);
    // check walk to another floor (e.g: when above 3 parcels)
    } else {
        // check if can walk to a lower floor
        auto canChangeFloorDown = [&]() -> bool {
            Position pos = toPos;
            if(!pos.down())
                return false;
            TilePtr toTile = g_map.getTile(pos);
            if(toTile && toTile->hasElevation(3))
                return true;
            return false;
        };

        // check if can walk to a higher floor
        auto canChangeFloorUp = [&]() -> bool {
            TilePtr fromTile = m_localPlayer->getTile();
            if(!fromTile || !fromTile->hasElevation(3))
                return false;
            Position pos = toPos;
            if(!pos.up())
                return false;
            TilePtr toTile = g_map.getTile(pos);
            if(!toTile || !toTile->isWalkable())
                return false;
            return true;
        };

        if(canChangeFloorDown() || canChangeFloorUp() ||
            (!toTile || toTile->isEmpty())) {
            m_localPlayer->lockWalk();
        } else
            return false;
    }

    m_localPlayer->stopAutoWalk();

    g_lua.callGlobalField("g_game", "onWalk", direction, dash);

    forceWalk(direction);
    if(dash)
      m_dashTimer.restart();

    m_lastWalkDir = direction;
    return true;
}

bool Game::dashWalk(Otc::Direction direction)
{
    return walk(direction, true);
}

void Game::autoWalk(std::vector<Otc::Direction> dirs)
{
    if(!canPerformGameAction())
        return;

    // protocol limits walk path up to 255 directions
    if(dirs.size() > 127) {
        g_logger.error("Auto walk path too great, the maximum number of directions is 127");
        return;
    }

    if(dirs.size() == 0)
        return;

    // must cancel follow before any new walk
    if(isFollowing())
        cancelFollow();

    auto it = dirs.begin();
    Otc::Direction direction = *it;
    if(!m_localPlayer->canWalk(direction))
        return;

    TilePtr toTile = g_map.getTile(m_localPlayer->getPosition().translatedToDirection(direction));
    if(toTile && toTile->isWalkable() && !m_localPlayer->isServerWalking()) {
        m_localPlayer->preWalk(direction);

        if(getFeature(Otc::GameForceFirstAutoWalkStep)) {
            forceWalk(direction);
            dirs.erase(it);
        }
    }

    g_lua.callGlobalField("g_game", "onAutoWalk", dirs);

    m_protocolGame->sendAutoWalk(dirs);
}

void Game::forceWalk(Otc::Direction direction)
{
    if(!canPerformGameAction())
        return;

    switch(direction) {
    case Otc::North:
        m_protocolGame->sendWalkNorth();
        break;
    case Otc::East:
        m_protocolGame->sendWalkEast();
        break;
    case Otc::South:
        m_protocolGame->sendWalkSouth();
        break;
    case Otc::West:
        m_protocolGame->sendWalkWest();
        break;
    case Otc::NorthEast:
        m_protocolGame->sendWalkNorthEast();
        break;
    case Otc::SouthEast:
        m_protocolGame->sendWalkSouthEast();
        break;
    case Otc::SouthWest:
        m_protocolGame->sendWalkSouthWest();
        break;
    case Otc::NorthWest:
        m_protocolGame->sendWalkNorthWest();
        break;
    default:
        break;
    }

    g_lua.callGlobalField("g_game", "onForceWalk", direction);
}

void Game::turn(Otc::Direction direction)
{
    if(!canPerformGameAction())
        return;

    switch(direction) {
    case Otc::North:
        m_protocolGame->sendTurnNorth();
        break;
    case Otc::East:
        m_protocolGame->sendTurnEast();
        break;
    case Otc::South:
        m_protocolGame->sendTurnSouth();
        break;
    case Otc::West:
        m_protocolGame->sendTurnWest();
        break;
    default:
        break;
    }
}

void Game::stop()
{
    if(!canPerformGameAction())
        return;

    if(isFollowing())
        cancelFollow();

    m_protocolGame->sendStop();
}

void Game::look(const ThingPtr& thing)
{
    if(!canPerformGameAction() || !thing)
        return;

    if(thing->isCreature() && m_protocolVersion >= 961)
        m_protocolGame->sendLookCreature(thing->getId());
    else
        m_protocolGame->sendLook(thing->getPosition(), thing->getId(), thing->getStackPos());
}

void Game::move(const ThingPtr& thing, const Position& toPos, int count)
{
    if(count <= 0)
        count = 1;

    if(!canPerformGameAction() || !thing || thing->getPosition() == toPos)
        return;

    uint id = thing->getId();
    if(thing->isCreature()) {
        CreaturePtr creature = thing->static_self_cast<Creature>();
        id = Proto::Creature;
    }

    m_protocolGame->sendMove(thing->getPosition(), id, thing->getStackPos(), toPos, count);
}

void Game::moveToParentContainer(const ThingPtr& thing, int count)
{
    if(!canPerformGameAction() || !thing || count <= 0)
        return;

    Position position = thing->getPosition();
    move(thing, Position(position.x, position.y, 254), count);
}

void Game::rotate(const ThingPtr& thing)
{
    if(!canPerformGameAction() || !thing)
        return;

    m_protocolGame->sendRotateItem(thing->getPosition(), thing->getId(), thing->getStackPos());
}

void Game::use(const ThingPtr& thing)
{
    if(!canPerformGameAction() || !thing)
        return;

    Position pos = thing->getPosition();
    if(!pos.isValid()) // virtual item
        pos = Position(0xFFFF, 0, 0); // inventory item

    // some items, e.g. parcel, are not set as containers but they are.
    // always try to use these items in free container slots.
    m_protocolGame->sendUseItem(pos, thing->getId(), thing->getStackPos(), findEmptyContainerId());
}

void Game::useInventoryItem(int itemId)
{
    if(!canPerformGameAction() || !g_things.isValidDatId(itemId, ThingCategoryItem))
        return;

    Position pos = Position(0xFFFF, 0, 0); // means that is a item in inventory

    m_protocolGame->sendUseItem(pos, itemId, 0, 0);
}

void Game::useWith(const ItemPtr& item, const ThingPtr& toThing)
{
    if(!canPerformGameAction() || !item || !toThing)
        return;

    Position pos = item->getPosition();
    if(!pos.isValid()) // virtual item
        pos = Position(0xFFFF, 0, 0); // means that is an item in inventory

    m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}

void Game::useInventoryItemWith(int itemId, const ThingPtr& toThing)
{
    if(!canPerformGameAction() || !toThing)
        return;

    Position pos = Position(0xFFFF, 0, 0); // means that is a item in inventory

    if(toThing->isCreature())
        m_protocolGame->sendUseOnCreature(pos, itemId, 0, toThing->getId());
    else
        m_protocolGame->sendUseItemWith(pos, itemId, 0, toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}

ItemPtr Game::findItemInContainers(uint itemId, int subType)
{
    for(auto& it : m_containers) {
        const ContainerPtr& container = it.second;

        if(container) {
            ItemPtr item = container->findItemById(itemId, subType);
            if(item != nullptr)
                return item;
        }
    }
    return nullptr;
}

int Game::open(const ItemPtr& item, const ContainerPtr& previousContainer)
{
    if(!canPerformGameAction() || !item)
        return -1;

    int id = 0;
    if(!previousContainer)
        id = findEmptyContainerId();
    else
        id = previousContainer->getId();

    m_protocolGame->sendUseItem(item->getPosition(), item->getId(), item->getStackPos(), id);
    return id;
}

void Game::openParent(const ContainerPtr& container)
{
    if(!canPerformGameAction() || !container)
        return;

    m_protocolGame->sendUpContainer(container->getId());
}

void Game::close(const ContainerPtr& container)
{
    if(!canPerformGameAction() || !container)
        return;

    m_protocolGame->sendCloseContainer(container->getId());
}

void Game::refreshContainer(const ContainerPtr& container)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRefreshContainer(container->getId());
}

void Game::attack(CreaturePtr creature)
{
    if(!canPerformGameAction() || creature == m_localPlayer)
        return;

    // cancel when attacking again
    if(creature && creature == m_attackingCreature)
        creature = nullptr;

    if(creature && isFollowing())
        cancelFollow();

    setAttackingCreature(creature);
    m_localPlayer->stopAutoWalk();

    if(m_protocolVersion >= 963) {
        if(creature)
            m_seq = creature->getId();
    } else
        m_seq++;

    m_protocolGame->sendAttack(creature ? creature->getId() : 0, m_seq);
}

void Game::follow(CreaturePtr creature)
{
    if(!canPerformGameAction() || creature == m_localPlayer)
        return;

    // cancel when following again
    if(creature && creature == m_followingCreature)
        creature = nullptr;

    if(creature && isAttacking())
        cancelAttack();

    setFollowingCreature(creature);
    m_localPlayer->stopAutoWalk();

    if(m_protocolVersion >= 963) {
        if(creature)
            m_seq = creature->getId();
    } else
        m_seq++;

    m_protocolGame->sendFollow(creature ? creature->getId() : 0, m_seq);
}

void Game::cancelAttackAndFollow()
{
    if(!canPerformGameAction())
        return;

    if(isFollowing())
        setFollowingCreature(nullptr);
    if(isAttacking())
        setAttackingCreature(nullptr);

    m_localPlayer->stopAutoWalk();

    m_protocolGame->sendCancelAttackAndFollow();

    g_lua.callGlobalField("g_game", "onCancelAttackAndFollow");
}

void Game::talk(const std::string& message)
{
    if(!canPerformGameAction() || message.empty())
        return;
    talkChannel(Otc::MessageSay, 0, message);
}

void Game::talkChannel(Otc::MessageMode mode, int channelId, const std::string& message)
{
    if(!canPerformGameAction() || message.empty())
        return;
    m_protocolGame->sendTalk(mode, channelId, "", message);
}

void Game::talkPrivate(Otc::MessageMode mode, const std::string& receiver, const std::string& message)
{
    if(!canPerformGameAction() || receiver.empty() || message.empty())
        return;
    m_protocolGame->sendTalk(mode, 0, receiver, message);
}

void Game::openPrivateChannel(const std::string& receiver)
{
    if(!canPerformGameAction() || receiver.empty())
        return;
    m_protocolGame->sendOpenPrivateChannel(receiver);
}

void Game::requestChannels()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestChannels();
}

void Game::joinChannel(int channelId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendJoinChannel(channelId);
}

void Game::leaveChannel(int channelId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendLeaveChannel(channelId);
}

void Game::closeNpcChannel()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendCloseNpcChannel();
}

void Game::openOwnChannel()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendOpenOwnChannel();
}

void Game::inviteToOwnChannel(const std::string& name)
{
    if(!canPerformGameAction() || name.empty())
        return;
    m_protocolGame->sendInviteToOwnChannel(name);
}

void Game::excludeFromOwnChannel(const std::string& name)
{
    if(!canPerformGameAction() || name.empty())
        return;
    m_protocolGame->sendExcludeFromOwnChannel(name);
}

void Game::partyInvite(int creatureId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendInviteToParty(creatureId);
}

void Game::partyJoin(int creatureId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendJoinParty(creatureId);
}

void Game::partyRevokeInvitation(int creatureId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRevokeInvitation(creatureId);
}

void Game::partyPassLeadership(int creatureId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendPassLeadership(creatureId);
}

void Game::partyLeave()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendLeaveParty();
}

void Game::partyShareExperience(bool active)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendShareExperience(active);
}

void Game::requestOutfit()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestOutfit();
}

void Game::changeOutfit(const Outfit& outfit)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendChangeOutfit(outfit);
}

void Game::addVip(const std::string& name)
{
    if(!canPerformGameAction() || name.empty())
        return;
    m_protocolGame->sendAddVip(name);
}

void Game::removeVip(int playerId)
{
    if(!canPerformGameAction())
        return;

    auto it = m_vips.find(playerId);
    if(it == m_vips.end())
        return;
    m_vips.erase(it);
    m_protocolGame->sendRemoveVip(playerId);
}

void Game::editVip(int playerId, const std::string& description, int iconId, bool notifyLogin)
{
    if(!canPerformGameAction())
        return;

    auto it = m_vips.find(playerId);
    if(it == m_vips.end())
        return;

    std::get<2>(m_vips[playerId]) = description;
    std::get<3>(m_vips[playerId]) = iconId;
    std::get<4>(m_vips[playerId]) = notifyLogin;

    if(getFeature(Otc::GameAdditionalVipInfo))
        m_protocolGame->sendEditVip(playerId, description, iconId, notifyLogin);
}

void Game::setChaseMode(Otc::ChaseModes chaseMode)
{
    if(!canPerformGameAction())
        return;
    if(m_chaseMode == chaseMode)
        return;
    m_chaseMode = chaseMode;
    m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
    g_lua.callGlobalField("g_game", "onChaseModeChange", chaseMode);
}

void Game::setFightMode(Otc::FightModes fightMode)
{
    if(!canPerformGameAction())
        return;
    if(m_fightMode == fightMode)
        return;
    m_fightMode = fightMode;
    m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
    g_lua.callGlobalField("g_game", "onFightModeChange", fightMode);
}

void Game::setSafeFight(bool on)
{
    if(!canPerformGameAction())
        return;
    if(m_safeFight == on)
        return;
    m_safeFight = on;
    m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
    g_lua.callGlobalField("g_game", "onSafeFightChange", on);
}

void Game::setPVPMode(Otc::PVPModes pvpMode)
{
    if(!canPerformGameAction())
        return;
    if(!getFeature(Otc::GamePVPMode))
        return;
    if(m_pvpMode == pvpMode)
        return;
    m_pvpMode = pvpMode;
    m_protocolGame->sendChangeFightModes(m_fightMode, m_chaseMode, m_safeFight, m_pvpMode);
    g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
}

void Game::setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints)
{
    if(!canPerformGameAction())
        return;
    if(!getFeature(Otc::GameUnjustifiedPoints))
        return;
    if(m_unjustifiedPoints == unjustifiedPoints)
        return;

    m_unjustifiedPoints = unjustifiedPoints;
    g_lua.callGlobalField("g_game", "onUnjustifiedPointsChange", unjustifiedPoints);
}

void Game::setOpenPvpSituations(int openPvpSituations)
{
    if(!canPerformGameAction())
        return;
    if(m_openPvpSituations == openPvpSituations)
        return;

    m_openPvpSituations = openPvpSituations;
    g_lua.callGlobalField("g_game", "onOpenPvpSituationsChange", openPvpSituations);
}

void Game::inspectNpcTrade(const ItemPtr& item)
{
    if(!canPerformGameAction() || !item)
        return;
    m_protocolGame->sendInspectNpcTrade(item->getId(), item->getCount());
}

void Game::buyItem(const ItemPtr& item, int amount, bool ignoreCapacity, bool buyWithBackpack)
{
    if(!canPerformGameAction() || !item)
        return;
    m_protocolGame->sendBuyItem(item->getId(), item->getCountOrSubType(), amount, ignoreCapacity, buyWithBackpack);
}

void Game::sellItem(const ItemPtr& item, int amount, bool ignoreEquipped)
{
    if(!canPerformGameAction() || !item)
        return;
    m_protocolGame->sendSellItem(item->getId(), item->getSubType(), amount, ignoreEquipped);
}

void Game::closeNpcTrade()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendCloseNpcTrade();
}

void Game::requestTrade(const ItemPtr& item, const CreaturePtr& creature)
{
    if(!canPerformGameAction() || !item || !creature)
        return;
    m_protocolGame->sendRequestTrade(item->getPosition(), item->getId(), item->getStackPos(), creature->getId());
}

void Game::inspectTrade(bool counterOffer, int index)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendInspectTrade(counterOffer, index);
}

void Game::acceptTrade()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendAcceptTrade();
}

void Game::rejectTrade()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRejectTrade();
}

void Game::editText(uint id, const std::string& text)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendEditText(id, text);
}

void Game::editList(uint id, int doorId, const std::string& text)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendEditList(id, doorId, text);
}

void Game::openRuleViolation(const std::string& reporter)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendOpenRuleViolation(reporter);
}

void Game::closeRuleViolation(const std::string& reporter)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendCloseRuleViolation(reporter);
}

void Game::cancelRuleViolation()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendCancelRuleViolation();
}

void Game::reportBug(const std::string& comment)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendBugReport(comment);
}

void Game::reportRuleViolation(const std::string& target, int reason, int action, const std::string& comment, const std::string& statement, int statementId, bool ipBanishment)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRuleViolation(target, reason, action, comment, statement, statementId, ipBanishment);
}

void Game::debugReport(const std::string& a, const std::string& b, const std::string& c, const std::string& d)
{
    m_protocolGame->sendDebugReport(a, b, c, d);
}

void Game::requestQuestLog()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestQuestLog();
}

void Game::requestQuestLine(int questId)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestQuestLine(questId);
}

void Game::equipItem(const ItemPtr& item)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendEquipItem(item->getId(), item->getCountOrSubType());
}

void Game::mount(bool mount)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendMountStatus(mount);
}

void Game::requestItemInfo(const ItemPtr& item, int index)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestItemInfo(item->getId(), item->getSubType(), index);
}

void Game::answerModalDialog(int dialog, int button, int choice)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendAnswerModalDialog(dialog, button, choice);
}

void Game::browseField(const Position& position)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendBrowseField(position);
}

void Game::seekInContainer(int cid, int index)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendSeekInContainer(cid, index);
}

void Game::buyStoreOffer(int offerId, int productType, const std::string& name)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendBuyStoreOffer(offerId, productType, name);
}

void Game::requestTransactionHistory(int page, int entriesPerPage)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestTransactionHistory(page, entriesPerPage);
}

void Game::requestStoreOffers(const std::string& categoryName)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendRequestStoreOffers(categoryName);
}

void Game::openStore()
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendOpenStore();
}

void Game::transferCoins(const std::string& recipient, int amount)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendTransferCoins(recipient, amount);
}

void Game::openTransactionHistory(int entriesPerPage)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendOpenTransactionHistory(entriesPerPage);
}

void Game::ping()
{
    if(!m_protocolGame || !m_protocolGame->isConnected())
        return;

    if(m_pingReceived != m_pingSent)
        return;

    m_denyBotCall = false;
    m_protocolGame->sendPing();
    m_denyBotCall = true;
    m_pingSent++;
    m_pingTimer.restart();
}

void Game::changeMapAwareRange(int xrange, int yrange)
{
    if(!canPerformGameAction())
        return;
    m_protocolGame->sendChangeMapAwareRange(xrange, yrange);
}

bool Game::checkBotProtection()
{
#ifdef BOT_PROTECTION
    // accepts calls comming from a stacktrace containing only C++ functions,
    // if the stacktrace contains a lua function, then only accept if the engine is processing an input event
    if(m_denyBotCall && g_lua.isInCppCallback() && !g_app.isOnInputEvent()) {
        g_logger.error(g_lua.traceback("caught a lua call to a bot protected game function, the call was cancelled"));
        return false;
    }
#endif
    return true;
}

bool Game::canPerformGameAction()
{
    // we can only perform game actions if we meet these conditions:
    // - the game is online
    // - the local player exists
    // - the local player is not dead
    // - we have a game protocol
    // - the game protocol is connected
    // - its not a bot action
    return m_online && m_localPlayer && !m_localPlayer->isDead() && !m_dead && m_protocolGame && m_protocolGame->isConnected() && checkBotProtection();
}

void Game::setProtocolVersion(int version)
{
    if(m_protocolVersion == version)
        return;

    if(isOnline())
        stdext::throw_exception("Unable to change protocol version while online");

    if(version != 0 && (version < 740 || version > 1090))
        stdext::throw_exception(stdext::format("Protocol version %d not supported", version));

    m_protocolVersion = version;

    Proto::buildMessageModesMap(version);

    g_lua.callGlobalField("g_game", "onProtocolVersionChange", version);
}

void Game::setClientVersion(int version)
{
    if(m_clientVersion == version)
        return;

    if(isOnline())
        stdext::throw_exception("Unable to change client version while online");

    if(version != 0 && (version < 740 || version > 1090))
        stdext::throw_exception(stdext::format("Client version %d not supported", version));

    m_features.reset();
    enableFeature(Otc::GameFormatCreatureName);

    if(version >= 770) {
        enableFeature(Otc::GameLooktypeU16);
        enableFeature(Otc::GameMessageStatements);
        enableFeature(Otc::GameLoginPacketEncryption);
    }

    if(version >= 780) {
        enableFeature(Otc::GamePlayerAddons);
        enableFeature(Otc::GamePlayerStamina);
        enableFeature(Otc::GameNewFluids);
        enableFeature(Otc::GameMessageLevel);
        enableFeature(Otc::GamePlayerStateU16);
        enableFeature(Otc::GameNewOutfitProtocol);
    }

    if(version >= 790) {
        enableFeature(Otc::GameWritableDate);
    }

    if(version >= 840) {
        enableFeature(Otc::GameProtocolChecksum);
        enableFeature(Otc::GameAccountNames);
        enableFeature(Otc::GameDoubleFreeCapacity);
    }

    if(version >= 841) {
        enableFeature(Otc::GameChallengeOnLogin);
        enableFeature(Otc::GameMessageSizeCheck);
    }

    if(version >= 854) {
        enableFeature(Otc::GameCreatureEmblems);
    }

    if(version >= 860) {
        enableFeature(Otc::GameAttackSeq);
    }

    if(version >= 862) {
        enableFeature(Otc::GamePenalityOnDeath);
    }

    if(version >= 870) {
        enableFeature(Otc::GameDoubleExperience);
        enableFeature(Otc::GamePlayerMounts);
        enableFeature(Otc::GameSpellList);
    }

    if(version >= 910) {
        enableFeature(Otc::GameNameOnNpcTrade);
        enableFeature(Otc::GameTotalCapacity);
        enableFeature(Otc::GameSkillsBase);
        enableFeature(Otc::GamePlayerRegenerationTime);
        enableFeature(Otc::GameChannelPlayerList);
        enableFeature(Otc::GameEnvironmentEffect);
        enableFeature(Otc::GameItemAnimationPhase);
    }

    if(version >= 940) {
        enableFeature(Otc::GamePlayerMarket);
    }

    if(version >= 953) {
        enableFeature(Otc::GamePurseSlot);
        enableFeature(Otc::GameClientPing);
    }

    if(version >= 960) {
        enableFeature(Otc::GameSpritesU32);
        enableFeature(Otc::GameOfflineTrainingTime);
    }

    if(version >= 963) {
        enableFeature(Otc::GameAdditionalVipInfo);
    }

    if(version >= 980) {
        enableFeature(Otc::GamePreviewState);
        enableFeature(Otc::GameClientVersion);
    }

    if(version >= 981) {
        enableFeature(Otc::GameLoginPending);
        enableFeature(Otc::GameNewSpeedLaw);
    }

    if(version >= 984) {
        enableFeature(Otc::GameContainerPagination);
        enableFeature(Otc::GameBrowseField);
    }

    if(version >= 1000) {
        enableFeature(Otc::GameThingMarks);
        enableFeature(Otc::GamePVPMode);
    }

    if(version >= 1035) {
        enableFeature(Otc::GameDoubleSkills);
        enableFeature(Otc::GameBaseSkillU16);
    }

    if(version >= 1036) {
        enableFeature(Otc::GameCreatureIcons);
        enableFeature(Otc::GameHideNpcNames);
    }

    if(version >= 1038) {
        enableFeature(Otc::GamePremiumExpiration);
    }

    if(version >= 1050) {
        enableFeature(Otc::GameEnhancedAnimations);
    }

    if(version >= 1053) {
        enableFeature(Otc::GameUnjustifiedPoints);
    }

    if(version >= 1054) {
        enableFeature(Otc::GameExperienceBonus);
    }

    if(version >= 1055) {
        enableFeature(Otc::GameDeathType);
    }

    if(version >= 1057) {
        enableFeature(Otc::GameIdleAnimations);
    }

    if(version >= 1061) {
        enableFeature(Otc::GameOGLInformation);
    }

    if(version >= 1071) {
        enableFeature(Otc::GameContentRevision);
    }

    if(version >= 1072) {
        enableFeature(Otc::GameAuthenticator);
    }

    if(version >= 1074) {
        enableFeature(Otc::GameSessionKey);
    }

    if(version >= 1080) {
        enableFeature(Otc::GameIngameStore);
    }

    m_clientVersion = version;

    g_lua.callGlobalField("g_game", "onClientVersionChange", version);
}

void Game::setAttackingCreature(const CreaturePtr& creature)
{
    if(creature != m_attackingCreature) {
        CreaturePtr oldCreature = m_attackingCreature;
        m_attackingCreature = creature;

        g_lua.callGlobalField("g_game", "onAttackingCreatureChange", creature, oldCreature);
    }
}

void Game::setFollowingCreature(const CreaturePtr& creature)
{
    CreaturePtr oldCreature = m_followingCreature;
    m_followingCreature = creature;

    g_lua.callGlobalField("g_game", "onFollowingCreatureChange", creature, oldCreature);
}

std::string Game::formatCreatureName(const std::string& name)
{
    std::string formatedName = name;
    if(getFeature(Otc::GameFormatCreatureName) && name.length() > 0) {
        bool upnext = true;
        for(uint i=0;i<formatedName.length();++i) {
            char ch = formatedName[i];
            if(upnext) {
                formatedName[i] = stdext::upchar(ch);
                upnext = false;
            }
            if(ch == ' ')
                upnext = true;
        }
    }
    return formatedName;
}

int Game::findEmptyContainerId()
{
    int id = 0;
    while(m_containers[id] != nullptr)
        id++;
    return id;
}

int Game::getOs()
{
    if(m_clientCustomOs >= 0)
        return m_clientCustomOs;

    if(g_app.getOs() == "windows")
        return 10;
    else if(g_app.getOs() == "mac")
        return 12;
    else // linux
        return 11;
}

redpajama_set_name: RedPajamaGithub


Books usually undergo a series of reviews, starting with a rigorous review process at the proposal stage. Editors working at publishing companies contact experts in the field and provide the written proposals and often a draft table of contents for feedback.
Once a book project passes the proposal phase, it enters the manuscript phase, where another round of reviews is often conducted by a new expert or experts in the field. Feedback at this stage is often collected by the in-house editor, who works with the individual book author or editors to adapt it and better shape the book project on the path to publication.
And finally, after publication, a book can be reviewed and a written "book review" can be published in a journal, publicity outlet or high-profile blog.


text:
Scates, Bruce
Historian and academic who has written several books on Gallipoli.
{"name":"Academic","target":"","target_text":null,"date":{"#markup":"<\/span>"},"date_start":null,"date_end":null}
{"name":"Historian","target":"","target_text":null,"date":{"#markup":"<\/span>"},"date_start":null,"date_end":null}
The Fallen on the Ultimo Presbyterian Church Roll of Honour The Red Cross in Sydney in World War One
The Fallen on the Ultimo Presbyterian Church Roll of Honour
The Ultimo Presbyterian Church Roll of Honour, now housed in the Ultimo Community Centre, lists the names of 36 men. Four of those men died as a result of their war service and were lost to their families and friends - people who openly grieved their passing. Their grief is a reminder of the true cost of war, for the fallen and for their family, friends, and community.
The Red Cross in Sydney in World War One
A Sydney branch of the British Red Cross was formed in 1913 and it, and a host of new branches, joined the national movement at the outbreak of World War One in August 1914. The earliest activities were training in first aid and home nursing as pre-requisites for membership of Voluntary Aid Detachments. At a local level Red Cross workers undertook sewing, knitting and fundraising, all the while being encouraged to see themselves at 'ministering angels'.

redpajama_set_name: RedPajamaCommonCrawl


Languages, compilers, and computer-aided design tools will be essential for scalable quantum computing, which promises an exponential leap in our ability to execute complex tasks. LIQUi|> contains an embedded, domain-specific language designed for programming quantum algorithms. It is also fully modular and independent of a specific quantum architecture. LIQUi|> allows the extraction of a circuit data structure that can be used for optimization, rendering, or translation. The circuit can also be exported to external hardware and software environments. Two different simulation environments are available to the user which allow a trade-off between number of qubits and class of operations. LIQUi|> can be executed in a wide range of run-times from the desktop to the cloud. In this session, I will describe the significant components of the design architecture and show how to express any given quantum algorithm. LIQUi|> enables easy programming, compilation, and simulation of quantum algorithms and circuits.


text:
Bang Khae (, ) is a khwaeng (subdistrict) of Bang Khae District, in Bangkok, Thailand. In 2020, it had a total population of 38,915 people.

References

Subdistricts of Bangkok
Bang Khae district

redpajama_set_name: RedPajamaWikipedia


text:
What's Going On With the 2021 Oscars?
While the movie business struggles amidst the coronavirus pandemic, the Academy is rethinking how it will handle the 2021 Oscars.
Updated on 6/22/2020 at 1:17 PM
Remember when 'Parasite' won? That was awesome. | Matt Petit - Handout/A.M.P.A.S. via Getty Images
There are no new movies. OK, that's an exaggeration. But there are far fewer new movies than there would be if the coronavirus pandemic hadn't ripped through the world. Major releases have essentially been put on hold, leaving streaming services and VOD to pick up the slack. Right now, we should be heading into a packed summer movie season, but instead we're left wondering whether anyone will even want to go to a theater to see a new Christopher Nolan thriller. So if there aren't any new movies, what becomes of the Oscars? Let's investigate.
The Oscars are being postponed
On June 15, the Academy announced that, yes, the Oscars are being postponed. Now the ceremony will take place on April 25, 2021. Now February 28, the day the event was supposed to take place, is actually the cut off period for eligibility. So movies that come out in the early days of 2021 will be considered for this year's awards. Nominations will be announced March 15.
Could the Oscars ever be canceled altogether?
Probably not. The Oscars have actually never in their history been fully canceled. They've been delayed three times: In 1938 due to flooding in Los Angeles, in 1968 following Martin Luther King Jr.'s assassination, and in 1981 after the assassination attempt on Ronald Reagan. Of course, what's happening now is much different. None of these incidents actually stopped movies from coming out or large gatherings from taking place.
Thrillist TV
What movies are even eligible?
The Academy has already announced contingency plans to account for the fact that theaters are mostly shuttered. In normal times, to be eligible for an Oscar a film must play for at least seven consecutive days in a Los Angeles movie theater. Given that that's not actually possible, the organization is making an exception to that qualifying rule for this year only. Now, movies that had planned on a theatrical release but are now going direct to VOD or streaming can be considered for a trophy. Waiving the eligibility run will end on a to-be-determined date when theaters do get safely up and running, but for now it allows studios to be strategic when it comes to distribution. For instance, it's unlikely that Netflix would have decided to drop Da 5 Bloods, Spike Lee's Vietnam epic in June had the Academy not made this decision.
We wait! For now, it seems unlikely that a traditional "awards season" can go on like normal. Cannes -- where pundits usually get a sense of an Oscar field beginning to form -- should be underway, but was canceled. Other festivals like Venice and the Toronto International Film Festival have announced that they intend to go on in some form, but it's unclear what that looks like as it seems risky to host an event where people from all around the world gather to sit in enclosed spaces. Some films that could be in contention, like Steven Spielberg's West Side Story and Wes Anderson's The French Dispatch, are holding onto release dates in the fall, but no one really knows what the movie industry will look like by then. Still, other ceremonies are following the Oscars' lead and shifting around their dates. The Golden Globes will now be held on Feb. 28, the day the Oscars were supposed to take place, while the Critics Choice will happen on March 7.
Need help finding something to watch? Sign up here for our weekly Streamail newsletter to get streaming recommendations delivered straight to your inbox.
Esther Zuckerman is a senior entertainment writer at Thrillist. Follow her on Twitter @ezwrites.


Food and Agricultural Code (FAC) section 12811.5 requires an applicant for registration or amendment of a pesticide product to submit its own data to fulfill a current data requirement. If the applicant relies upon data that it does not own and the data meet certain specified criteria, the applicant must irrevocably offer to pay the data owner a share of the cost of producing the data and comply with the provisions of subsection (d). The statute provides that the data owner may seek to enforce the cost-sharing obligation of the applicant by bringing an action in any California court of competent jurisdiction or by seeking a determination by the Director that the applicant did not satisfy its obligation and request cancellation of the applicant's product.


Craig Curk's love of the game of soccer extended into his college years at Xavier University in Norwood, Ohio near Cincinnati in the United States. The Xavier Musketeers are a Division I team, and Curk was goalkeeper for the Musketeers from 1979 to 1980. Craig Curk's time at Alter High School in Kettering, Ohio led him naturally into his enrollment at Xavier, a Jesuit Catholic University which is the sixth oldest Catholic and fourth oldest Jesuit university in the United States. Xavier specializes in the undergraduate liberal arts education, and currently enrolls almost 4,500 undergraduates and 2,165 graduates. Xavier University's roots go deep into a time before the establishment of the United States, when Ohio was part of the Northwest Territory of the New World, when Xavier was the first Catholic institution of higher learning in the entire Territory. Xavier was established in 1831 to be an exclusively male college for Cincinnati, originally dubbed The Athenaeum until 1840 when the Society of Jesus took over and changed its name to St. Xavier College to honor the 16th century Jesuit missionary St. Francis Xavier. The school finally became Xavier University in 1930.
Between the City of Cincinnati, Ohio and the City of Norwood, Ohio in the United States, the campus of Xavier University covers 190 acres, where residential and academic facilities were utilized by student Craig Curk upon his enrollment in 1979. Curk would eventually earn a Bachelor of Science in Business Administration (BSBA) in 1983 from Xavier's Williams College of Business.
This entry was posted in Craig Curk and tagged Craig, Curk, Education. Bookmark the permalink.


Our dip bowl in stone gray is made from Melaboo™, a unique blend of melamine and bamboo, creating a beautiful texture that anyone would mistake for artisanal pottery. Perfect for enjoying sushi or a veggie dip, this dip bowl from our Potter series is the ideal choice for many occasions. Made from Melaboo™, this BPA free serveware is shatterproof and stain resistant. With an earthy design and organic feel, this dip bowl promises a fresh addition to your mealtime. If you are looking for the highest quality in unbreakable serveware, then the Potter dip bowl in stone gray is your choice!


Fulcrum utilizes a variety of research tools to maximize the advertising ROI. We implement market research data to make the most informed media plans, targeted to the designated consumer while keeping in mind the specific goal and budget of the advertiser.
Fulcrum has developed the Assured Compliance process for ad placement. This begins with confirmation of orders and proceeds all the way to verification of reproduction, creating multiple touch points ensuring flawless order execution.


In celebration of the 30th anniversary of the ATI Graphics Business, On this occasion AMD finally comes with the awaited confirmation and AMD officially unveiled a new video card " Radeon R9 285 ", Now complete 15 Members of R200 Family.
AMD R9 285 is from the AMD R9 Series, it will replace the R9 280, the Core (Codename TONGA PRO) GCN architecture is based on improving version 1.1 (although the officials never used this name). Tonga is the greatest improvement from the AMD side as Tonga GPU is the less power eater, Mantle API must be supported, and there are also some features including new PowerTune Boost dynamic acceleration and TrueAudio technology, XDMA Crossfire Technology and other new technologies, also support DirectX 12.
AMD R9 285 is equipped with the following specifications : It has 1792 stream processors, 112 texture units, 32 ROP units , the point is that R9 280 have also exactly the same specifications, but the memory interface is only 256-bit, with 2GB GDDR5, inferior to the latter's 384-bit 3GB.
We can say only the core frequency of Turbo boost is up to 918MHz (single-precision floating point performance 3.29TFlops), but still lower than the R9 280 933MHz, the memory increase from 5GHz to 5.5GHz.
The core technology is still 28nm, but the entire card typical power consumption of only 190W, and now the R9 280 / 280X / 290, etc. are 250W, visible energy efficient the new core is quite high, Pair of six-pin can only be the point of attractiveness.
For now, no performance level data leaked. The official internal testing showed that the card with Core i7-4960X, 16GB DDR3-1866, 3DMark 11 may run out of P7066, X3513, far more than the GTX 760 P5650, X2774.
R9 285 will be available on September 2, the suggested retail price of $ 249. If we compare it will competitors from Nvidia Side Gtx 760 is of $239.


People in flats to rent in Waltham Forest will get a chance to see the Queen in March 2012 as the monarch pays a visit to the local town hall.
People occupying flats to rent in Barking and Dagenham are to see a number of improvements made to local roads.
People living in flats to rent in Harrow will see the area's local children's centres remaining open thanks to an innovative new operating model unveiled by the local council.
Residents of flats to rent in Epsom and Ewell can now gain access to new facilities at Rainbow Leisure Centre, which has just completed a £1 million refurbishment project.
People occupying flats to rent in Hounslow are to be encouraged to recycle via a new drive by the local authority to promote greener lifestyles.


text:
Q: Redirect loop after .htaccess update I want my WordPress based homepage to automatically start at abc.com/#about if the user enters abc.com.
I have added the following to my .htaccess file:
RewriteBase /
RewriteCond %{REQUEST_URI} !=about
RewriteRule ^$ /#about [L,R,NE]

The URL is changed, but the browser (chrome) give the error: "This webpage has a redirect loop".
I get the same behavior if I use
RewriteCond %{REQUEST_URI} !=/#about

or
RewriteCond %{REQUEST_URI} !=#about

It could be because the URL contains a #, but I'm not sure.
Thanks in advance.

A: One solution is to use cookies. You can set a cookie after redirecting to URI with # and then delete it. Try:
RewriteEngine On
RewriteCond %{HTTP_COOKIE} (^|\s)test=1($|\s)
RewriteRule $ - [L,CO=test:0:.your_site.com:-1]
RewriteRule $ /#about [L,R,NE,CO=test:1:.your_site.com]

A: Problem is that for the URL http://domain.com/#about browser doesn't send URI path after hash # to server and server will still see URL as http://domain.com/ which will make it redirect again and eventually browser shows looping error to you.
You can try this rule to stop the looping:
RewriteRule ^$ /index.html#about [L,NE,R]

OR else if index.php is your default file then:
RewriteRule ^$ /index.php#about [L,NE,R]

A: Try This:
RewriteBase /
RewriteCond %{REQUEST_URI} !=about
RewriteRule $ /%23about [L,R,NE]

The # part is replaced with URL encoded form %23. and the part which has to be rewritten should be $ , not ^$

redpajama_set_name: RedPajamaStackExchange


text:
The Trinidad and Tobago Olympic Committee (TTOC) and The University of Trinidad and Tobago (UTT) sign Memorandum of Understanding
The Trinidad and Tobago Olympic Committee (TTOC) and The University of Trinidad and Tobago (UTT) signed a Memorandum of Understanding (MoU) today, Friday 18th September, 2020 at the Olympic House in Port-of-Spain.
Ian Pritchard, Senior Manager (Ag.) Sport and Recreation at The UTT indicated that this MoU will establish a framework for collaboration between UTT and the TTOC, increasing the research, educational and training opportunities available to members of both institutions. Both parties expect that this will create opportunities for faculty, staff and athletes and allow accessibility to physical resources to support programmes of mutual interest.
Mr. Pritchard further indicated that a Partnership Committee, whose primary responsibility is to implement and execute the proposed goals stated in the MoU, will be established, comprising representatives of both entities.
TTOC and UTT look forward to working together to strengthening each other's organisational capacity to the benefit of the wider society of Trinidad and Tobago.
Over the past five (5) months the TTOC has hosted a series of courses and webinars and has forged collaborations, such as this one with the University, aimed at weathering this crisis situation, as well as preparing and upskilling our athletes, coaches and administrators for the future sporting environment.
According to Annette Knott, Secretary General of the TTOC, "a meaningful collaboration has been estabished with the UTT as we explore all the opportunities in Education and Research. Our joint webinars and research projects have included care and injury prevention, where the medical staff volunteers of the TTOC have joined with the scientists at UTT to look to the best practices during this period."
Ms. Knott further stated, "as we navigate the next steps in our Sporting environment our expectation can only be that our strength will be in continued collaborations with all the stakeholders."
President of the TTOC Brian Lewis explained that this is a first for the TTOC and a symbolic event. The world of sport is no longer recreation but high performance.
Lewis also stated "This MoU is therefore not ticking a box for some courses but delivering technology and processes based on research and development. It must complement the work of the national sporting organisations".
Mr. Lewis further stated "the real opportunity of this MoU is a start point for research and development. The priority from the TTOC perspective is implementation".
University of Trinidad and Tobago (UTT) Memorandum of Understanding (MoU)


text:
Watch the Show
Archive for Thu, Jul 9, 2020
Thu, Jul 9, 2020
Hour 2 – 07/09/20: Charlie Daniels (Encore)
In this encore presentation of an interview from September, 2017, country music legend Charlie Daniels talks with Eric about hard work, faith and music from his eagerly-awaited memoir, "Never Look at the Empty Seats." (Encore Presentation)
Hour 1 – 07/09/20: Robert R. Reilly
Robert R. Reilly, senior fellow at the American Foreign Policy Council, takes a look at the unique greatness of this country, and the push to fundamentally transform it, with a defense of the founding presented in his book, "America on Trial."
Podcast Archive Calendar
Show Guest List
www.MetaxasTalk.com
Home Listen Watch Games Videos Podcasting Gift Certificates
About Metaxas Super Frequently Asked Questions Customer Support
Copyright © 2021 Metaxas Super & Salem Media Group. All Rights Reserved.
Privacy Policy | California - Do not sell my personal information | California- CCPA Notice | Terms of Use


text:
Jan Hendrik de Waal Malefijt (Overveen, 31 januari 1852 – Katwijk, 14 maart 1931) was een Nederlands politicus voor de Anti-Revolutionaire Partij (ARP).

Levensloop
De Waal Malefijt had een bescheiden opleiding en was een wat schuchtere verschijning. Hij was eerst korte tijd onderwijzer, daarna een paar jaar gemeenteambtenaar en vervolgens fabrikant van een zeepziederij. Na burgemeestersposten in plattelandsgemeenten te hebben vervuld, werd hij in 1897 Tweede Kamerlid. Hij volgde in 1909 na veel aarzeling Idenburg op als minister van Koloniën in het kabinet-Heemskerk. Hij vervreemdde in die functie van Kuyper en werd niet als sterk minister beschouwd. Hij werd na zijn aftreden burgemeester van Katwijk.

De Waal Malefijt groeide op in de Nederlandse Hervormde Kerk maar ging in 1886 met de Doleantie mee, die in 1892 resulteerde in de oprichting van de Gereformeerde Kerken in Nederland.

De Waal Malefijt was ook nog van andere politieke organen lid:
Gemeenteraad van Zeist: 1884-1890
Burgemeester van Westbroek en Achttienhoven: 1890-1903
Provinciale Staten van Utrecht: 1892-1909
Gedeputeerde Staten van Utrecht: 1903-1909
Provinciale Staten van Zuid-Holland: 1916-1917
Eerste Kamer: 1917-1925

Onderscheiding
Ridder in de Orde van de Nederlandse Leeuw

Externe link
Waal Malefijt, Jan Hendrik de (1852-1931), Biografisch Woordenboek van Nederland

ARP-politicus
Gereformeerd persoon
Burgemeester van Katwijk
Burgemeester van Achttienhoven (Utrecht)
Gedeputeerde van Utrecht
Tweede Kamerlid
Eerste Kamerlid
Nederlands minister van Koloniën
Nederlands ambtenaar
Nederlands ondernemer
Burgemeester van Westbroek


Whether your visiting Hobart or a local, Solo Pasta and Pizza offers an Italian dining experience in an energised, and modern setting we know you will enjoy.
Select a section of our menu below to view. Our wine and drinks menu can be downloaded here.
Start your traditional Italian food experience off with one or more of delicious and authentic starter dishes.


Wir freuen uns schon mächtig auf unseren Stargast im nächsten Spieleveteranen-Podcast. David Fox entwickelte einst bei Lucasfilm Games Klassiker wie Rescue on Fractalus und Zak McKracken. Seine jüngste Veröffentlichung ist das Puzzle-Spiel Rube Works, zudem arbeitet er an dem neuen Grafik-Adventure Thimbleweed Park mit.
Wenn Ihr bestimmte Fragen an David Fox habt, dann postet sie bitte hier als Kommentar zu diesem Blog-Eintrag. Wir picken uns einige Eurer Fragen heraus und verlesen sie bei der Aufnahme. Es gibt auch was zu gewinnen, die drei kreativsten Fragesteller werden mit je einem Steam-Code für Rube Works belohnt.
Lucasfilm games of old had that feel to them that they were largely inspired by movies – or at least when you were watching the scenes (and cutscenes), characters would behave like actors. Shrugging, scratching their heads — gesturing and walking around even when engaging in scripted dialogs.
Are you going to give the scripted events that sort of feel again, that suggests to the player that he's watching a movie, and that the screen is treated like a camera? And will there be scene transition effects again, too? (when we see a different locale, or jump back and forth in time, et al).
War da jemals der Gedanke: Ich bin zu früh geboren und die Entwicklung der Computer war zu langsam, so dass ich zu der Zeit, wo ich kreativ war, so limitiert war durch die Technik und jetzt, wo die Technik fast "grenzenlos" erscheint, gehen mir die Ideen?
I have a few questions for you and hope you find the time to answer some of them.
(1) You started your career at a time of severe technological limitations; even so, Ballblazer, Fractalus, The Eidolon and Koronis Rift seemed to have come from another galaxy altogether, so advanced were they: was technological superiority a key USP for Lucasfilm Games at the time or did this come to be out of the necessities of your design documents?
(2) Had you had today's technology at your disposal then, would you have changed the designs of these early games? What might have been different?
(3) In a 1987 interview you explained that you always wanted to make players believe they were in a different universe, complaining, however, that you did not have access to widescreens and surround sound. Now that this and much more is available, could you see yourself designing a game that would push this nearly unlimited technology to the envelope?
(4) With your participation in Ron's and Gary's Thimbleweed Park, you seem to be returning to your game design roots; how much has game design as a profession changed since you began?
(5) Do you think it's possible that Noah, Ron, Gary and you might reunite, Beatles-style, for one last collaborative effort?
Thank you for your time, have a good 'un!
Ich hoffe, dass Boris bei diesem absolut ehrwürdigen Gast nochmal vor dem Mikro Platz nimmt.
are there any plans for a kind remake of "Rescue on Fractalus" or something similar ?
On ebay, you can find an active auction that tries to sell the C64 version of Zak McKracken on 5.25″ floppies including the original case, the manual, the original newspaper, a hint book and the code book.
It claims that it is signed by Ron, Matthew and you.
The owner says that he had the chance of getting his game signed by the three of you about ten years ago.
Auf den freue ich mich! Ich hege ja auch die vage Hoffnung, daß er nach einem hoffentlich erfolgreichen Thimbleweed Park die Lust verspürt, einen spirituellen Nachfolger Zak McKracken zu bauen.
Was ist aus dem Power Play Digital Projekt geworden? Die Webseite ist inzwischen im Nirvana.
Wenn's keinen was angeht schreibt dies ruhig, aber diese Frage stelle ich oft und bislang kommt nur Schweigen.
Aus Power Play Digital ist leider nichts geworden, mangels finanzieller Basis, die man für ein regelmäßiges Projekt mit diversen Autoren braucht. Vielleicht greifen wir die Idee eines Tages wieder auf – oder https://www.patreon.com/spieleveteranen wird so erfolgreich, dass wir hier mit mehr Content-Formen experimentieren.
Danke fuer die Info! Schade ist es sehr darum, aber mal sehen was die Zukunft noch bringt. Ein Gelegenheits-Blog mit feeds von euch allen im Stil von "Senior Gamer" vielleicht. Mal sehen.
Dear David Fox! Will there ever be a new book by Winnie Forster on http://www.gameplan.de? And even more important: Where can I get the terminal codes to leave the USA in Zak McKracken?
Frage nach der Rechnerkonfiguration: Ich habe einen….. muß ich aufrüsten?