Procházet zdrojové kódy

fix missing chunks

Kolja Strohm před 3 roky
rodič
revize
587d0bb449

+ 15 - 0
FactoryCraft/Chunk.cpp

@@ -447,6 +447,21 @@ void Chunk::removeView( Entity* zEntity )
     cs.unlock();
 }
 
+bool Chunk::hasView( Entity* zEntity )
+{
+    cs.lock();
+    for( Entity* e : views )
+    {
+        if( e == zEntity )
+        {
+            cs.unlock();
+            return 1;
+        }
+    }
+    cs.unlock();
+    return 0;
+}
+
 bool Chunk::hasViews() const
 {
     return views.getEintragAnzahl() > 0;

+ 1 - 0
FactoryCraft/Chunk.h

@@ -50,5 +50,6 @@ public:
     void setAdded();
     void addView( Entity* zEntity );
     void removeView( Entity* zEntity );
+    bool hasView( Entity* zEntity );
     bool hasViews() const;
 };

+ 4 - 4
FactoryCraft/Game.cpp

@@ -89,8 +89,8 @@ void GameClient::reply( Game* zGame )
         zGame->api( req, this );
     requests.leeren();
     other.unlock();
-    int x = (int)zPlayer->getPosition().x;
-    int y = (int)zPlayer->getPosition().y;
+    int x = (int)floor( zPlayer->getPosition().x );
+    int y = (int)floor( zPlayer->getPosition().y );
     int d = zPlayer->getCurrentDimensionId();
     foreground.lock();
     client->zForegroundWriter()->schreibe( (char*)&Message::POSITION_UPDATE, 1 );
@@ -138,9 +138,9 @@ void GameClient::reply( Game* zGame )
     }
     else
     {
-        Punkt lastMin = zGame->getChunkCenter( (int)lastPos.x - CHUNK_SIZE * viewDistance, (int)lastPos.y - CHUNK_SIZE * viewDistance );
+        Punkt lastMin = zGame->getChunkCenter( (int)floor( lastPos.x ) - CHUNK_SIZE * viewDistance, (int)floor( lastPos.y ) - CHUNK_SIZE * viewDistance );
         Punkt curMin = zGame->getChunkCenter( x - CHUNK_SIZE * viewDistance, y - CHUNK_SIZE * viewDistance );
-        Punkt lastMax = zGame->getChunkCenter( (int)lastPos.x + CHUNK_SIZE * viewDistance, (int)lastPos.y + CHUNK_SIZE * viewDistance );
+        Punkt lastMax = zGame->getChunkCenter( (int)floor( lastPos.x ) + CHUNK_SIZE * viewDistance, (int)floor( lastPos.y ) + CHUNK_SIZE * viewDistance );
         Punkt curMax = zGame->getChunkCenter( x + CHUNK_SIZE * viewDistance, y + CHUNK_SIZE * viewDistance );
         Dimension* dim = zGame->zDimension( d );
         if( dim )

+ 1 - 1
FactoryCraft/WorldUpdate.cpp

@@ -36,7 +36,7 @@ int WorldUpdate::distanceTo( int x, int y ) const
         xDist = 0;
     if( y >= minAffected.y && y <= maxAffected.y )
         yDist = 0;
-    return (int)sqrt( xDist * xDist + yDist * yDist );
+    return MIN( xDist, yDist );
 }