void ClientConnection::createCharacter(const RootOperation& op)
{
    static unsigned int charCounter = 0;
    char charId[64];
    ::snprintf(charId, 64, "_customChar_%d", ++charCounter);
    
    RootEntity ent = smart_dynamic_cast<RootEntity>(op->getArgs().front());
    
    ent->setId(charId);
    ent->setLoc("_world");
    m_server->m_world[charId] = ent;

    StringList children(m_server->m_world["_world"]->getContains());
    children.push_back(charId);
    m_server->m_world["_world"]->setContains(children);

    Agent* ag = new Agent(this, charId);
    ag->setEntityVisible(charId, true);
    
    m_agents[charId] = ag;
    
    Info info;
    info->setArgs1(m_server->m_world[charId]);
    info->setFrom(charId);
    info->setTo(m_account); // I *think* this is right
    info->setRefno(op->getSerialno());
    
    send(info);
}
const EnvironmentGroup::Info EnvironmentGroup::getDefaultEnvironment () const
{
	Info rfgi;
	rfgi.setFamilyId(0);

	return rfgi;
}
void ClientConnection::activateCharacter(const std::string& charId, const RootOperation& op)
{
    // special magic testing IDs
    if (charId == "_fail_") {
        sendError("deliberate", op);
        return;
    }

    assert(entityIsCharacter(charId));
    //debug() << "activation, inbound op's serial is " << op->getSerialno();
    
    if (m_agents.count(charId)) {
        sendError("duplicate character action", op);
        return;
    }
    
    Agent* ag = new Agent(this, charId);
    m_agents[charId] = ag;
    
    Info info;
    info->setArgs1(m_server->m_world[charId]);
    info->setFrom(charId);
    info->setTo(m_account); // I *think* this is right
    info->setRefno(op->getSerialno());
    
    send(info);
    ag->processOp(op); // process as normal
}
Example #4
0
int main() {
    Info info;
    cout << info.getType() << endl;
    cout << info.getName() << endl;
    cout << is_rvalue_reference<string&&>::value << endl;
    return 0;    
}
void ClientConnection::processAccountCreate(const Create& cr)
{
    const std::vector<Root>& args = cr->getArgs();
    if (args.empty()) {
        sendError("missing account in create", cr);
        return;
    }
    
    // check for duplicate username
    AtlasAccount acc = smart_dynamic_cast<AtlasAccount>(args.front());
    if (!acc.isValid()) {
        sendError("malformed account in create", cr);
        return;
    }
    
    AccountMap::const_iterator A = m_server->findAccountByUsername(acc->getUsername());
    if (A  != m_server->m_accounts.end()) {
        sendError("duplicate account: " + acc->getUsername(), cr);
        return;
    }
    
    m_account = std::string("_") + acc->getUsername() + "_123";
    acc->setId(m_account);
    m_server->m_accounts[m_account] = acc;
    
    Info createInfo;
    createInfo->setArgs1(acc);
    createInfo->setTo(m_account);
    createInfo->setRefno(cr->getSerialno());
    send(createInfo);
    
    m_server->joinRoom(m_account, "_lobby");
    m_server->resetWorld();
}
Example #6
0
void Juncture::onSocketConnected()
{
    m_peer = new Peer(*m_socket, m_connection->m_server,
                      m_host, m_port, getId(), getIntId());

    m_socket->setup(m_peer);
    m_peer->destroyed.connect(sigc::mem_fun(this, &Juncture::onPeerLost));
    m_peer->replied.connect(sigc::mem_fun(this, &Juncture::onPeerReplied));

    log(INFO, String::compose("Juncture onPeerC succeeded %1", getId()));
    if (m_connection != 0) {
        Anonymous info_arg;
        addToEntity(info_arg);

        Info info;
        info->setArgs1(info_arg);
        if (m_connectRef != 0L) {
            info->setRefno(m_connectRef);
        }

        m_connection->send(info);
    }
    m_socket = 0;
    m_connectRef = 0L;
}
void ClientConnection::processAnonymousGet(const Get& get)
{
    const std::vector<Root>& args = get->getArgs();
    if (args.empty())
    {
        Info serverInfo;
        RootEntity svObj;
        
        Atlas::Message::ListType prs;
        prs.push_back("server");
        svObj->setParentsAsList(prs);
        
        svObj->setName("Bob's StubServer");
        svObj->setAttr("server", "stubserver");
        svObj->setAttr("ruleset", "stub-world");
        svObj->setAttr("uptime", 666.0);
        svObj->setAttr("clients", 42);
        
        serverInfo->setArgs1(svObj);
        send(serverInfo);
    } else {
        std::string typeName = args.front()->getId();

        if (m_server->m_types.count(typeName))
        {
            Info typeInfo;
            typeInfo->setArgs1(m_server->m_types[typeName]);
            typeInfo->setRefno(get->getSerialno());
            send(typeInfo);
        } else
            sendError("unknown type " + typeName, get);
    }
}
Example #8
0
//
// DTrack::RegisterDestruction
//
// Register the destruction of the item 'info'
//
void DTrack::RegisterDestruction(Info &info)
{
  // Never registered, or has died - perhaps deleting twice?
  if (!info.IsSetup())
  {
    ERR_FATAL(("Invalid destruction : Item is NOT setup! (Tracker %s)", name.str));
  }
  
  // Different id, something bad has happened - perhaps bad memory?
  if (*info.trackPos != info.id)
  {
    ERR_FATAL(("Invalid destruction : Different Id (Tracker %s, %d, %d)", name.str, *info.trackPos, info.id));
  }

  // Set item as empty
  *info.trackPos = DTRACK_EMPTY;

  // Add to cache
  CacheAdd(info.trackPos);

  // Info is no longer setup
  info.Clear();

  ASSERT(stateInfo.items);

  // Decrease number of items
  stateInfo.items--;
}
Example #9
0
int main(int argc, char** argv) {

    TestBox t;
    MidiInfo minf("midifiles/Cisei.kar"); //open file (open initialize also ticklength of file, resolution.....)

    if(minf.isValid())
        minf.readInfo(&t); //if you have a valid midi, read all info filling t
    else
        return ERR_NOTMIDI;

    minf.readInfo(); //now try to call readInfo without parameters. What happens? Nothing special but..

    Tick* inf = minf.getInfo();//you can use defaul struct Tick

    Info *n = inf[22320].info;

    unsigned char* buf;

    while((n != NULL) && (buf = n->nextInfo()))
        printf("\nInfo :%s", buf);

    printf("\n\nNumber of ticks: %d Resolution: %dtpb Length: %dsec.\n", minf.getTickLength(), minf.getResolution(), minf.getSecondLenght());

    return 0;
}
static int DefaultOnClick(WPARAM hContact, LPARAM lParam, LPARAM param)
{
	Info *p = (Info*)param;
	if (p == NULL)
		return 0;

	if (hContact == NULL)
		return 0;

	char *proto = GetContactProto(hContact);
	if (IsEmpty(proto))
		return 0;

	bool found = false;
	for (int j = 0; !found && j < SIZEOF(p->db); j += 2) {
		if (p->db[j + 1] == NULL)
			break;

		ptrA szValue(db_get_sa(hContact, p->db[j] == NULL ? proto : p->db[j], p->db[j + 1]));
		if (!IsEmpty(szValue)) {
			p->OnClick(p, szValue);
			found = true;
		}
	}

	return 0;
}
static int DefaultOnClick(WPARAM wParam, LPARAM lParam, LPARAM param)
{
	Info *info = (Info *) param;
	if (info == NULL)
		return 0;

	HANDLE hContact = (HANDLE) wParam;
	if (hContact == NULL)
		return 0;

	char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
	if (IsEmpty(proto))
		return 0;

	bool found = false;
	for (unsigned int j = 0; !found && j < MAX_REGS(info->db); j += 2)
	{
		if (info->db[j + 1] == NULL)
			break;

		DBVARIANT dbv = { 0 };
		if (!DBGetContactSettingString(hContact, info->db[j] == NULL ? proto : info->db[j], info->db[j+1], &dbv))
		{
			if (!IsEmpty(dbv.ptszVal))
			{
				info->OnClick(info, dbv.ptszVal);
				found = true;
			}

			DBFreeVariant(&dbv);
		}
	}

	return 0;
}
Example #12
0
Info operator + (const Info &L,const Info &R){
    Info ret;
    ret.init(L.siz + R.siz);
    for(int i=0;i<3;i++){
        ret.s[i] = (L.s[i] + R.s[i]) % mod;
    }
    return ret;
}
Example #13
0
const RadialGroup::Info RadialGroup::getDefaultRadial () const
{
    Info rfgi;
    rfgi.setFamilyId(0);
    rfgi.setChildChoice(0.f);

    return rfgi;
}
Example #14
0
    static bool ValidArgs(const Info& info, size_t rowBytes, size_t* minSize) {
        const int maxDimension = SK_MaxS32 >> 2;

        if (info.width() <= 0 || info.height() <= 0) {
            return false;
        }
        if (info.width() > maxDimension || info.height() > maxDimension) {
            return false;
        }
        if ((unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType) {
            return false;
        }
        if ((unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType) {
            return false;
        }

        if (kUnknown_SkColorType == info.colorType()) {
            return false;
        }
        if (!info.validRowBytes(rowBytes)) {
            return false;
        }

        size_t size = info.computeByteSize(rowBytes);
        if (SkImageInfo::ByteSizeOverflowed(size)) {
            return false;
        }

        if (minSize) {
            *minSize = size;
        }
        return true;
    }
Example #15
0
    static bool ValidArgs(const Info& info, size_t rowBytes, size_t* minSize) {
        const int maxDimension = SK_MaxS32 >> 2;

        if (info.width() <= 0 || info.height() <= 0) {
            return false;
        }
        if (info.width() > maxDimension || info.height() > maxDimension) {
            return false;
        }
        if ((unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType) {
            return false;
        }
        if ((unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType) {
            return false;
        }

        if (kUnknown_SkColorType == info.colorType()) {
            return false;
        }
        if (rowBytes < info.minRowBytes()) {
            return false;
        }

        size_t size = info.getSafeSize(rowBytes);
        if (0 == size) {
            return false;
        }

        if (minSize) {
            *minSize = size;
        }
        return true;
    }
Example #16
0
void Admin::SetOperation(const Operation & op, OpVector & res)
{
    const std::vector<Root> & args = op->getArgs();
    if (args.empty()) {
        error(op, "Set has no args.", res, getId());
        return;
    }
    const Root & arg = args.front();
    if (!arg->hasAttrFlag(Atlas::Objects::OBJTYPE_FLAG)) {
        error(op, "Set arg has no objtype.", res, getId());
        return;
    }
    const std::string & objtype = arg->getObjtype();
    if (!arg->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
        error(op, "Set arg has no id.", res, getId());
        return;
    }
    const std::string & id = arg->getId();

    if (objtype == "object" || objtype == "obj") {

        long intId = integerId(id);

        if (intId == getIntId()) {
            setAttribute(arg);
        } else {

            if (m_charactersDict.find(intId) != m_charactersDict.end()) {
                Account::SetOperation(op, res);
                return;
            }
            log(WARNING, "Unable to set attributes of non-character yet");
        }
        // Manipulate attributes of existing objects.
    } else if (objtype == "class" || objtype == "op_definition") {
        if (Inheritance::instance().hasClass(id)) {
            if (Ruleset::instance()->modifyRule(id, arg) == 0) {
                Info info;
                info->setTo(getId());
                info->setArgs1(arg);
                res.push_back(info);
            } else {
                error(op, "Updating type failed", res, getId());
            }
            return;
        }
        error(op, "Client attempting to use obsolete Set to install new type",
              res, getId());
        return;
    } else {
        error(op, "Unknow object type set", res, getId());
        return;
    }
}
Example #17
0
void VerticalLayout::CreateLayout(){
	Info f;
	f.FillInfoMap();
	std::map<int,double> mymap = f.GetMap();
	std::map<int,double>::iterator it;

	for (it=mymap.begin(); it!=mymap.end(); ++it)
	{
	  fVLayout->addLayout((new HorizontalLayout(QString::number(it->first),QString::number(it->second)))->GetLayout());
	}
}
Example #18
0
SourceFile::~SourceFile()
// ----------------------------------------------------------------------------
//   Delete info
// ----------------------------------------------------------------------------
{
    Info *next = NULL;
    for (Info *i = info; i; i = next)
    {
        next = i->next;
        i->Delete();
    }
}
Example #19
0
/// <summary>Entry point for the program.</summary>
int main(int argc, const char* argv[])
{
	// initialize WinRing0
	if (!InitializeOls() || GetDllStatus() != 0)
	{
		cerr << "ERROR: WinRing0 initialization failed" << endl;
		DeinitializeOls();

		return 1;
	}

	try
	{
		Info info;
		if (!info.Initialize())
		{
			cout << "ERROR: unsupported CPU" << endl;
			DeinitializeOls();
			WaitForKey();
			return 2;
		}

		if (argc > 1)
		{
			Worker worker(info);

			if (!worker.ParseParams(argc, argv))
			{
				DeinitializeOls();
				WaitForKey();
				return 3;
			}

			worker.ApplyChanges();
		}
		else
		{
			PrintInfo(info);
			WaitForKey();
		}
	}
	catch (const std::exception& e)
	{
		cerr << "ERROR: " << e.what() << endl;
		DeinitializeOls();
		WaitForKey();
		return 10;
	}

	DeinitializeOls();

	return 0;
}
void PackageMetadata::getData( const QString & packageName )
{
    Info packageInfo = ZyppInfo::queryMetadataForPackage( packageName.toStdString() );
    
    m_version = QString::fromStdString( packageInfo.version() );
    m_size = QString::fromStdString( packageInfo.installedSizeAsString() );
    
    // We use QMetaObject::invokeMethod to queue the call until the finished() signal is connected
    // by the parent object later on in the code. Please, don't replace it with a direct call to
    // sizeAndVersionObtained unless you really know what you're doing.
    QMetaObject::invokeMethod(this, "sizeAndVersionObtained", Qt::QueuedConnection);
}
Example #21
0
int* findRank(Info::const_iterator itInfo) {			// look for somebody's rank
    Info::const_iterator it;
    int* result = result1;
    for(int i=0; i<4; ++i) {
        int k = 1;
        for(it=info.begin(); it!=info.end(); it++) {
            //if(it == itInfo) continue;
            if((it->second)[i] >(itInfo->second)[i]) k++;
        }
        result[i] = k;
    }
    return result;
}
const EnvironmentGroup::Info EnvironmentGroup::chooseEnvironment (int familyId) const
{
	Info rfgi = getDefaultEnvironment ();

	//-- search for the shader in the family list
	int familyIndex = findFamilyIndex (familyId);
	if (familyIndex != -1)
		rfgi.setFamilyId(familyId);
	else
		//-- family id wasn't found, so log and return default shader
		DEBUG_REPORT_LOG_PRINT (true, ("EnvironmentGroup::chooseEnvironment - familyId %i not found, using default shader\n", familyId));

	return rfgi;
}
Example #23
0
File: tree.cpp Project: c3d/elfe
Tree::~Tree()
// ----------------------------------------------------------------------------
//   Delete the hash if we have one
// ----------------------------------------------------------------------------
{
    Info *next = NULL;
    assert (info != (Info *) 0xD00DEL && "Please report this in bug #922");
    for (Info *i = info; i; i = next)
    {
        ELFE_ASSERT(i->owner == this);
        next = i->next;
        i->Delete();
    }
}
Example #24
0
inline void add_incoming_and_outgoing_angles(Point const& map_point, Point const& intersection_point,
				Ring const& ring, 
                int turn_index,
                int operation_index,
                segment_identifier seg_id,
                Info& info)
{
    typedef typename boost::range_iterator
        <
            Ring const
        >::type iterator_type;

	int const n = boost::size(ring);
	if (seg_id.segment_index >= n || seg_id.segment_index < 0)
	{
		return;
	}

    segment_identifier real_seg_id = seg_id;
	iterator_type it = boost::begin(ring) + seg_id.segment_index;

    // TODO: if we use turn-info ("to", "middle"), we know if to advance without resorting to equals
    relaxed_less<Point> comparator;

    if (comparator.equals(intersection_point, *it))
    {
		// It should be equal only once. But otherwise we skip it (in "add")
		it = advance_circular(it, ring, seg_id, false);
    }

	info.add(map_point, *it, intersection_point, turn_index, operation_index, real_seg_id, true);

    if (comparator.equals(intersection_point, *it))
    {
		it = advance_circular(it, ring, real_seg_id);
	}
	else
	{
		// Don't upgrade the ID
		it = advance_circular(it, ring, seg_id);
	}
    for (int defensive_check = 0; 
		comparator.equals(intersection_point, *it) && defensive_check < n; 
		defensive_check++)
    {
		it = advance_circular(it, ring, real_seg_id);
    }

	info.add(map_point, *it, intersection_point, turn_index, operation_index, real_seg_id, false);
}
Example #25
0
    static bool ValidArgs(const Info& info, size_t rowBytes) {
        const int maxDimension = SK_MaxS32 >> 2;
        const size_t kMaxPixelByteSize = SK_MaxS32;

        if (info.width() <= 0 || info.height() <= 0) {
            return false;
        }
        if (info.width() > maxDimension || info.height() > maxDimension) {
            return false;
        }
        if ((unsigned)info.colorType() > (unsigned)kLastEnum_SkColorType) {
            return false;
        }
        if ((unsigned)info.alphaType() > (unsigned)kLastEnum_SkAlphaType) {
            return false;
        }

        if (kUnknown_SkColorType == info.colorType()) {
            return false;
        }

        // TODO: check colorspace

        if (rowBytes < SkImageMinRowBytes(info)) {
            return false;
        }

        int64_t size = (int64_t)info.height() * rowBytes;
        if (size > (int64_t)kMaxPixelByteSize) {
            return false;
        }
        return true;
    }
const EnvironmentGroup::Info EnvironmentGroup::chooseEnvironment (const PackedRgb& desiredColor) const
{
	Info rfgi = getDefaultEnvironment ();

	//-- search for the shader in the family list
	int familyIndex = findFamilyIndex (desiredColor);
	if (familyIndex != -1)
		rfgi.setFamilyId(familyList[familyIndex]->getFamilyId());
	else
		//-- family id wasn't found, so log and return default shader
		DEBUG_REPORT_LOG_PRINT (true, ("EnvironmentGroup::chooseEnvironment - family with color %i %i %i not found, using default shader\n", desiredColor.r, desiredColor.g, desiredColor.b));

	return rfgi;
}
Example #27
0
const RadialGroup::Info RadialGroup::chooseRadial (const PackedRgb& desiredColor) const
{
    Info rfgi = getDefaultRadial ();

    //-- search for the shader in the family list
    int familyIndex = findFamilyIndex (desiredColor);
    if (familyIndex != -1 && familyList [familyIndex]->getNumberOfChildren () > 0)
        rfgi.setFamilyId(familyList[familyIndex]->getFamilyId());
    else
        //-- family id wasn't found, so log and return default shader
        DEBUG_REPORT_LOG_PRINT (true, ("RadialGroup::chooseRadial - family with color %i %i %i not found, using default shader\n", desiredColor.r, desiredColor.g, desiredColor.b));

    return rfgi;
}
Example #28
0
bool HashTable::loadFromFile(std::string filename){
    clear();
    std::ifstream file;
    file.open(filename.c_str());
    bool res = true;
    Info *info;
    std::string line;
    while (res && std::getline(file,line)){
        info = new Info();
        res &= info->loadFromFile(line) && add(info) == NONE;
        if (!res) delete info;
    }
    file.close();
    return res;
}
Example #29
0
inline void add_incoming_and_outgoing_angles(
                RobustPoint const& intersection_point, // rescaled
                Turn const& turn,
                Pieces const& pieces, // using rescaled offsets of it
                int operation_index,
                segment_identifier seg_id,
                Info& info)
{
    segment_identifier real_seg_id = seg_id;
    geometry::equal_to<RobustPoint> comparator;

    // Move backward and forward
    RobustPoint direction_points[2];
    for (int i = 0; i < 2; i++)
    {
        int index = turn.operations[operation_index].index_in_robust_ring;
        int piece_index = turn.operations[operation_index].piece_index;
        while(comparator(pieces[piece_index].robust_ring[index], intersection_point))
        {
            move_index(pieces, index, piece_index, i == 0 ? -1 : 1);
        }
        direction_points[i] = pieces[piece_index].robust_ring[index];
    }

    info.add(direction_points[0], direction_points[1], intersection_point,
        turn.turn_index, operation_index, real_seg_id);
}
Example #30
0
std::string dotNETServiceGenerator::generateHStub(Interface & i, Info & info) {

	string tmp = TEMPLATE_STUB;
	replaceAll(tmp, "<stubname>", info.name);

	string stub_upper = info.name;
	std::transform(stub_upper.begin(), stub_upper.end(), stub_upper.begin(), ::toupper);
	replaceAll(tmp, "<STUBNAME>", stub_upper);
	replaceAll(tmp, "<includes>", "#include \"" + info.getInterfaceHeader() + "\"");


	//std::string fname = jsonp ? "Json" : "Jsonp";
	vector<string> fullnmspc = i.namesp;
	fullnmspc.push_back("DotNet");

	replaceAll(tmp, "<namespaceStart>", generateNamespaceStart(fullnmspc));
	replaceAll(tmp, "<namespaceEnd>", generateNamespaceEnd(fullnmspc));

	//generate procedures
	std::string clientStr;
	std::string privateClientStr;
	std::string serversStr;

	for (Class::List::iterator c = i.classes.begin(); c != i.classes.end(); c++) {
		clientStr.append(generateClientMethodSignature(*c) + ";" + "\n");
		privateClientStr.append(fullClassName(c->namesp, "I" + c->name) + "::Ptr " + variable(c->name) + ";" + "\n");
	}

	replaceAll(tmp, "<clients>", clientStr);
	replaceAll(tmp, "<private>", privateClientStr);
	return tmp;
}