Exemplo n.º 1
0
// return a list of dependencies with name:version string for missing/different version mods.
LinkedList<CharString> APIMod::getMissingDependencies(LinkedList<APIMod*> othermods){
    LinkedList<CharString> strs;
    LinkedListIterator<CharString> depstrs = dependencyversions.getIterator();
    
    while(depstrs.hasNext()){
        CharString depstr = depstrs.next();
        if(depstr.contains(":")){
            LinkedListIterator<APIMod*> modit = othermods.getIterator();
            bool identified = false;
            while(modit.hasNext()){
                APIMod *mod = modit.next();
                // compare direct
                if(unixname.compare(mod->unixname) && version.compareVersion(mod->versionstr)){
                    // not the same or and older version
                    identified = true; // same
                    break;
                }
            }
            
            if(!identified){
                strs.add(depstr); // "mod:version"
            }
            
        } // else invalid!
    }
    
    return strs;
}
Exemplo n.º 2
0
MSGClient* MSGServer::getMSGClient(SockClient* cli){
    MSGClient* client = 0x0;
    
    LinkedList<MSGClient*> activeClients;
    
    refreshClients();
    
    // loop through clients
    LinkedListIterator<MSGClient*> msgcit = cclients.getIterator();
    while(msgcit.hasNext()){
        MSGClient* c = msgcit.next();
        if(c->hasBroadcastClient(cli)) // has a serverclient socket?
            client = c;
    }
    
    // found client? If not, add to list if it's alive.
    if(client == 0x0 && cli != 0x0){
        if(cli->alive){
            client = new MSGClient(cli);
            activeClients.add(client);
        }
    }
    
    cclients.clear(); // clear old one
    cclients = activeClients;
    
    return client;
}
Exemplo n.º 3
0
// figure out what mods have good dependencies
bool APIMod::compareModDependencies(LinkedList<APIMod*> othermods){
    LinkedListIterator<CharString> depstrs = dependencyversions.getIterator();
    
    while(depstrs.hasNext()){
        CharString depstr = depstrs.next();
        if(depstr.contains(":")){
            LinkedListIterator<APIMod*> modit = othermods.getIterator();
            while(modit.hasNext()){
                APIMod *mod = modit.next();
                // compare direct
                if(! version.compareVersion(mod->version)){
                    // not the same or and older version
                    return false;
                }
            }
            
        } // else invalid!
    }
}
Exemplo n.º 4
0
// get channel
MSGClientChannel* MSGServer::getMSGChannel(CharString channelname){
    // loop through channels
    LinkedListIterator<MSGClientChannel*> msgcit = channels.getIterator();
    while(msgcit.hasNext()){
        MSGClientChannel* channel = msgcit.next();
        if(channel->channelname.compare(channelname)){
            return channel;
        }
    }
    
    // no channel by that name
    return 0x0;
}
Exemplo n.º 5
0
// only in-between broadcast servers
void MSGServer::shareClientIPID(MSGClient* client){
    LinkedListIterator<MSGClient*> bit = bservers.getIterator();
    SockClient* sc = client->getFirstBroadcastServer();
    CharString msgpack = "newid:";
    msgpack += sc->getAddr();
    msgpack += ":";
    msgpack += client->identity;
    
    while(bit.hasNext()){
        MSGClient* bserver = bit.next();
        if(!bserver->isbserver) continue;
        
        SockClient* bsc = bserver->getFirstBroadcastServer();
        if(bsc != 0x0){
            bsc->sendc(msgpack);
        }
    }
}
Exemplo n.º 6
0
MSGClient* MSGServer::getMSGClient(CharString identity){ // get from id
    refreshClients();
    
    // loop through clients
    LinkedListIterator<MSGClient*> msgcit = cclients.getIterator();
    while(msgcit.hasNext()){
        MSGClient* c = msgcit.next();
        
        // is an actual client?
        if(c != 0x0){
            if(c->identity.compare(identity)){
                return c;
            }
        }
    }
    
    // none!
    return 0x0;
}
Exemplo n.º 7
0
void MSGServer::refreshClients(){
    MSGClient* client = 0x0;
    
    LinkedList<MSGClient*> activeClients;
    
    // loop through clients
    LinkedListIterator<MSGClient*> msgcit = cclients.getIterator();
    while(msgcit.hasNext()){
        MSGClient* c = msgcit.next();
        
        // is an actual client?
        if(c != 0x0){
            if(c->checkBroadcastAlive()){ // quick check
                activeClients.add(c);
            }
        }
    }
    
    cclients.clear(); // clear old one
    cclients = activeClients;
}
Exemplo n.º 8
0
// LinkedList<LinkedList<CharString>> lines = SimpleParseFile(file, '\n');
void APIMod::loadProperties(){ // , CharString name, CharString language, CharString version
    if(propertiesloaded) return;

    LinkedList<LinkedList<CharString>> lines = SimpleParseString(getModFileData("mod.properties"), '=');

    CharString depvers = "";
    LinkedListIterator<LinkedList<CharString>> lineit = lines.getIterator();
    while(lineit.hasNext()){
        LinkedList<CharString> p = lineit.next();
        CharString pname = p[0];
        if(pname.compare(CharString("name")))
            this->name = p[1];
        else if(pname.compare(CharString("unixname")))
            this->unixname = p[1];
        else if(pname.compare(CharString("language"))) // c++, java, etc.
            this->language = p[1];
        else if(pname.compare(CharString("version"))){
            this->versionstr = p[1];
            this->version = APIModVersion(p[1]);
        }else if(pname.compare(CharString("dependency_versions")))
            depvers = p[1];
    }

    this->modcwdloc = unixname; // relative folder location for mod
    
    // load dependency versioning information
    //      this->dependencyversions.add("mod1:v12938");
    if(depvers.getSize() > 3){
        if(depvers.contains(", ")){
            depvers.replace(" ", "");
            LinkedList<CharString> v = depvers.split(",");
            this->dependencyversions.addAll(v);
        }else{
            this->dependencyversions.add(depvers);
        }
    }


    propertiesloaded=true;
}
Exemplo n.º 9
0
 // add items from another list
 void addAll(LinkedList<T> cc) {
     LinkedListIterator<T> it = cc.getIterator();
     while(it.hasNext())
         add(it.next());
 }