bool operator() (const std::string& filename) {
        std::string ext = GetFileExtension(filename);
        if (stringcaseequal(ext, "exe"))
        {
            list.insert(filename);
        }
        if (stringcaseequal(ext, "bat"))
        {
            list.insert(filename);
        }

        return true;
    }
예제 #2
0
///////////////////
// Load the weapons restrictions list
void CWpnRest::loadList(const std::string& szFilename, const std::string& moddir)
{
    // Shutdown the list first
    Shutdown();

    std::string fn = szFilename;
    if(!strCaseStartsWith(fn, "cfg/")) {
        if(fn.size() > 4 && !stringcaseequal(fn.substr(fn.size()-4), ".wps"))
            fn += ".wps";
        if(moddir != "" && IsFileAvailable("cfg/presets/" + moddir + "/" + fn))
            fn = "cfg/presets/" + moddir + "/" + fn;
        else
            fn = "cfg/presets/" + fn;
    }

    FILE *fp = OpenGameFile(fn, "rt");
    if( !fp )
        return;

    std::string line;

    while( !feof(fp) && !ferror(fp) ) {
        line = ReadUntil(fp, '\n');
        std::vector<std::string> exploded = explode(line,",");
        if (exploded.size() >= 2)
            addWeapon(exploded[0],from_string<int>(exploded[1]));
    }

    fclose(fp);

    // Sort the list
    sortList();
}
예제 #3
0
///////////////////
// Apply the given tag
void CScrollbar::ApplyTag(xmlNodePtr node)
{
	CWidget::ApplyTag(node);

	iMin = MAX(0, xmlGetInt(node, "min"));
	iMax = MAX(iMin + 1, xmlGetInt(node, "max", iMin + 1));
	iValue = CLAMP(xmlGetInt(node, "value"), iMin, iMax);
	iItemsperbox = CLAMP(xmlGetInt(node, "itemsperbox"), 0, iMax);

	std::string base = xmlGetBaseURL(node);
	if (xmlPropExists(node, "topbtn"))
		bmpTop.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "topbtn"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "bottombtn"))
		bmpBottom.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "bottombtn"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "slidertop"))
		bmpSliderTop.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "slidertop"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "sliderbottom"))
		bmpSliderBottom.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "sliderbottom"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "slidermain"))
		bmpSliderMiddle.set(LoadGameImage(JoinPaths(base, xmlGetString(node, "slidermain"))), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "color"))
		iColor.set(xmlGetColour(node, "color", iColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "highcolor"))
		iHighlightColor.set(xmlGetColour(node, "highcolor", iHighlightColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "shadowcolor"))
		iShadowColor.set(xmlGetColour(node, "shadowcolor", iShadowColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "bgcolor"))
		iBackgroundColor.set(xmlGetColour(node, "bgcolor", iBackgroundColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "arrowcolor"))
		iArrowColor.set(xmlGetColour(node, "arrowcolor", iArrowColor), TAG_ATTR_PRIORITY);
	if (xmlPropExists(node, "dir"))  {
		std::string dir = xmlGetString(node, "dir", "vertical");
		if (stringcaseequal(dir, "vertical"))
			iDirection.set(scrVertical, TAG_ATTR_PRIORITY);
		else if (stringcaseequal(dir, "horizontal"))
			iDirection.set(scrHorizontal, TAG_ATTR_PRIORITY);
	}
}
    bool operator() (const std::string& filename) {
        std::string ext = GetFileExtension(filename);
        if (stringcaseequal(ext, "ck1") ||
                stringcaseequal(ext, "ck2") ||
                stringcaseequal(ext, "ck3") ||
                stringcaseequal(ext, "ck4") ||
                stringcaseequal(ext, "ck5") ||
                stringcaseequal(ext, "ck6") )
            list.insert(filename);

        return true;
    }
예제 #5
0
bool LevelInfo::operator==(const CustomVar& o) const {
	const LevelInfo* oi = dynamic_cast<const LevelInfo*> (&o);
	return oi && stringcaseequal(path, oi->path);
}
예제 #6
0
std::string ProcessSetVar(const std::vector<std::string>& params, int sender_id) {
	// Check the sender
	if (sender_id < 0 || sender_id >= MAX_WORMS)
		return "Invalid worm";
	
	// Param check
	if (params.size() < GetCommand(&ProcessSetVar)->iMinParamCount ||
		params.size() > GetCommand(&ProcessSetVar)->iMaxParamCount)
		return "Invalid parameter count";
	
	// Check privileges
	CWorm *w = &cServer->getWorms()[sender_id];
	CServerConnection *cl = w->getClient();
	if (!cl || !cl->getRights()->SetVar)
		return "You do not have sufficient privileges to set a variable";

	std::string var = params[0];
	TrimSpaces( var );
	RegisteredVar* varptr = CScriptableVars::GetVar(var);
	if( varptr == NULL )
		return "No variable with name " + var;
	if(varptr->var.type == SVT_CALLBACK)
		return "Callbacks are not allowed";
	
	if( varptr->var.ptr.s == &tLXOptions->sServerPassword ) {
		if(params.size() == 1) return "The password cannot be shown";
		if(!cl->getRights()->Dedicated)
			return "You can only set the password with Dedicated priviliges";
	}

	if(cServer->getState() != SVS_LOBBY && params.size() == 2) {
		if( varptr->var.ptr.s == &gameSettings[FT_Map].as<LevelInfo>()->path )
			return "You cannot change the map in game";

		if( varptr->var.ptr.s == &gameSettings[FT_Map].as<LevelInfo>()->name )
			return "You cannot change the map-name in game";

		if( varptr->var.ptr.s == &gameSettings[FT_Mod].as<ModInfo>()->path )
			return "You cannot change the mod in game";

		if( stringcaseequal(var, "GameOptions.GameInfo.GameType") )
			return "You cannot change the gametype in game";
	}
	
	if(!w->isUsed()) return "Invalid worm";
	if(!w->getClient()) return "Invalid worm with no client";

	if(params.size() == 1) {
		w->getClient()->getNetEngine()->SendText(var + " = " + varptr->var.toString(), TXT_PRIVATE);
		return "";
	}
	
	std::string value = params[1];
	TrimSpaces(value);
	StripQuotes(value);
	
	CScriptableVars::SetVarByString(varptr->var, value);
	
	w->getClient()->getNetEngine()->SendText(var + " = " + varptr->var.toString(), TXT_PRIVATE);
	notes << "ChatCommand: SetVar " << var << " = " << value << endl;
	
	cServer->UpdateGameLobby();
		
	return "";
}