Hooks
static bool BeforeCvLuaGame_lGetReplayMessage(lua_State* L, int& result);static void AfterCvLuaGame_lGetReplayMessage(lua_State* L, int& result);static int ReplaceCvLuaGame_lGetReplayMessage(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaGame_lGetReplayMessage>(host, &BeforeCvLuaGame_lGetReplayMessage);CivRegisterAfter<CivHooks::CvLuaGame_lGetReplayMessage>(host, &AfterCvLuaGame_lGetReplayMessage);CivRegisterReplace<CivHooks::CvLuaGame_lGetReplayMessage>(host, &ReplaceCvLuaGame_lGetReplayMessage);
Code
1627int CvLuaGame::lGetReplayMessage(lua_State* L)1628{1629 CvGame& game = GC.getGame();1630 const size_t nReplayMessages = game.getNumReplayMessages();16311632 unsigned int idx = luaL_checkint(L, 1);1633 if(idx < nReplayMessages)1634 {1635 const CvReplayMessage* pMessage = game.getReplayMessage(idx);16361637 lua_createtable(L, 0, 5);1638 const int t = lua_gettop(L);16391640 lua_pushinteger(L, pMessage->getPlayer());1641 lua_setfield(L, t, "Player");16421643 lua_pushinteger(L, pMessage->getTurn());1644 lua_setfield(L, t, "Turn");16451646 lua_pushinteger(L, pMessage->getType());1647 lua_setfield(L, t, "Type");16481649 const CvString& text = pMessage->getText();1650 if(text.GetLength() > 0)1651 {1652 lua_pushstring(L, text.c_str());1653 lua_setfield(L, t, "Text");1654 }16551656 const unsigned int nPlots = pMessage->getNumPlots();1657 if(nPlots > 0)1658 {1659 lua_createtable(L, nPlots, 0);1660 int plots_idx = 1;1661 int plots_t = lua_gettop(L);16621663 for(unsigned int i = 0; i < nPlots; i++)1664 {1665 int iPlotX, iPlotY;1666 if(pMessage->getPlot(i, iPlotX, iPlotY))1667 {1668 lua_createtable(L, 0, 2);1669 lua_pushinteger(L, iPlotX);1670 lua_setfield(L, -2, "X");1671 lua_pushinteger(L, iPlotY);1672 lua_setfield(L, -2, "Y");1673 lua_rawseti(L, plots_t, plots_idx++);1674 }1675 }16761677 lua_setfield(L, t, "Plots");1678 }16791680 return 1;1681 }16821683 return 0;1684}