Beispiel #1
0
entry loadEntry() {
    entry e = { NULL, -1, 0 };
    uint32_t length, offset[4];

    /* reset error container */
    errors.level = 0;

    offset[0] = CURR_OFFSET;
    if (!loadType(&e)) {
        return e;
    }

    offset[1] = CURR_OFFSET;
    if (e.type == REDIS_SELECTDB) {
        if ((length = loadLength(NULL)) == REDIS_RDB_LENERR) {
            SHIFT_ERROR(offset[1], 
                "Error reading database number");
            return e;
        }
        if (length > 63) {
            SHIFT_ERROR(offset[1], 
                "Database number out of range (%d)", length);
            return e;
        }
    } else if (e.type == REDIS_EOF) {
        if (positions[level].offset < positions[level].size) {
            SHIFT_ERROR(offset[0], 
                "Unexpected EOF");
        } else {
            e.success = 1;
        }
        return e;
    } else {
        /* optionally consume expire */
        if (e.type == REDIS_EXPIRETIME) {
            if (!processTime()) return e;
            if (!loadType(&e)) return e;
            db_stats.total_expires++;
        }

        offset[1] = CURR_OFFSET;
        if (!loadPair(&e)) {
            SHIFT_ERROR(offset[1], "Error for type %s", types[e.type]);
            return e;
        }
    }

    /* all entries are followed by a valid type:
     * e.g. a new entry, SELECTDB, EXPIRE, EOF */
    offset[2] = CURR_OFFSET;
    if (peekType() == -1) {
        SHIFT_ERROR(offset[2], "Followed by invalid type");
        SHIFT_ERROR(offset[0], "Error for type %s", types[e.type]);
        e.success = 0;
    } else {
        e.success = 1;
    }

    return e;
}
Beispiel #2
0
void Cell::loadCell (matvar_t *matVar, int i)
{
  loadType (matVar, i);
  loadLhs (matVar, i);
  loadDetwindow (matVar, i);
  loadI (matVar, i);
  loadOffset (matVar, i);

  // Type of structure 1 (last field called def)
  if ( matVar->dims[0] == 1 && matVar->dims[1] == 1 )
  {
    setFlagStr(STR_DEF);
    loadRhs (matVar, i);
    loadDef (matVar, i);
  }

  // Type of structure 2 (last field called anchor)
  else if ( vectorLength(matVar) > 1 )
  {
    setFlagStr(STR_ANCHOR);
    loadRhs (matVar, i, false);
    loadAnchor (matVar, i);
  }

  _IxDim = -1;
  _Ix = NULL;

  _IyDim = -1;
  _Iy = NULL;

  _scoreDim = -1;
  _score = NULL;
}
Beispiel #3
0
    void ClsTypeManager<T>::loadTypes(string _strDirectory)
    {
	list<string> listTypes = getListLibraries(_strDirectory);
	
	typename list<string>::iterator it;
	for (it = listTypes.begin(); it != listTypes.end(); ++it) {
	    string strFileName = it->data();
	    string strType = fileName2typeName(strFileName);
	    string strPath = getPathToFile(_strDirectory, 
					   strFileName);
	    try {
		string strLabel = loadType(strType, strPath);

		// Guard against duplicate label.
		typename TypeLabelMap::iterator entry;
		entry = mapLabelLookup.find(strLabel);
		if (entry != mapLabelLookup.end()) {
		    cerr << "WARNING: duplicate label "
			 << strLabel
			 << ", scanning for new label:"
			 << endl;
		    
		    int i = 1;
		    ostringstream tmp;
		    do {
			tmp.str("");
			++i;
			tmp << strLabel << " #" << i;
		    } while (mapLabelLookup.find(tmp.str()) 
			     != mapLabelLookup.end());
		    strLabel = tmp.str();
		}

		mapLabelLookup.insert(make_pair(strLabel, strType));
		listLabels.push_back(strLabel);
		
		if (bDebugTypeManager) {
		    cout << "Loaded " 
			 << strLabel
			 << ", stored as "
			 << strType
			 << endl;
		}
	    }
	    catch (iqrcommon::LoadTypeError &e) {
		cerr << getName()
		     << ": couldn't load "
		     << strFileName
		     << endl
		     << "    "
		     << e.what()
		     << endl;
	    }
	}

	// Sort the list of names alphabetically.
	listLabels.sort();
    }
GameScriptState::GameScriptState(Core::Engine& engine, std::string className):engine_(engine){
    bool c = loadType(className);
    if(!c) {
        xLOG[Util::LogType::ERROR]("ScriptState :: ctor") << "Couldn't load type for class: " << className << ". Wrong Name?" << "\0";
        throw Util::RunTimeError(xLOG.prev());
    }
    c = loadObject();
    if(!c) {
        xLOG[Util::LogType::ERROR]("ScriptState :: ctor") << "Couldn't load object for class: " << className << ". Wait how can this even happen... You done f****d it up!" << "\0";
        throw Util::RunTimeError(xLOG.prev());
    }
    extractVitalFunctions();
}
void EntityResourceManager::loadResource(const std::string filepath)
{
	//open up the file
	std::filebuf fb;
	fb.open(filepath, std::ios::in);

	//try to parse it
	Json::Value root;
	Json::Reader reader;
	bool parseSuccessful = reader.parse(std::istream(&fb), root);
	//now we have it parsed we can close it
	fb.close();

	if(!parseSuccessful)
	{
		std::cerr << "Unable to load entity: " << filepath << std::endl;
		std::cerr << reader.getFormattedErrorMessages() << std::endl;
		return;
	}

	Entity *entityPtr = loadType(root);
	if(entityPtr == NULL)
	{
		std::cerr << "Invalid type in entity file " << filepath << std::endl;
		return;
	}

	loadGenerics(*entityPtr, root);
	loadDamagingEntity(*entityPtr, root);
	loadCharacter(*entityPtr, root);

	std::string behaviour = root.get("behaviour", "").asString();
	if(!behaviour.empty())
	{
		loadBehaviour(*entityPtr, root);
	}

	Json::Value animations = root["animations"];
	if(animations.size() > 0)
	{
		loadAnimations(*entityPtr, root);
	}

	Json::Value abilities = root["abilities"];
	if(abilities.size() > 0)
	{
		loadAbilities(*entityPtr, root);
	}

	resourceMap[filepath] = entityPtr;
}
Beispiel #6
0
CArtifact * CArtHandler::loadFromJson(const JsonNode & node, const std::string & identifier)
{
	CArtifact * art;

	if (!VLC->modh->modules.COMMANDERS || node["growing"].isNull())
		art = new CArtifact();
	else
	{
		auto  growing = new CGrowingArtifact();
		loadGrowingArt(growing, node);
		art = growing;
	}
	art->identifier = identifier;
	const JsonNode & text = node["text"];
	art->name        = text["name"].String();
	art->description = text["description"].String();
	art->eventText   = text["event"].String();

	const JsonNode & graphics = node["graphics"];
	art->image = graphics["image"].String();

	if (!graphics["large"].isNull())
		art->large = graphics["large"].String();
	else
		art->large = art->image;

	art->advMapDef = graphics["map"].String();

	art->price = node["value"].Float();

	loadSlots(art, node);
	loadClass(art, node);
	loadType(art, node);
	loadComponents(art, node);

	for (auto b : node["bonuses"].Vector())
	{
		auto bonus = JsonUtils::parseBonus(b);
		art->addNewBonus(bonus);
	}
	return art;
}
ScriptComponent::ScriptComponent(Core::Engine &engine, ECS::Entity &parent, std::string className):Component(engine,parent), scObj_(nullptr),
								ctx_(nullptr),scType_(nullptr){
    std::string moduleName = className + ".as";
	bool c = loadScript(moduleName);
	if(!c) {
		xLOG[Util::LogType::ERROR]("ScriptComponent :: ctor") << "Unable to load Scipt " << moduleName << ". Invalid Path?" << "\0";
		throw Util::RunTimeError(xLOG.prev());
	}
	registerModule(moduleName);
	c = loadType(className);
	if(!c) {
		xLOG[Util::LogType::ERROR]("ScriptComponent :: ctor") << "Couldn't load type for class: " << className << ". Wrong Name?" << "\0";
		throw Util::RunTimeError(xLOG.prev());
	}
	c = loadObject();
	if(!c) {
		xLOG[Util::LogType::ERROR]("ScriptComponent :: ctor") << "Couldn't load object for class: " << className << ". Wait how can this even happen... You done f****d it up!" << "\0";
		throw Util::RunTimeError(xLOG.prev());
	}
	extractVitalFunctions();

	engine_.scriptEngine().registerScriptComponent(this);
}