Exemplo n.º 1
0
void GameStateManager::handlePlayerMove(int32_t eid)
{
  const PlayerState & player = *m_states[eid];

  sendRawToAllExceptOne(rawPacketSCEntityTeleport(eid, getFractionalCoords(player.position), player.yaw, player.pitch), eid);

  auto interesting_blocks = m_map.blockAlerts().equal_range(getWorldCoords(player.position));

  for (auto it = interesting_blocks.first; it != interesting_blocks.second; ++it)
  {
    if (it->second.type == Map::BlockAlert::CONTAINS_SPAWN_ITEM)
    {
      const auto jt = m_map.items().find(it->second.data);
      if (jt != m_map.items().end())
      {
        sendToAll(MAKE_CALLBACK(packetSCCollectItem, jt->first, eid));
        sendToAll(MAKE_CALLBACK(packetSCDestroyEntity, jt->first));

        // Add 1 undamaged unit to the player's inventory.
        updatePlayerInventory(eid, jt->second, 1, 0);

        m_map.items().erase(jt);
      }
    }
  }
}
Exemplo n.º 2
0
void GameStateManager::reactToBlockDestruction(const WorldCoords & wc)
{
  // Clear the block alerts. The only alerts that can possibly be
  // stored with a solid block are of the type that we process here,
  // so we clear the entire range.

  auto interesting_blocks = m_map.blockAlerts().equal_range(wc);
  m_map.blockAlerts().erase(interesting_blocks.first, interesting_blocks.second);


  // Remove attached torches.

  WorldCoords wn;

  for (size_t k = 1; k < 6; ++k)
  {
    const WorldCoords wn = wc + Direction(k);

    if (!m_map.haveChunk(getChunkCoords(wn))) continue;

    unsigned char & block =  m_map.chunk(getChunkCoords(wn)).blockType(getLocalCoords(wn));

    if (block == BLOCK_Torch)
    {
      sendToAll(MAKE_CALLBACK(packetSCBlockChange, wn, BLOCK_Air, 0));
      block = BLOCK_Air;
      m_map.chunk(getChunkCoords(wn)).taint();
      reactToSuccessfulDig(wn, EBlockItem(block));
    }
  }

}
Exemplo n.º 3
0
bool LoadingScreen::Initialize()
{
#define MAKE_CALLBACK(FUNC) new r3dScaleformMovie::TGFxEICallback<LoadingScreen>(this, &LoadingScreen::FUNC)
	gfxMovie.RegisterEventHandler("eventRegisterUI", MAKE_CALLBACK(eventRegisterUI));

	return true;
}
Exemplo n.º 4
0
//---------------------------------------------------------------------------
void TSessionLog::Add(TLogLineType Type, const UnicodeString & Line)
{
  assert(FConfiguration);
  if (GetLogging())
  {
    try
    {
      if (FParent != nullptr)
      {
        DoAdd(Type, Line, MAKE_CALLBACK(TSessionLog::DoAddToParent, this));
      }
      else
      {
        TGuard Guard(FCriticalSection);

        BeginUpdate();
        auto cleanup = finally([&]()
        {
          DeleteUnnecessary();
          EndUpdate();
        });
        {
          DoAdd(Type, Line, MAKE_CALLBACK(TSessionLog::DoAddToSelf, this));
        }
      }
    }
    catch (Exception &E)
    {
      // We failed logging, turn it off and notify user.
      FConfiguration->SetLogging(false);
      try
      {
        throw ExtException(&E, LoadStr(LOG_GEN_ERROR));
      }
      catch (Exception &E)
      {
        AddException(&E);
        FUI->HandleExtendedException(&E);
      }
    }
  }
}
PluginFilterList::PluginFilterList(QWidget *parent) :
    QListWidget(parent)
{
    setModualName("plugin_filter_list");
    // set listener
    listenToParams(QStringList()<<"filter_names"<<"filter_status",
                   MAKE_CALLBACK(PluginFilterList::onSequenceChanged));

    // load filters command
    GitlIvkCmdEvt cRequest("reload_filter");
    cRequest.dispatch();
}
Exemplo n.º 6
0
void GameStateManager::reactToSuccessfulDig(const WorldCoords & wc, EBlockItem block_type)
{
  // this is just temporary
  std::cout << "Successfully dug at " << wc << " for " << BLOCKITEM_INFO.find(block_type)->second.name << std::endl;

  if (block_type == BLOCK_WoodenDoor || block_type == BLOCK_IronDoor)
  {
    Chunk & chunk = m_map.chunk(getChunkCoords(wc));

    if (wY(wc) < 127 && chunk.blockType(getLocalCoords(wc + BLOCK_YPLUS)) == block_type)
    {
      sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc + BLOCK_YPLUS, BLOCK_Air, 0));
      chunk.blockType(getLocalCoords(wc + BLOCK_YPLUS)) = BLOCK_Air;
    }

    if (wY(wc) > 0 && chunk.blockType(getLocalCoords(wc + BLOCK_YMINUS)) == block_type)
    {
      sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc + BLOCK_YMINUS, BLOCK_Air, 0));
      chunk.blockType(getLocalCoords(wc + BLOCK_YMINUS)) = BLOCK_Air;
    }

    spawnSomething(block_type == BLOCK_WoodenDoor ? ITEM_WoodenDoor : ITEM_IronDoor, 1, 0, wc);
  }

  else if (block_type != 0)
  {
    spawnSomething(uint16_t(block_type), 1, 0, wc);

    auto interesting_blocks = m_map.blockAlerts().equal_range(wc);

    for (auto it = interesting_blocks.first; it != interesting_blocks.second; ++it)
    {
      if (it->second.type == Map::BlockAlert::SUPPORTS_CANDLE)
      {
        reactToBlockDestruction(wc);
        break;
      }
    }
  }
}
Exemplo n.º 7
0
void GameStateManager::reactToToggle(const WorldCoords & wc, EBlockItem b)
{
  if (!m_map.haveChunk(getChunkCoords(wc))) return;

  Chunk & chunk = m_map.chunk(getChunkCoords(wc));

  switch (b)
  {
  case BLOCK_WoodenDoor:
  case BLOCK_IronDoor:
    {
      // We don't really care if the door is one, two or three blocks tall,
      // but we'll only treat at most one block above and below the clicked one.

      uint8_t meta = chunk.getBlockMetaData(getLocalCoords(wc));
      meta ^= 0x4;
      chunk.setBlockMetaData(getLocalCoords(wc), meta);
      sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc, b, meta));

      if (wY(wc) < 127 && chunk.blockType(getLocalCoords(wc + BLOCK_YPLUS)) == b)
      {
        uint8_t meta = chunk.getBlockMetaData(getLocalCoords(wc + BLOCK_YPLUS));
        meta ^= 0x4;
        chunk.setBlockMetaData(getLocalCoords(wc + BLOCK_YPLUS), meta);
        sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc + BLOCK_YPLUS, b, meta));
      }

      if (wY(wc) > 0 && chunk.blockType(getLocalCoords(wc + BLOCK_YMINUS)) == b)
      {
        uint8_t meta = chunk.getBlockMetaData(getLocalCoords(wc + BLOCK_YMINUS));
        meta ^= 0x4;
        chunk.setBlockMetaData(getLocalCoords(wc + BLOCK_YMINUS), meta);
        sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc + BLOCK_YMINUS, b, meta));
      }

      break;
    }
  default: break;
  }
}
Exemplo n.º 8
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    m_cPreferenceDialog(this),
    m_cBusyDialog(this),
    m_cThemeGroup(this),
    ui(new Ui::MainWindow)
{

    setModualName("main_window");
    ui->setupUi(this);

    /// set listeners
    listenToParams("picture", MAKE_CALLBACK(MainWindow::onFrameArrived));
    listenToParams(QStringList() <<"total_frame_num"<<"current_frame_poc",
                   MAKE_CALLBACK(MainWindow::onPOCInfoChanged));
    listenToParams("theme_stylesheet", MAKE_CALLBACK(MainWindow::onStylesheetChanged));
    listenToParams("snapshot", MAKE_CALLBACK(MainWindow::onSnapshot));


    /// layout hacks
    ui->msgDockWidget->widget()->layout()->setContentsMargins(0,0,0,0);
    ui->pluginFilterListDockWidget->widget()->layout()->setContentsMargins(0,0,0,0);
    ui->sequencesListDockWidget->widget()->layout()->setContentsMargins(0,0,0,0);

    /// exclusive theme action btns
    ui->defaultThemeAction->setActionGroup(&m_cThemeGroup);
    ui->darkThemeAction->setActionGroup(&m_cThemeGroup);

    /// bitstream drop open accepted
    setAcceptDrops(true);

    /// model init, including filter loading, etc..
    ModelLocator::getInstance();

    /// load theme from preferences
    GitlIvkCmdEvt cEvt("switch_theme");
    cEvt.setParameter("load_theme_from_pref", true);
    cEvt.dispatch();
}
Exemplo n.º 9
0
void GameStateManager::spawnSomething(uint16_t type, uint8_t number, uint8_t damage, const WorldCoords & wc)
{
  WorldCoords wbelow(wc);

  if (!fall(wbelow)) return;

  int32_t eid = GenerateEID();

  m_map.blockAlerts().insert(std::make_pair(wbelow, Map::BlockAlert(Map::BlockAlert::CONTAINS_SPAWN_ITEM, eid)));

  m_map.items().insert(std::make_pair(eid, type)); // stub

  sendToAll(MAKE_CALLBACK(packetSCPickupSpawn, eid, type, number, damage, wc));
}
Exemplo n.º 10
0
bool HUDRepair::Init()
{
	if(!gfxMovie_.Load("Data\\Menu\\WarZ_HUD_Repair.swf", false)) 
	{
		return false;
	}

#define MAKE_CALLBACK(FUNC) new r3dScaleformMovie::TGFxEICallback<HUDRepair>(this, &HUDRepair::FUNC)
    gfxMovie_.RegisterEventHandler("eventReturnToGame", MAKE_CALLBACK(eventReturnToGame));
	// repairall , repairiteminslot

	gfxMovie_.SetCurentRTViewport(Scaleform::GFx::Movie::SM_ExactFit);
	itemInventory_.initialize(&gfxMovie_);

	isActive_ = false;
	isInit_ = true;
	return true;
}
Exemplo n.º 11
0
GameStateManager::EBlockPlacement GameStateManager::blockPlacement(int32_t eid,
    const WorldCoords & wc, Direction dir, BlockItemInfoMap::const_iterator it, uint8_t & meta)
{
  // I believe we are never allowed to place anything on an already occupied block.
  // If that's false, we have to refactor this check. Water counts as unoccupied.

  if (!m_map.haveChunk(getChunkCoords(wc + dir)) || !isBuildable(EBlockItem(m_map.chunk(getChunkCoords(wc + dir)).blockType(getLocalCoords(wc + dir)))))
  {
    std::cout << "Sorry, cannot place object on occupied block at " << wc + dir << "." << std::endl;
    return CANNOT_PLACE;
  }

  // Likewise, we exclude globally right-clicks on banned block types, aka non-stackables.
  // Actually, I don't think the official server has such a rule. In fact, I think when the
  // client sends a PLACEMENT packet, it already expects the placement to be legal.
  // We're not expected to tell the client off. Oh well.

  if (!m_map.haveChunk(getChunkCoords(wc)) ||
      !isStackable(EBlockItem(m_map.chunk(getChunkCoords(wc)).blockType(getLocalCoords(wc)))) )
  {
    std::cout << "Sorry, cannot place object on non-stackable block at " << wc << "." << std::endl;
    return CANNOT_PLACE;
  }

  // Target block is clear and source block is stackable, let's get to work.

  switch(it->first) // block ID
  {
  case BLOCK_WoodenStairs:
  case BLOCK_CobblestoneStairs:
    {
      std::cout << "Special block: #" << eid << " is trying to place stairs." << std::endl;

      if (wY(wc) == 0 || dir == BLOCK_YMINUS) return CANNOT_PLACE;

      // Stairs are oriented to have their low end pointing toward the player.
      meta = 5 - int(m_states[eid]->getRelativeXZDirection(midpointRealCoords(wc + dir)));
      return OK_WITH_META;
    }

  case BLOCK_FurnaceBlock:
    {
      std::cout << "Special block: #" << eid << " is trying to place a furnace." << std::endl;

      if (wY(wc) == 0 || dir == BLOCK_YMINUS) return CANNOT_PLACE_AIRFORCE;

      const int d = int(m_states[eid]->getRelativeXZDirection(midpointRealCoords(wc + dir)));

      if      (d == 2) meta = 3;
      else if (d == 3) meta = 2;
      else if (d == 4) meta = 5;
      else if (d == 5) meta = 4;

      return OK_WITH_META;
    }
  case BLOCK_Torch:
  case BLOCK_RedstoneTorchOff:
  case BLOCK_RedstoneTorchOn:
    {
      std::cout << "Special block: #" << eid << " is trying to place a torch." << std::endl;

      // Torches are oriented simply to attach to the face which the user clicked.
      switch (int(dir))
      {
      case 2: meta = 4; break;
      case 3: meta = 3; break;
      case 4: meta = 2; break;
      case 5: meta = 1; break;
      default: meta = 5; break;
      }

      m_map.blockAlerts().insert(std::make_pair(wc, Map::BlockAlert(Map::BlockAlert::SUPPORTS_CANDLE)));

      return OK_WITH_META;
    }

  case ITEM_WoodenDoor:
  case ITEM_IronDoor:
    {
      // Doors can only be placed from above.
      if (dir != BLOCK_YPLUS)
        return CANNOT_PLACE;

      // Doors cannot be placed on glass, it seems.
      if (m_map.chunk(getChunkCoords(wc)).blockType(getLocalCoords(wc)) == BLOCK_Glass)
        return CANNOT_PLACE;

      const auto d = m_states[eid]->getRelativeXZDirection(midpointRealCoords(wc + dir));
      const unsigned char b = it->first == ITEM_WoodenDoor ? BLOCK_WoodenDoor : BLOCK_IronDoor;

      uint8_t meta;

      enum { HINGE_NE = 0, HINGE_SE = 1, HINGE_SW = 2, HINGE_NW = 3, SWUNG = 4 };

      switch (d)
      {
      case BLOCK_XPLUS:
        {
          if (m_map.haveChunk(getChunkCoords(wc + dir + BLOCK_ZPLUS)) &&
              !isBuildable(EBlockItem(m_map.chunk(getChunkCoords(wc + dir + BLOCK_ZPLUS)).blockType(getLocalCoords(wc + dir + BLOCK_ZPLUS)))))
            meta = HINGE_NW | SWUNG;
          else
            meta = HINGE_NE;
          break;
        }
      case BLOCK_XMINUS:
        {
          if (m_map.haveChunk(getChunkCoords(wc + dir + BLOCK_ZMINUS)) &&
              !isBuildable(EBlockItem(m_map.chunk(getChunkCoords(wc + dir + BLOCK_ZMINUS)).blockType(getLocalCoords(wc + dir + BLOCK_ZMINUS)))))
            meta = HINGE_SE | SWUNG;
          else
            meta = HINGE_SW;
          break;
        }
      case BLOCK_ZPLUS:
        {
          if (m_map.haveChunk(getChunkCoords(wc + dir + BLOCK_XMINUS)) &&
              !isBuildable(EBlockItem(m_map.chunk(getChunkCoords(wc + dir + BLOCK_XMINUS)).blockType(getLocalCoords(wc + dir + BLOCK_XMINUS)))))
            meta = HINGE_NE | SWUNG;
          else
            meta = HINGE_SE;
          break;
        }
      case BLOCK_ZMINUS:
        {
          if (m_map.haveChunk(getChunkCoords(wc + dir + BLOCK_XPLUS)) &&
              !isBuildable(EBlockItem(m_map.chunk(getChunkCoords(wc + dir + BLOCK_XPLUS)).blockType(getLocalCoords(wc + dir + BLOCK_XPLUS)))))
            meta = HINGE_SW | SWUNG;
          else
            meta = HINGE_NW;
          break;
        }
      default: return CANNOT_PLACE;
      }

      // Double-door algorithm: only check for a door on the left (apparently that's what the client does).
      if      (d == BLOCK_XMINUS && m_map.chunk(getChunkCoords(wc + dir + BLOCK_ZPLUS)) .blockType(getLocalCoords(wc + dir + BLOCK_ZPLUS))  == b)
      {
        meta = HINGE_SE | SWUNG;
      }
      else if (d == BLOCK_XPLUS  && m_map.chunk(getChunkCoords(wc + dir + BLOCK_ZMINUS)).blockType(getLocalCoords(wc + dir + BLOCK_ZMINUS)) == b)
      {
        meta = HINGE_NW | SWUNG;
      }
      else if (d == BLOCK_ZMINUS && m_map.chunk(getChunkCoords(wc + dir + BLOCK_XMINUS)).blockType(getLocalCoords(wc + dir + BLOCK_XMINUS)) == b)
      {
        meta = HINGE_SW | SWUNG;
      }
      else if (d == BLOCK_ZPLUS  && m_map.chunk(getChunkCoords(wc + dir + BLOCK_XPLUS)) .blockType(getLocalCoords(wc + dir + BLOCK_XPLUS))  == b)
      {
        meta = HINGE_NE | SWUNG;
      }

      sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc + dir, b, meta));
      sendToAll(MAKE_CALLBACK(packetSCBlockChange, wc + dir + BLOCK_YPLUS, b, meta | 0x8));

      Chunk & chunk = m_map.chunk(getChunkCoords(wc + dir));
      chunk.blockType(getLocalCoords(wc + dir)) = b;
      chunk.setBlockMetaData(getLocalCoords(wc + dir), meta);
      chunk.blockType(getLocalCoords(wc + dir + BLOCK_YPLUS)) = b;
      chunk.setBlockMetaData(getLocalCoords(wc + dir + BLOCK_YPLUS), meta | 0x8);

      return OK_NO_META;
    }

  default:
    return OK_NO_META;
  }

  return OK_NO_META;
}
Exemplo n.º 12
0
static void InitDLLCallbackFunctions(void)
{ 
    KppSetEvalKalHandler((FARPROC) EvalKalHandlersCB);

    MAKE_CALLBACK(Tone);    
    MAKE_CALLBACK(EvalCFunc);
    MAKE_CALLBACK(RenameItem_ClBrowser);
    MAKE_CALLBACK(RemoveFrom_ClBrowser);
    MAKE_CALLBACK(AddTo_ClBrowser);
    MAKE_CALLBACK(UpdateCommonSymbols);
    MAKE_CALLBACK(BeforeNewApplication);
    MAKE_CALLBACK(AfterNewApplication);
    MAKE_CALLBACK(FinishNewApplication);
    MAKE_CALLBACK(BeforeSaveApplication);
    MAKE_CALLBACK(AfterSaveApplication); 
    MAKE_CALLBACK(BeforeInterpretFile);
    MAKE_CALLBACK(AfterInterpretFile);
    MAKE_CALLBACK(BeforeWriteKalFile);
    MAKE_CALLBACK(AfterWriteKalFile);
    MAKE_CALLBACK(PrintHierarchy);
    MAKE_CALLBACK(BeforeMoveGroup);
    MAKE_CALLBACK(AfterMoveGroup);
    MAKE_CALLBACK(ConvertInstanceToClass);
    MAKE_CALLBACK(ConvertClassToInstance);
    MAKE_CALLBACK(ExplainPair);
    MAKE_CALLBACK(EnablePrintMenuItem);
    MAKE_CALLBACK(MarkAppAsUnmodified);
    MAKE_CALLBACK(ShowSubNodes);
    MAKE_CALLBACK(GetAppName);
    MAKE_CALLBACK(DisplaySlotValue);
    MAKE_CALLBACK(ExtractSlotValue);
    MAKE_CALLBACK(hWndKappa);
    MAKE_CALLBACK(hWndBrowser);
    MAKE_CALLBACK(hWndKAL);
    MAKE_CALLBACK(ShowSystemWindow);
    MAKE_CALLBACK(HideSystemWindow);
    MAKE_CALLBACK(IconMaxSystemWindow);
    MAKE_CALLBACK(GetDefPrinterDC);
    MAKE_CALLBACK(SetupPrintAbort);
    MAKE_CALLBACK(TakedownPrintAbort);
    MAKE_CALLBACK(SelectItem);
    MAKE_CALLBACK(RequestArg);
    MAKE_CALLBACK(GetClBrowserFocus);
    MAKE_CALLBACK(SetClBrowserFocus);
    MAKE_CALLBACK(ConvertBrowserDTxt);
    MAKE_CALLBACK(SetPostMenuPosition);
    MAKE_CALLBACK(PostLBMenuSelection);
    MAKE_CALLBACK(PostMenu);
    MAKE_CALLBACK(PostMultipleSelection);
    MAKE_CALLBACK(AddToIF);
    MAKE_CALLBACK(PostInputForm);
    MAKE_CALLBACK(LoadBinApp);
    MAKE_CALLBACK(WaitForInput);
    MAKE_CALLBACK(ResetClock);
    MAKE_CALLBACK(GetClock);
    MAKE_CALLBACK(Wait);
    MAKE_CALLBACK(IncrementPopupCount);
    MAKE_CALLBACK(DecrementPopupCount);
    MAKE_CALLBACK(OpenSaveFile);
    MAKE_CALLBACK(SelectBrowserObject);
    MAKE_CALLBACK(BrowserGetSelections);
    MAKE_CALLBACK(Increment_ClBrowserAtoms);
    MAKE_CALLBACK(ScaleBrowser);
    MAKE_CALLBACK(SetDDEInst);
    MAKE_CALLBACK(GetKalFunctionSyntax);
#ifndef RUNTIME
    MAKE_CALLBACK(ChangeAllColors_RlBr);
    MAKE_CALLBACK(RequestSlot);
    MAKE_CALLBACK(RequestMethod);
    MAKE_CALLBACK(hWndInterpret);
    MAKE_CALLBACK(hWndInference);
    MAKE_CALLBACK(hWndTrace);
    MAKE_CALLBACK(hWndTraceText);
    MAKE_CALLBACK(hWndRuleRel);
    MAKE_CALLBACK(hWndFinder);
    MAKE_CALLBACK(hWndKalView);
    MAKE_CALLBACK(RequestNewItemName);
    MAKE_CALLBACK(RequestNewItem);
    MAKE_CALLBACK(ChangeRule);
    MAKE_CALLBACK(Clear_RlBrowser);
    MAKE_CALLBACK(AddTo_RlBrowser);
    MAKE_CALLBACK(ChangeColor_RlBrowser);
    MAKE_CALLBACK(AddTo_RlBrowserForward);
    MAKE_CALLBACK(RemoveFromWindowMenu);
    MAKE_CALLBACK(AddToWindowMenu);
    MAKE_CALLBACK(Increment_RlBrowserAtoms);
    MAKE_CALLBACK(StepTraceAction);
    MAKE_CALLBACK(ShowFunction);
    MAKE_CALLBACK(ShowMethod);
#else
    MAKE_CALLBACK(HandleRunTimeMenus);
#endif
}
GitlFrontController::GitlFrontController()
{
    m_iMaxEvtInQue = 1000;
    subscribeToEvtByName(GITL_EXE_COMMAND_REQUEST_EVENT, MAKE_CALLBACK(GitlFrontController::detonate));
    this->start();
}