示例#1
0
void eraseGeometry()
{
    // Clear out map
    int halfSize = getworldsize()/2;
    loopi(2) loopj(2) loopk(2)
        deleteCube(i*halfSize, j*halfSize, k*halfSize, halfSize);
}
示例#2
0
void createCube(int x, int y, int z, int gridsize)
{
    logger::log(logger::DEBUG, "createCube: %d,%d,%d  --  %d\r\n", x, y, z, gridsize);

    if (!checkCubeCoords(x, y, z, gridsize))
    {
        logger::log(logger::ERROR, "Bad cube coordinates to createCube: %d,%d,%d : %d\r\n", x, y, z, gridsize);
        return;
    }

    // We simulate creating a cube by extruding from another, using mpeditface. This works even if there is no cube there to extrude from.
    selinfo sel;
    // We can either extrude from an imaginary cube from below, or from above. If there is room below, then extrude from there
    if (z - gridsize >= 0)
    {
        sel.o = ivec(x, y, z - gridsize);
        sel.orient = 5; // up
    } else {
        assert(z + gridsize < getworldsize());
        sel.o = ivec(x, y, z + gridsize);
        sel.orient = 4; // down
    }

    sel.s = ivec(1, 1, 1);
    sel.grid = gridsize;

    // Does it matter?
    sel.corner = 1;
    sel.cx = 0;
    sel.cxs = 2;
    sel.cy = 0;
    sel.cys = 2;

    mpeditface(-1, 1, sel, true);
}
示例#3
0
文件: client.cpp 项目: offtools/cubej
 void Client::loadScene(const char* name) {
     if(load_world(name)) {
         copystring(clientmap, name);
     }
     CubeJ::MsgDataType<CubeJ::MSG_SND_SCENEINFO> data(clientmap, getworldsize(), getmapversion());
     SendMessage(data);
 }
示例#4
0
// Ensure that cube coordinates are valid. (x,y,z) can be any values in 0..getworldsize, and gridsize must
// be a cube size appropriate for that, i.e.,
//      512,512,512  ;  64
// is fine, as a cube of size 64 can indeed start there. But
//      1, 1, 1      ;  64
// is invalid, as only a cube of size 1 can be in that position.
bool checkCubeCoords(int x, int y, int z, int gridsize)
{
    int curr = 1;
    while (curr < getworldsize())
    {
        if (gridsize == curr)
            break;
        curr *= 2;
    }
    if (gridsize != curr) return false;

    if (gridsize*(x/gridsize) != x ) return false;
    if (gridsize*(y/gridsize) != y ) return false;
    if (gridsize*(z/gridsize) != z ) return false;

    if (x >= getworldsize()) return false;
    if (y >= getworldsize()) return false;
    if (z >= getworldsize()) return false;

    return true;
}
示例#5
0
文件: waypoint.cpp 项目: swooboo/base
 int getpull(const vec &o)
 {
     vec pos = o; pos.z += JUMPMIN;
     if(!insideworld(vec(pos.x, pos.y, min(pos.z, getworldsize() - 1e-3f)))) return -2;
     float dist = raycube(pos, vec(0, 0, -1), 0, RAY_CLIPMAT);
     int posmat = lookupmaterial(pos), pull = 1;
     if(isliquid(posmat&MATF_VOLUME)) pull *= 5;
     if(dist >= 0)
     {
         pull = int(dist/JUMPMIN);
         pos.z -= clamp(dist-8.0f, 0.0f, pos.z);
         int trgmat = lookupmaterial(pos);
         if(trgmat&MAT_DEATH || (trgmat&MATF_VOLUME) == MAT_LAVA) pull *= 10;
         else if(isliquid(trgmat&MATF_VOLUME)) pull *= 2;
     }
     return pull;
 }