bind g_map.getSpectators

This commit is contained in:
Eduardo Bart 2012-02-01 17:37:40 -02:00
parent 2a62159a61
commit 20390d6684
4 changed files with 7 additions and 5 deletions

View File

@ -21,7 +21,7 @@ local function onUseWithMouseRelease(self, mousePosition, mouseButton)
if mouseButton == MouseLeftButton then if mouseButton == MouseLeftButton then
local clickedWidget = Game.gameUi:recursiveGetChildByPos(mousePosition) local clickedWidget = Game.gameUi:recursiveGetChildByPos(mousePosition)
if clickedWidget then if clickedWidget then
if clickedWidget:getClassName() == 'Tile' then if clickedWidget:getClassName() == 'UIMap' then
local tile = clickedWidget:getTile(mousePosition) local tile = clickedWidget:getTile(mousePosition)
if tile then if tile then
Game.useWith(Game.selectedThing, tile:getTopMultiUseThing()) Game.useWith(Game.selectedThing, tile:getTopMultiUseThing())

View File

@ -306,6 +306,8 @@ std::vector<CreaturePtr> Map::getSpectatorsInRangeEx(const Position& centerPos,
maxZRange = Otc::MAX_Z; maxZRange = Otc::MAX_Z;
} }
//TODO: get creatures from other floors corretly
for(int iz=-minZRange; iz<=maxZRange; ++iz) { for(int iz=-minZRange; iz<=maxZRange; ++iz) {
for(int iy=-minYRange; iy<=maxYRange; ++iy) { for(int iy=-minYRange; iy<=maxYRange; ++iy) {
for(int ix=-minXRange; ix<=maxXRange; ++ix) { for(int ix=-minXRange; ix<=maxXRange; ++ix) {

View File

@ -197,7 +197,6 @@ void MapView::updateVisibleTilesCache(int start)
// cache visible tiles in draw order // cache visible tiles in draw order
// draw from last floor (the lower) to first floor (the higher) // draw from last floor (the lower) to first floor (the higher)
for(int iz = m_cachedLastVisibleFloor; iz >= m_cachedFirstVisibleFloor && !stop; --iz) { for(int iz = m_cachedLastVisibleFloor; iz >= m_cachedFirstVisibleFloor && !stop; --iz) {
//TODO: cleanup this code
if(m_viewRange <= FAR_VIEW) { if(m_viewRange <= FAR_VIEW) {
// draw tiles like linus pauling's rule order // draw tiles like linus pauling's rule order
const int numDiagonals = m_drawDimension.width() + m_drawDimension.height() - 1; const int numDiagonals = m_drawDimension.width() + m_drawDimension.height() - 1;
@ -245,6 +244,7 @@ void MapView::updateVisibleTilesCache(int start)
int fillHeight = (quadTopLeft.x >= 0) ? quadHeight-1 : quadHeight; int fillHeight = (quadTopLeft.x >= 0) ? quadHeight-1 : quadHeight;
if(quadTopLeft.y >= 0) { if(quadTopLeft.y >= 0) {
for(int qx=0;qx<fillWidth;++qx) { for(int qx=0;qx<fillWidth;++qx) {
//TODO: remvoe this repeated code
// only start really looking tiles in the desired start // only start really looking tiles in the desired start
if(count < start) { if(count < start) {
count++; count++;
@ -332,7 +332,6 @@ void MapView::updateVisibleTilesCache(int start)
// schedule next update continuation // schedule next update continuation
m_updateTilesCacheEvent = g_dispatcher.addEvent(std::bind(&MapView::updateVisibleTilesCache, asMapView(), count)); m_updateTilesCacheEvent = g_dispatcher.addEvent(std::bind(&MapView::updateVisibleTilesCache, asMapView(), count));
} }
if(start == 0) if(start == 0)
m_cachedFloorVisibleCreatures = g_map.getSpectators(cameraPosition, false); m_cachedFloorVisibleCreatures = g_map.getSpectators(cameraPosition, false);
} }
@ -448,7 +447,7 @@ int MapView::getFirstVisibleFloor()
Position cameraPosition = getCameraPosition(); Position cameraPosition = getCameraPosition();
// avoid rendering multile floors on far views // avoid rendering multifloors in far views
if(m_viewRange >= FAR_VIEW) if(m_viewRange >= FAR_VIEW)
return cameraPosition.z; return cameraPosition.z;
@ -495,7 +494,7 @@ int MapView::getLastVisibleFloor()
{ {
Position cameraPosition = getCameraPosition(); Position cameraPosition = getCameraPosition();
// avoid rendering multile floors on far views // avoid rendering multifloors in far views
if(m_viewRange >= FAR_VIEW) if(m_viewRange >= FAR_VIEW)
return cameraPosition.z; return cameraPosition.z;

View File

@ -73,6 +73,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction("g_map", "getCentralPosition", std::bind(&Map::getCentralPosition, &g_map)); g_lua.bindClassStaticFunction("g_map", "getCentralPosition", std::bind(&Map::getCentralPosition, &g_map));
g_lua.bindClassStaticFunction("g_map", "getCreatureById", std::bind(&Map::getCreatureById, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "getCreatureById", std::bind(&Map::getCreatureById, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "removeCreatureById", std::bind(&Map::removeCreatureById, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "removeCreatureById", std::bind(&Map::removeCreatureById, &g_map, _1));
g_lua.bindClassStaticFunction("g_map", "getSpectators", std::bind(&Map::getSpectators, &g_map, _1, _2));
g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor); g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor);