Exemplo n.º 1
0
Entity::Entity(int x, int y, Map *m, std::string name) :
    Viewable(x, y, m->getId()), hp(0), name(name), dir(DOWN), m(m)
{
    oidTable[getOid()] = this;
    for (int i = 0; i < StatusEffect::SE_KINDS; i++) {
        effects[i] = 0;
    }
}
Exemplo n.º 2
0
void Mob::getViewedBlock(IDataStream *dp)
{
	dp->appendShort(getX());
	dp->appendShort(getY());
	dp->appendInt(getOid());
	dp->appendShort(appearance | 0x4000);
	dp->appendInt(0);
	dp->appendByte(getDir());
	dp->appendByte(0);
	dp->appendByte(0);//type=0 mob
}
Exemplo n.º 3
0
string CssmData::toOid() const
{
	if (length() == 0)
		return "";

	unsigned int pos = 0;
		
	// first byte is composite (q1,q2)
	char buffer[10];
	unsigned long oid1 = getOid(*this, pos);
	unsigned long q1 = min(oid1 / 40, 2ul);
	snprintf(buffer, sizeof(buffer), "%lu.%lu", q1, oid1 - q1 * 40);
	string s = buffer;

	// now for the rest
	while (pos < length()) {
		char buffer[20];
		snprintf(buffer, sizeof(buffer), ".%lu", getOid(*this, pos));
		s += buffer;
	}
	return s;
}
Exemplo n.º 4
0
    void TxnOplog::spill() {
        // it is possible to have spill called when there
        // is nothing to actually spill. For instance, when
        // the root commits and we have already spilled,
        // we call spill to write out any remaining ops, of which
        // there may be none
        if (_m.size() > 0) {
            if (!_oid.isSet()) {
                _oid = getOid();
            }
            BSONObjBuilder b;

            // build the _id
            BSONObjBuilder b_id;
            b_id.append("oid", _oid);
            // probably not necessary to increment _seq, but safe to do
            b_id.append("seq", ++_seq);
            b.append("_id", b_id.obj());

            // build the ops array
            BSONArrayBuilder b_a;
            while (_m.size() > 0) {
                BSONObj o = _m.front();
                b_a.append(o);
                _m.pop_front();
                _mem_size -= o.objsize();
            }
            b.append("ops", b_a.arr());

            verify(_m.size() == 0);
            verify(_mem_size == 0);

            // insert it
            dassert(_logOpsToOplogRef);

            BSONObj obj = b.obj();
            TimerHolder timer(&_refsTimer);
            _refsSize += obj.objsize();
            _logOpsToOplogRef(obj);
        }
        else {
            // just a sanity check
            verify(_oid.isSet());
        }
    }
Exemplo n.º 5
0
void Entity::freeOid()
{
    oidTable[getOid()] = 0;
    //TODO consider releasing the oid maybe (so that it can be reused)
}