void run_scp_program(sc_memory_context *context, scp_operand *scp_program)
{
    scp_operand arc1, arc2, quest, params;
    MAKE_DEFAULT_ARC_ASSIGN(arc1);
    MAKE_DEFAULT_ARC_ASSIGN(arc2);
    MAKE_DEFAULT_NODE_ASSIGN(quest);
    scp_program->param_type = SCP_FIXED;
    genElStr5(context, &quest, &arc1, scp_program, &arc2, ordinal_rrels + 1);
    quest.param_type = SCP_FIXED;
    MAKE_DEFAULT_NODE_ASSIGN(params);
    genElStr5(context, &quest, &arc1, &params, &arc2, ordinal_rrels + 2);
    set_author(context, &quest, &abstract_scp_machine);
    genElStr3(context, &question_scp_interpretation_request, &arc1, &quest);
    genElStr3(context, &question_initiated, &arc1, &quest);
}
Exemple #2
0
DictInfo& DictInfo::operator=(const DictInfo& dict_info)
{
	clear();
	ifo_file_name = dict_info.ifo_file_name;

	if(dict_info.is_wordcount())
		set_wordcount(dict_info.get_wordcount());
	if(dict_info.is_filecount())
		set_filecount(dict_info.get_filecount());
	if(dict_info.is_synwordcount())
		set_synwordcount(dict_info.get_synwordcount());
	if(dict_info.is_bookname())
		set_bookname(dict_info.get_bookname());
	if(dict_info.is_author())
		set_author(dict_info.get_author());
	if(dict_info.is_email())
		set_email(dict_info.get_email());
	if(dict_info.is_website())
		set_website(dict_info.get_website());
	if(dict_info.is_date())
		set_date(dict_info.get_date());
	if(dict_info.is_description())
		set_description(dict_info.get_description());
	if(dict_info.is_index_file_size())
		set_index_file_size(dict_info.get_index_file_size());
	if(dict_info.is_sametypesequence())
		set_sametypesequence(dict_info.get_sametypesequence());
	if(dict_info.is_dicttype())
		set_dicttype(dict_info.get_dicttype());
	if(dict_info.is_version())
		set_version(dict_info.get_version());
	if(dict_info.is_infotype())
		set_infotype(dict_info.get_infotype());

	f_idxoffsetbits = dict_info.f_idxoffsetbits;
	return *this;
}
void ProjectManager::load_new_game()
{
    _init_resources();
    
    debug("loading the debug map\n");
    import(Action, am);
    import(Branch, bm);
    import(Event, em);
    import(Image, im);
    import(Position, pm);
    import(Sound, sm);
    import(Text, tm);
    import(Variable, vm);

    {
        Image* new_elem(new Image());

        new_elem->res_data.size = 775;
        im[0] = new_elem;
    }

    {
        Image* new_elem(new Image());

        new_elem->res_data.size = 871;
        im[1] = new_elem;
    }

    set_name("debug game project");
    set_author("benoit guina");
    m_meta.player.x = 0;
    m_meta.player.y = 0;
    m_meta.player.image.id = 1;
    m_meta.player.image.at_x = 0;
    m_meta.player.image.at_y = 0;

    int map_height((int)ProjectManagerBase::map_height);
    int map_width((int)ProjectManagerBase::map_width);
    //int map_height(1);
    //int map_width(1);
    for (int y = 0; y < map_height; ++y)
    {
        for (int x = 0; x < map_width; ++x)
        {
            Position* new_elem(new Position());

            new_elem->res_data.x = x;
            new_elem->res_data.y = y;
            //new_elem->res_data.id_event = 0;
            new_elem->res_data.id_event = -1;
            new_elem->res_data.id_image = 0;
            new_elem->res_data.image_tile_at[0] = 0;
            new_elem->res_data.image_tile_at[1] = 0;
            pm[y * ProjectManagerBase::map_width + x] = new_elem;
        }
    }

    {
        //Event* e = new Event;
        //em[0] = new ;
    }

    debug("debug map created\n");

    load();
}
Exemple #4
0
void
f_set_author (void)
{
    set_author(sp->u.string);
    free_string_svalue(sp--);
}
Exemple #5
0
bool DictInfo::load_from_ifo_file(const std::string& ifofilename,
	DictInfoType infotype)
{
	clear();
	ifo_file_name=ifofilename;
	set_infotype(infotype);
	glib::CharStr buffer;
	glib::Error error;
	if (!g_file_get_contents(ifo_file_name.c_str(), get_addr(buffer), NULL, get_addr(error))) {
		g_critical("Load %s failed. Error: %s.", ifo_file_name.c_str(), error->message);
		return false;
	}
	const gchar *p1 = get_impl(buffer);
	
	if(g_str_has_prefix(p1, UTF8_BOM))
		p1 += 3;
	if(!g_utf8_validate(p1, -1, NULL)) {
		g_critical("Load %s failed: Invalid UTF-8 encoded text.", ifo_file_name.c_str());
		return false;
	}
	lineno = 1;

	const gchar *magic_data = NULL;
	if(infotype == DictInfoType_NormDict)
		magic_data = NORM_DICT_MAGIC_DATA;
	else if(infotype == DictInfoType_TreeDict)
		magic_data = TREE_DICT_MAGIC_DATA;
	else if(infotype == DictInfoType_ResDb)
		magic_data = RES_DB_MAGIC_DATA;
	else
		return false;
	if (!g_str_has_prefix(p1, magic_data)) {
		g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str());
		if(g_str_has_prefix(p1, NORM_DICT_MAGIC_DATA))
			g_message("File '%s' is an index-based dictionary.", ifo_file_name.c_str());
		else if(g_str_has_prefix(p1, TREE_DICT_MAGIC_DATA))
			g_message("File '%s' is a tree dictionary.", ifo_file_name.c_str());
		else if(g_str_has_prefix(p1, RES_DB_MAGIC_DATA))
			g_message("File '%s' is a resource database.", ifo_file_name.c_str());
		else
			g_message("File '%s' is not a StarDict dictionary or it's broken.", ifo_file_name.c_str());
		return false;
	}
	p1 += strlen(magic_data);
	p1 = skip_new_line(p1);
	if(!p1) {
		g_critical("Load %s failed: Incorrect magic data.", ifo_file_name.c_str());
		return false;
	}

	std::string key, value;
	while(true) {
		++lineno;
		p1 = get_key_value(p1, key, value);
		if(!p1)
			break;

		// version must the first option
		if(!is_version()) {
			if(key != "version") {
				g_critical("Load %s failed: \"version\" must be the first option.", ifo_file_name.c_str());
				return false;
			}
		}
		if(key == "version") {
			if(!check_option_duplicate(f_version, "version"))
				continue;
			set_version(value);
			if(infotype == DictInfoType_NormDict) {
				if(version != "2.4.2" && version != "3.0.0") {
					g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str());
					return false;
				}
			} else if(infotype == DictInfoType_TreeDict) {
				if(version != "2.4.2") {
					g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str());
					return false;
				}
			} else if(infotype == DictInfoType_ResDb) {
				if(version != "3.0.0") {
					g_critical("Load %s failed: Unknown version.", ifo_file_name.c_str());
					return false;
				}
			}
		} else if(key == "idxoffsetbits") {
			if(!check_option_duplicate(f_idxoffsetbits, "idxoffsetbits"))
				continue;
			if(value != "32") {
				// TODO
				g_critical("Load %s failed: idxoffsetbits != 32 not supported presently.",
					ifo_file_name.c_str());
				return false;
			}
		} else if(key == "wordcount" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_wordcount, "wordcount"))
				continue;
			set_wordcount(atol(value.c_str()));
		} else if(key == "filecount" && infotype == DictInfoType_ResDb) {
			if(!check_option_duplicate(f_filecount, "filecount"))
				continue;
			set_filecount(atol(value.c_str()));
		} else if(key == "synwordcount" && infotype == DictInfoType_NormDict) {
			if(!check_option_duplicate(f_synwordcount, "synwordcount"))
				continue;
			set_synwordcount(atol(value.c_str()));
		} else if(key == "tdxfilesize" && infotype == DictInfoType_TreeDict) {
			if(!check_option_duplicate(f_index_file_size, "tdxfilesize"))
				continue;
			set_index_file_size(atol(value.c_str()));
		} else if(key == "idxfilesize" && infotype == DictInfoType_NormDict) {
			if(!check_option_duplicate(f_index_file_size, "idxfilesize"))
				continue;
			set_index_file_size(atol(value.c_str()));
		} else if(key == "ridxfilesize" && infotype == DictInfoType_ResDb) {
			if(!check_option_duplicate(f_index_file_size, "ridxfilesize"))
				continue;
			set_index_file_size(atol(value.c_str()));
		} else if(key == "dicttype" && infotype == DictInfoType_NormDict) {
			if(!check_option_duplicate(f_dicttype, "dicttype"))
				continue;
			set_dicttype(value);
		} else if(key == "bookname" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_bookname, "bookname"))
				continue;
			set_bookname(value);
		} else if(key == "author" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_author, "author"))
				continue;
			set_author(value);
		} else if(key == "email" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_email, "email"))
				continue;
			set_email(value);
		} else if(key == "website" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_website, "website"))
				continue;
			set_website(value);
		} else if(key == "date" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_date, "date"))
				continue;
			set_date(value);
		} else if(key == "description" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_description, "description"))
				continue;
			std::string temp;
			decode_description(value.c_str(), value.length(), temp);
			set_description(temp);
		} else if(key == "sametypesequence" && (infotype == DictInfoType_NormDict
			|| infotype == DictInfoType_TreeDict)) {
			if(!check_option_duplicate(f_sametypesequence, "sametypesequence"))
				continue;
			set_sametypesequence(value);
		} else {
			g_message("Load %s warning: unknown option %s.", ifo_file_name.c_str(),
				key.c_str());
		}
	}

	// check required options
	if((!is_wordcount() || wordcount == 0) && ((infotype == DictInfoType_NormDict
		|| infotype == DictInfoType_TreeDict))) {
		g_critical("Load %s failed: wordcount not specified or 0.",
			ifo_file_name.c_str());
		return false;
	}
	if((!is_filecount() || filecount == 0) && infotype == DictInfoType_ResDb) {
		g_critical("Load %s failed: filecount not specified or 0.",
			ifo_file_name.c_str());
		return false;
	}
	if((!is_bookname() || bookname.empty()) && (infotype == DictInfoType_NormDict
		|| infotype == DictInfoType_TreeDict)) {
		g_critical("Load %s failed: bookname not specified.",
			ifo_file_name.c_str());
		return false;
	}
	if(!is_index_file_size() || index_file_size == 0) {
		const char* kkey;
		if(infotype == DictInfoType_NormDict)
			kkey = "idxfilesize";
		else if(infotype == DictInfoType_TreeDict)
			kkey = "tdxfilesize";
		else if(infotype == DictInfoType_ResDb)
			kkey = "ridxfilesize";
		else
			kkey = "";
		g_critical("Load %s failed: %s not specified or 0.",
			ifo_file_name.c_str(), kkey);
		return false;
	}

	return true;
}