Example #1
0
File: s3_put.c Project: cheah/aws4c
int main ( int argc, char * argv[] )
{
  int rv;

  aws_init ();
  aws_set_debug  ( 0 );
  int rc = aws_read_config  ( "sample" );
  if ( rc )
    {
      puts ( "Could not find a credential in the config file" );
      puts ( "Make sure your ~/.awsAuth file is correct" );
      exit ( 1 );
    }

  s3_set_bucket ("aws4c.samples");
  s3_set_mime ("text/plain");
  s3_set_acl ("public-read");

  IOBuf * bf = aws_iobuf_new ();

  rv = putObject ( "aws4c.samplefile", bf );
  printf ( "RV %d\n", rv );

  printf ( "CODE    [%d] \n", bf->code );
  printf ( "RESULT  [%s] \n", bf->result );
  printf ( "LEN     [%d] \n", bf->len );
  printf ( "LASTMOD [%s] \n", bf->lastMod );
  printf ( "ETAG    [%s] \n", bf->eTag );

  while(-1)
    {
  char Ln[1024];
  int sz = aws_iobuf_getdata ( bf, Ln, sizeof(Ln));
  if ( Ln[0] == 0 ) break;
    printf ( "S[%3d] %s", sz, Ln );
    }

  /// Now Repeat using the RRS
  bf = aws_iobuf_new ();
  aws_set_rrs ( 1 ) ;
  rv = putObject ( "aws4c.samplefile.rrs", bf );
  printf ( "RV %d\n", rv );
  printf ( "CODE    [%d] \n", bf->code );
  printf ( "RESULT  [%s] \n", bf->result );
  printf ( "LEN     [%d] \n", bf->len );
  printf ( "LASTMOD [%s] \n", bf->lastMod );
  printf ( "ETAG    [%s] \n", bf->eTag );

  aws_deinit ();
  return 0;
}
Example #2
0
void
shMapLevel::buildTwistyRooms ()
{
    int i = 1000;
    int n = 0;
    int x, y;

    n = buildTwistyCorridor (RNG (mColumns / 3, 2 * mColumns / 3),
                             4, kSouth);
    while (--i and n < 4 * (mRows + mColumns)) {
        do {
            x = RNG (mColumns);
            y = RNG (mRows);
        } while (!TESTSQ (x, y, kFloor));
        n += buildTwistyCorridor (x, y, (shDirection) (2 * RNG (4)));
        if (n > 4 * (mRows + mColumns)) break;
    }


    buildSnuggledRooms ();
//    wallCorridors ();

    n = RNG (1, 6) + RNG (1, 6) + RNG (1, 6) + RNG (1, 6);
    for (i = 0; i < n; i++) {
        do {
            x = RNG (mColumns);
            y = RNG (mRows);
        } while (!TESTSQ (x, y, kFloor)  or
                 isObstacle (x, y));
        putObject (generateObject (), x, y);
    }

}
Example #3
0
	RetType Constructor( VM vm )
	{
		int i = 1;
		const char * modName = getString(vm,i);
		const char * interfaceName = getString(vm,i);
		T * t = (T*)engine->createInterface( modName, interfaceName );
		return putObject(vm, t, 1);
	}
Example #4
0
void JBtnObj::writeContent(JOutputStream& os) {
  JNBitsObj::writeContent(os);
  putObject(os, "label", label);
  putInteger(os, "type", type);
}
Example #5
0
void JBPosObj::writeContent(JOutputStream& os) {
  JAbsObj::writeContent(os);
  putObject(os, "v0", v[0]);
  putObject(os, "v1", v[1]);
}
Example #6
0
int
shMapLevel::buildSewer ()
{
    int x, y, i, n;
    int lighting = RNG (2) ? -1 : 1;
    SewerRoom nodes[NODECOLS][NODEROWS];

    mMapType = kSewer;

    x = RNG (NODECOLS);
    y = RNG (NODEROWS);

    //first pass
    buildSewerHelper (nodes, x, y, 0);

    //second pass, make more tightly connected
    for (n = 10; n; n--) {
        if (RNG(3)) {
            x = RNG (NODECOLS-1);
            y = RNG (NODEROWS);
            nodes[x][y].mWalls[1] = 0;
            nodes[x+1][y].mWalls[2] = 0;
        } else {
            x = RNG (NODECOLS);
            y = RNG (NODEROWS-1);
            nodes[x][y].mWalls[3] = 0;
            nodes[x][y+1].mWalls[0] = 0;
        }
    }

    for (x = 0; x < NODECOLS; x++) {
        for (y = 0; y < NODEROWS; y++) {
            if (nodes[x][y].mDeadEnd or !RNG(7)) {
                nodes[x][y].mBulbous = 1;
            }
        }
    }

    // force 2 bulbous rooms
    x = RNG (NODECOLS/3); y = RNG (NODEROWS);
    nodes[x][y].mBulbous = 1;
    x = NODECOLS - 1 - RNG (NODECOLS/3); y = RNG (NODEROWS);
    nodes[x][y].mBulbous = 1;

    // don't have adjacent bulbous rooms (looks bad)
    for (x = 0; x < NODECOLS-1; x++) {
        for (y = 0; y < NODEROWS; y++) {
            if (nodes[x][y].mBulbous and nodes[x+1][y].mBulbous and
                nodes[x][y].mWalls[1])
            {
                if (RNG(2))
                    nodes[x][y].mBulbous = 0;
                else
                    nodes[x+1][y].mBulbous = 0;
            }
        }
    }

    for (x = 0; x < NODECOLS; x++) {
        for (y = 0; y < NODEROWS-1; y++) {
            if (nodes[x][y].mBulbous and nodes[x][y+1].mBulbous and
                nodes[x][y].mWalls[3])
            {
                if (RNG(2))
                    nodes[x][y].mBulbous = 0;
                else
                    nodes[x][y+1].mBulbous = 0;
            }
        }
    }

    for (x = 0; x < NODECOLS; x++) {
        for (y = 0; y < NODEROWS; y++) {
            buildSewerRoom (nodes, x, y);
        }
    }

    for (n = NDX(2,4); n; n--) {
        floodMuck (RNG(NODECOLS)*6+5, RNG(NODEROWS)*4+2, kSewage, NDX(8,20));
    }

    for (i = NDX (2, 3); i; --i) {
        findUnoccupiedSquare (&x, &y);
        switch (RNG (4)) {
        case 0:
            addTrap (x, y, shFeature::kPit); break;
        case 1:
            addTrap (x, y, shFeature::kHole); break;
        case 2:
            addTrap (x, y, shFeature::kTrapDoor); break;
        case 3:
            addTrap (x, y, shFeature::kRadTrap); break;
        }
    }

    for (i = 0; i < 8; i++) {
        findUnoccupiedSquare (&x, &y);
        putObject (generateObject (mDLevel), x, y);
    }

    for (x = 0; x < mColumns; x++)
        for (y = 0; y < mRows; y++)
            setLit (x, y, lighting, lighting, lighting, lighting);



    return 1;
}
Example #7
0
int main(int argc, char** argv)
{
    String base = "=== [AWS API Init";
    std::cout << base << "]: Start===\n";
    Aws::SDKOptions options;
    // set the options
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info;
    // end of options
    Aws::InitAPI(options);
    // setup
    String signVer = SIGN_VER, host = HOST, portStr = PORT,
                bucketName = BUCKET;
    if (argc == 5)
    {
        signVer = argv[1];
        host = argv[2];
        portStr = argv[3];
        bucketName = argv[4];
    }

    auto client = init(host, portStr);
    std::cout << base << "]: End ===\n\n";
    // call tests here
    createBucket(client, bucketName);
    std::cout << '\n';

    // put object
    putObject(client, bucketName, "test.simple", SMALL_TEST_FILE);
    putObject(client, bucketName, "test.medium", MED_TEST_FILE);
    putObject(client, bucketName, "test.large", LARGE_TEST_FILE);

    // put object with metadata
    Map metadata;
    metadata[METADATA_KEY] = METADATA_VAL;
    putObject(client, bucketName, "test.simple.meta", SMALL_TEST_FILE, metadata);
    putObject(client, bucketName, "test.medium.meta", MED_TEST_FILE, metadata);
    putObject(client, bucketName, "test.large.meta", LARGE_TEST_FILE, metadata);

    // put object in parts
    putObjectMp(client, bucketName, "test.simple.mp", SMALL_TEST_FILE);
    putObjectMp(client, bucketName, "test.medium.mp", MED_TEST_FILE);
    putObjectMp(client, bucketName, "test.large.mp", LARGE_TEST_FILE);

    // put object in parts with metadata
    putObjectMp(client, bucketName, "test.simple.meta.mp", SMALL_TEST_FILE, metadata);
    putObjectMp(client, bucketName, "test.medium.meta.mp", MED_TEST_FILE, metadata);
    putObjectMp(client, bucketName, "test.large.meta.mp", LARGE_TEST_FILE, metadata);

    // head is already tested
    // get object
    getObject(client, bucketName, "test.simple", SMALL_TEST_FILE);
    getObject(client, bucketName, "test.medium", MED_TEST_FILE);
    getObject(client, bucketName, "test.large", LARGE_TEST_FILE);
    getObject(client, bucketName, "test.simple.mp", SMALL_TEST_FILE);
    getObject(client, bucketName, "test.medium.mp", MED_TEST_FILE);
    getObject(client, bucketName, "test.large.mp", LARGE_TEST_FILE);
    getObject(client, bucketName, "test.simple.meta", SMALL_TEST_FILE, metadata);
    getObject(client, bucketName, "test.medium.meta", MED_TEST_FILE, metadata);
    getObject(client, bucketName, "test.large.meta", LARGE_TEST_FILE, metadata);
    getObject(client, bucketName, "test.simple.meta.mp", SMALL_TEST_FILE, metadata);
    getObject(client, bucketName, "test.medium.meta.mp", MED_TEST_FILE, metadata);
    getObject(client, bucketName, "test.large.meta.mp", LARGE_TEST_FILE, metadata);

    // get fake object
    getFakeObject(client, bucketName, "test.noexist");

    // range get object
    rangeObject(client, bucketName, "test.simple", SMALL_TEST_FILE, 1, 4);
    // rangeObject(client, bucketName, "test.simple.mp", SMALL_TEST_FILE, 1, 4);
    rangeObject(client, bucketName, "test.large", LARGE_TEST_FILE, 1048576, 40485760);
    // rangeObject(client, bucketName, "test.large.mp", LARGE_TEST_FILE, 1048576, 10485760);

    // copy object
    copyObject(client, bucketName, "test.simple", "test.simple.copy");
    getObject(client, bucketName, "test.simple.copy", SMALL_TEST_FILE);

    // list object
    listObjects(client, bucketName, "", -1);

    // delete all objects
    deleteAllObjects(client, bucketName);
    listObjects(client, bucketName, "", 0);

    // put dummy objects
    putObject(client, bucketName, "list/test.small.", SMALL_TEST_FILE, Map(), 35);
    // multi-page list obj
    listObjects(client, bucketName, "list/", 35, 10);

    // multi-delete
    deleteObjects(client, bucketName, "list/test.small.", 10);
    listObjects(client, bucketName, "list/", 25);

    // get-put acl

    // delete bucket
    deleteBucket(client, bucketName);
    // end of tests
    std::cout << "=== AWS API Shutdown: Start===\n";
    Aws::ShutdownAPI(options);
    std::cout << "=== AWS API Shutdown: End ===\n";
    return 0;
}
Example #8
0
void JBSubObj::writeContent(JOutputStream& os) {
  JBAddObj::writeContent(os);
  putObject(os, "block", block);
  putInteger(os, "begin", begin);
  putInteger(os, "end", end);
}
Example #9
0
void JLEDObj::writeContent(JOutputStream& os) {
  JModuleObj::writeContent(os);
  putObject(os, "color", color);
  putObject(os, "bkgnd", bkgnd);
  putInteger(os, "value", value);
}
Example #10
0
/* returns 1 if shop successfully created, 0 o/w */
int
shMapLevel::makeShop (int sx, int sy, int ex, int ey, int kind)
{
    int x, y;
    int dx = -1, gx = -1;
    int dy = -1, gy = -1;
    shFeature *f;
    shFeature *door = NULL;
    shMonster *clerk;
    int roomid = mSquares[sx][sy].mRoomId;

    /* Find the door (we only make shops in rooms with exactly one door). */
    for (x = sx + 1; x < ex; x++) {
        f = getFeature (x, sy);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = x;
            dy = sy;
        }
        f = getFeature (x, ey);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = x;
            dy = ey;
        }
    }
    for (y = sy + 1; y < ey; y++) {
        f = getFeature (sx, y);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = sx;
            dy = y;
        }
        f = getFeature (ex, y);
        if (f and f->isDoor ()) {
            if (door) return 0;
            door = f;
            dx = ex;
            dy = y;
        }
    }

    if (!door)  return 0;  /* What?! There are no doors to this room? */

    /* Make sure door is a normal automatic door. */
    door->mType = shFeature::kDoorClosed;
    door->mDoor.mFlags = shFeature::kAutomatic;

    /* First row or column from the door shall be empty. */
    if (dx == sx) {
        sx++; dx++; gx = sx;
    } else if (dx == ex) {
        ex--; dx--; gx = ex;
    }
    if (dy == sy) {
        sy++; dy++; gy = sy;
    } else if (dy == ey) {
        ey--; dy--; gy = ey;
    }

    if (-1 == kind) { /* Randomly determine kind of shop. */
        switch (RNG (20)) {
        case 0: case 1: case 2: case 3: case 4:
        case 5: case 6: case 7:
            kind = shRoom::kGeneralStore; break;
        case 8: case 9: case 10:
            kind = shRoom::kHardwareStore; break;
        case 11: case 12: case 13:
            kind = shRoom::kSoftwareStore; break;
        case 14: case 15:
            kind = shRoom::kArmorStore; break;
        case 16: case 17:
            kind = shRoom::kWeaponStore; break;
        case 18:
            kind = shRoom::kImplantStore; break;
        case 19:
            kind = shRoom::kCanisterStore; break;
        }
    }

    bool infested = !RNG (25); /* Full of cockroaches. */

    for (x = sx + 1; x < ex; x++) { /* Get us some stuff to sell. */
        for (y = sy + 1; y < ey; y++) {
            shObject *obj = NULL;

            switch (kind) {
            case shRoom::kGeneralStore:
                obj = generateObject (-1); break;
            case shRoom::kHardwareStore:
                obj = createTool (); break;
            case shRoom::kSoftwareStore:
                if (RNG (8)) {
                    obj = createFloppyDisk ();
                } else {
                    obj = pickFromCategory (kObjGenericComputer);
                } break;
            case shRoom::kArmorStore:
                obj = createArmor (); break;
            case shRoom::kWeaponStore:
                if (RNG (20)) {
                    obj = createWeapon ();
                } else {
                    obj = createRayGun ();
                } break;
            case shRoom::kImplantStore:
                obj = createImplant (); break;
            case shRoom::kCanisterStore:
                obj = createCanister (); break;
            }
            obj->setUnpaid ();
            putObject (obj, x, y);

            if (infested and /* Put one under every big enough item. */
                obj->myIlk ()->mSize > MonIlks[kMonGiantCockroach].mSize)
            {
                shCreature *cockroach = new shMonster (kMonGiantCockroach);
                putCreature (cockroach, x, y);
            }
        }
    }

    /* The shopkeeper droid. */
    clerk = new shMonster (kMonClerkbot);
    putCreature (clerk, dx, dy);
    clerk->mShopKeeper.mHomeX = dx;
    clerk->mShopKeeper.mHomeY = dy;
    clerk->mShopKeeper.mShopId = roomid;
    clerk->mShopKeeper.mBill = 0;

    /* Shops may have a guard. */
    bool guarded = false;
    if (mDLevel > 4 and (!RNG (3) or mDLevel > TOWNLEVEL) and !isTownLevel ()) {
        shMonster *guard = NULL;
        shMonId guardtype[3] = {kMonSecuritron, kMonWarbot, kMonGuardbot};
        guard = new shMonster (guardtype [RNG (3)]);
        if (guard) { /* Pick a nice warm spot in a corner. */
            if (gx == -1) {
                gx = (sx+1 == dx) ? ex-1 :
                     (ex-1 == dx) ? sx+1 :
                          RNG (2) ? sx+1 : ex-1;
            } else {
                gy = (sy+1 == dy) ? ey-1 :
                     (ey-1 == dy) ? sy+1 :
                          RNG (2) ? sy+1 : ey-1;
            }
            if (!putCreature (guard, gx, gy)) {
                guard->mStrategy = shMonster::kGuard;
                guard->mDisposition = shMonster::kIndifferent;
                guard->mGuard.mToll = -1;
                guarded = true;
            }
        }
    }

    mRooms[roomid].mType = (shRoom::Type) kind;
    mFlags |= kHasShop;
    debug.log ("made %s%sshop on level %d.",
        guarded ? "guarded " : "", infested ? "infested " : "", mDLevel);
    return 1;
}
zend_object_value _http_requestpool_object_new(zend_class_entry *ce TSRMLS_DC)
{
	zend_object_value ov;
	http_requestpool_object *o;

	o = ecalloc(1, sizeof(http_requestpool_object));
	o->zo.ce = ce;

	http_request_pool_init(&o->pool);

	ALLOC_HASHTABLE(OBJ_PROP(o));
	zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0);
	zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));

	ov.handle = putObject(http_requestpool_object, o);
	ov.handlers = &http_requestpool_object_handlers;

	return ov;
}

void _http_requestpool_object_free(zend_object *object TSRMLS_DC)
{
	http_requestpool_object *o = (http_requestpool_object *) object;

	http_request_pool_dtor(&o->pool);
	freeObject(o);
}

#define http_requestpool_object_llist2array _http_requestpool_object_llist2array
static void _http_requestpool_object_llist2array(zval **req, zval *array TSRMLS_DC)
Example #12
0
void
shMapLevel::decorateRoom (int sx, int sy, int ex, int ey)
{
    if ((ex-sx) * (ey-sy) <= 20 + RNG (1, 20) and
        mDLevel > 1 and
        !RNG (1 + mDLevel) and
        !(kHasShop & mFlags) and
        makeShop (sx, sy, ex, ey))
    {
        return;
    }

    while (!RNG (8)) {  /* secret treasure niche */
        int x, y, dx, dy, horiz;
    failedniche:
        if (!RNG (222)) break;
        if (RNG (2)) {
            x = RNG (sx + 1, ex - 1);
            dx = x;
            horiz = 1;
            if (RNG (2)) {
                if (!testSquares (x - 1, sy - 2, x + 1, sy - 1, kStone))
                    goto failedniche;
                y = sy - 1;
                dy = sy;
            } else {
                if (!testSquares (x - 1, ey + 1, x + 1, ey + 2, kStone))
                    goto failedniche;
                y = ey + 1;
                dy = ey;
            }
        } else {
            y = RNG (sy + 1, ey - 1);
            dy = y;
            horiz = 0;
            if (RNG (2)) {
                if (!testSquares (sx - 2, y - 1, sx - 1, y + 1, kStone))
                    goto failedniche;
                x = sx - 1;
                dx = sx;
            } else {
                if (!testSquares (ex + 1, y - 1, ex + 2, y + 1, kStone))
                    goto failedniche;
                x = ex + 1;
                dx = ex;
            }
        }
        SETSQ (x-1, y-1, kHWall);
        SETSQ (x,   y-1, kHWall);
        SETSQ (x+1, y-1, kHWall);
        SETSQ (x-1, y,   kVWall);
        SETSQ (x,   y,   kFloor);
        SETSQ (x+1, y,   kVWall);
        SETSQ (x-1, y+1, kHWall);
        SETSQ (x,   y+1, kHWall);
        SETSQ (x+1, y+1, kHWall);

        SETSQ (dx, dy, kFloor);
        addDoor (dx, dy, horiz, 0, RNG (6), 1, !RNG(3), !RNG(10));
        SETSQFLAG (x, y, kHallway);
        if (RNG (6)) putObject (generateObject (mDLevel), x, y);
        if (RNG (2)) putObject (generateObject (mDLevel), x, y);

    }

    if (mDLevel > 7 and !RNG (15)) {
        /* monolith room */
        shMonster *m = new shMonster (kMonMonolith);
        putCreature (m, (sx + ex) / 2, (sy + ey) / 2);
        return;
    }

    if ((mDLevel > 6) and !RNG (22) and
        makeNest (sx, sy, ex, ey))
    {
        return;
    }

    if (mDLevel > 1 and mDLevel < 10 and
        !(kHasMelnorme & mFlags) and
        !RNG (30))
    {   /* Melnorme room. */
        makeTradePost (sx, sy, ex, ey);
    }   /* No return statement.  Trade post is a mundane room. */

    mundaneRoom (sx, sy, ex, ey);
}
Example #13
0
void
shMapLevel::moveWalls (int action)
{
    shFeature *f;

    int north = (1 == action or -1 == action) ? 1 : 0;

    int squares[20];
    int n = 0;
    int x, y;
    int i, j;
    int seen = 0;
    int interrupt = 0;
    int heard = 0;

    // move the wall
    y = -1;
    for (i = 0; i < mFeatures.count (); i++) {
        f = mFeatures.get (i);
        if (shFeature::kMovingHWall != f->mType) {
            continue;
        }
        if (action > 0) {
            /* close in */
            if (north and f->mMovingHWall.mBeginY < f->mMovingHWall.mEndY and
                f->mY < f->mMovingHWall.mEndY)
            {
                //if (Hero.canSee (f->mX, f->mY))
                //    setMemory (f->mX, f->mY, ' ');
                mVisibility[f->mX][f->mY] = 0;
                y = f->mY + 1;
                squares[n++] = f->mX;
                f->mY++;
                addMachinery (f->mX, f->mY-1);
            } else if (!north and f->mMovingHWall.mBeginY > f->mMovingHWall.mEndY and
                f->mY > f->mMovingHWall.mEndY)
            {
                //if (Hero.canSee (f->mX, f->mY))
                //    setMemory (f->mX, f->mY, ' ');
                mVisibility[f->mX][f->mY] = 0;
                y = f->mY - 1;
                squares[n++] = f->mX;
                f->mY--;
                addMachinery (f->mX, f->mY+1);
            } else {
                continue;
            }
            if (Hero.canSee (f->mX, f->mY)) {
                interrupt++;
                seen++;
            } else if (distance (&Hero, f->mX, f->mY) < 100) {
                heard++;
            }
        } else if (action < 0) {
            /* reset */
            int oldy = f->mY;
            if (north and f->mMovingHWall.mBeginY < f->mMovingHWall.mEndY and
                f->mY > f->mMovingHWall.mBeginY)
            {
                y = f->mY - 1;
                shFeature *machinery = getFeature (f->mX, y);
                if (machinery)
                    removeFeature (machinery);
                f->mY--;
            } else if (!north and
                       f->mMovingHWall.mBeginY > f->mMovingHWall.mEndY and
                       f->mY < f->mMovingHWall.mBeginY)
            {
                y = f->mY + 1;
                shFeature *machinery = getFeature (f->mX, y);
                if (machinery)
                    removeFeature (machinery);
                f->mY++;
            } else {
                continue;
            }
            if (Hero.canSee (f->mX, oldy))
                interrupt++;
        }
    }

    if (!Hero.getStoryFlag ("walls moving")) {
        if (seen) {
            I->p ("The walls are moving!");
            Hero.setStoryFlag ("walls moving", 1);
        } else if (heard and !Hero.getStoryFlag ("walls heard")) {
            I->p ("You hear a loud rumbling!");
            Hero.setStoryFlag ("walls heard", 1);
        }
    }

    // displace objects and creatures

    if (n) {
        shuffle (squares, n, sizeof(int));

        for (i = 0; i < n; i++) {
            x = squares[i];

            shObjectVector *v = getObjects (x, y);
            if (v) {
                int y2 = north ? y + 1 : y - 1;
                int safe = !isObstacle (x, y2);
                for (j = 0; j < v->count (); j++) {
                    shObject *obj = v->get (j);
                    if (safe) {
                        putObject (obj, x, y2);
                    } else {
                        delete obj;
                    }
                }
                if (Hero.mX == x and Hero.mY == y2) {
                    I->p ("%s pushed into your vicinity.",
                          v->count () > 1 ? "Some objects are"
                                          : "An object is");
                }
                delete v;
                setObjects (x, y, NULL);
            }

            shCreature *c = getCreature (x, y);
            if (c) {
                if (c->mZ < 0) {
                    if (c->isHero ()) {
                        I->p ("You are sealed below the moving wall!");
                        I->p ("That's not supposed to be possible!");
                        I->p ("Please send me a bug report! -cyrus");
                    }
                } else {
                    pushCreature (c, north ? kSouth : kNorth);
                }
            }
        }
    }
    if (interrupt)
        Hero.interrupt ();
}
Example #14
0
void
shMapLevel::mundaneRoom (int sx, int sy, int ex, int ey)
{
    int i, npiles, n;
    int x, y;

    if (mDLevel != TOWNLEVEL) {
        if (RNG (mDLevel + 6) > 9) {
            darkRoom (sx, sy, ex, ey);
        }

        if (!RNG (30)) {
            /* Radioactive room. */
            for (x = sx + 1; x < ex; x++) {
                for (y = sy + 1; y < ey; y++) {
                    mSquares[x][y].mFlags |= shSquare::kRadioactive;
                }
            }
        }
    }

    /* treasure expectation per room:
       version 0.3:
         0.375 piles x 1.1875 obj per pile +
         (~) 0.125 niches x 0.8 obj per niche
         ~ .5453125 objs per room

       version 0.2.9:
         0.375 piles x 1.375 obj per pile
         = .515625 obj per room
   */

    npiles = RNG (4) ? 0 : RNG (2) + RNG (2) + RNG (2);

    while (npiles--) {
        x = RNG (sx + 1, ex - 1);
        y = RNG (sy + 1, ey - 1);
        if (TESTSQ (x, y, kFloor)  and !isObstacle (x, y)) {
            n = RNG (10) ? 1 : RNG (2, 3);
            for (i = 0; i < n; i++) {
                putObject (generateObject (mDLevel), x, y);
            }
        }
    }

    if (0 == RNG (9)) {
        x = RNG (sx + 1, ex - 1);
        y = RNG (sy + 1, ey - 1);
        if (TESTSQ (x, y, kFloor) and !isObstacle (x, y) and
            0 == countObjects (x, y))
        {
            addVat (x, y);
        }
    }

    /* Reticulans of PRIME are weak enough to get instakilled in a pit.
       Do not place traps at all on first level. */
    while (!RNG (12) and mDLevel > 1) {
        x = RNG (sx + 1, ex - 1);
        y = RNG (sy + 1, ey - 1);
        if (TESTSQ (x, y, kFloor) and !isObstacle (x, y) and
            !getFeature (x, y))
        {
            shFeature::Type ttype;
        retrap:
            /* I'm using this retrap label because putting a for or while
               loop here uncovers a bug in g++! */
            /* FIXME: Probably the bug is long gone.  Get rid of goto. */
                ttype = (shFeature::Type) RNG (shFeature::kPit,
                                              shFeature::kPortal);
                switch (ttype) {
                case shFeature::kPit:
                case shFeature::kTrapDoor:
                    break;
                case shFeature::kAcidPit:
                    if (mDLevel < 7) goto retrap;
                    break;
                case shFeature::kHole:
                    if (RNG (5)) goto retrap;
                    break;
                case shFeature::kWeb:
                    goto retrap;
                case shFeature::kRadTrap:
                    if (mDLevel < 5) goto retrap;
                    break;
                case shFeature::kPortal:
                default: /* these traps are unimplemented */
                    goto retrap;
                }

            addTrap (x, y, ttype);
        }
    }
}
Example #15
0
void JBAddObj::writeContent(JOutputStream& os) {
  JModuleObj::writeContent(os);
  putObject(os, "value", value);
}
shared_ptr<PutObjectResult> GalaxyFDSClient::putObject(const string& bucketName,
    const string& objectName, istream& is) {
  return putObject(bucketName, objectName, is, FDSObjectMetadata());
}
Example #17
0
void JViewSet::writeContent(JOutputStream& os) {
  JViewObj::writeContent(os);
  putObject(os, "children", children);
}
Example #18
0
void JFont::writeContent(JOutputStream& os) {
  JObject::writeContent(os);
  putObject(os, "name", name);
  putInteger(os, "style", style);
  putInteger(os, "size", size);
}