Example #1
0
void renderscores()
{
    if(!scoreson) return;
    scorelines.setsize(0);
    if(!demoplayback) renderscore(player1);
    loopv(players) if(players[i]) renderscore(players[i]);
    
    // Added by Rick: Render Score for bots
    loopv(bots) if(bots[i]) renderscore(bots[i]);
    
    sortmenu(0, scorelines.length());
    if(m_teammode)
    {
        teamsused = 0;
        loopv(players) addteamscore(players[i]);
	
	// Added by Rick: Add team scores for bots
	loopv(bots) addteamscore(bots[i]);
	
        if(!demoplayback) addteamscore(player1);
        teamscores[0] = 0;
        loopj(teamsused)
        {
            sprintf_sd(sc)("[ %s: %d ]", teamname[j], teamscore[j]);
            strcat_s(teamscores, sc);
        };
        menumanual(0, scorelines.length(), "");
        menumanual(0, scorelines.length()+1, teamscores);
    };
};
Example #2
0
int finddynlights()
{
    closedynlights.setsize(0);
    if(!maxdynlights) return 0;
    physent e;
    e.type = ENT_CAMERA;
    loopvj(dynlights)
    {
        dynlight &d = dynlights[j];
        if(d.curradius <= 0) continue;
        d.dist = camera1->o.dist(d.o) - d.curradius;
        if(d.dist > dynlightdist || isfoggedsphere(d.curradius, d.o) || pvsoccludedsphere(d.o, d.curradius))
            continue;
        if(reflecting || refracting > 0)
        {
            if(d.o.z + d.curradius < reflectz) continue;
        }
        else if(refracting < 0 && d.o.z - d.curradius > reflectz) continue;
        e.o = d.o;
        e.radius = e.xradius = e.yradius = e.eyeheight = e.aboveeye = d.curradius;
        if(!collide(&e, vec(0, 0, 0), 0, false)) continue;

        int insert = 0;
        loopvrev(closedynlights) if(d.dist >= closedynlights[i]->dist) { insert = i+1; break; }
        closedynlights.insert(insert, &d);
        if(closedynlights.length() >= DYNLIGHTMASK) break;
    }
    return closedynlights.length();
}
Example #3
0
float vector::GetAngleBetween (vector vec1, vector vec2) 
{

   float mag1 = vec1.length();
   float mag2 = vec2.length();
   float dotproduct = DotProduct(vec1, vec2);

   return (float) (acos (dotproduct/(mag1 * mag2)));
}
Example #4
0
void menuprocess()
{
    int level = guistack.length();
    loopv(executelater) execute(executelater[i]);
    executelater.deletecontentsa();
    if(clearlater)
    {
        if(level==guistack.length()) guistack.deletecontentsa();
        clearlater = false;
    };
};
Example #5
0
 int addvert(const vertex &v)
 {
     uint h = hthash(v.pos)&(SIZE-1);
     for(int i = table[h]; i>=0; i = chain[i])
     {
         const vertex &c = verts[i];
         if(c.pos==v.pos && c.tc==v.tc && c.norm==v.norm && c.tangent==v.tangent && c.bitangent==v.bitangent)
              return i;
     }
     if(verts.length() >= USHRT_MAX) return -1;
     verts.add(v);
     chain.add(table[h]);
     return table[h] = verts.length()-1;
 }
Example #6
0
void renderscore(dynent *d)
{
    sprintf_sd(lag)("%d", d->plag);
    sprintf_sd(name) ("(%s)", d->name); 
    sprintf_s(scorelines.add().s)("%d\t%s\t%d\t%s\t%s", d->frags, d->state==CS_LAGGED ? "LAG" : lag, d->ping, d->team, d->state==CS_DEAD ? name : d->name);
    menumanual(0, scorelines.length()-1, scorelines.last().s); 
};
Example #7
0
void listfiles(const char *dir, const char *ext, vector<char *> &files, int (__cdecl *sf)(const char **, const char **))
{
    listdir(dir, ext, files);
    string s;
    if(homedir[0])
    {
        formatstring(s)("%s%s", homedir, dir);
        listdir(s, ext, files);
    }
    loopv(packagedirs)
    {
        formatstring(s)("%s%s", packagedirs[i], dir);
        listdir(s, ext, files);
    }
#ifndef STANDALONE
    listzipfiles(dir, ext, files);
#endif
    if(sf)
    { // sort and remove doubles
        files.sort(sf);
        for(int i = files.length() - 1; i > 0; i--)
        {
            if(!strcmp(files[i], files[i - 1])) delstring(files.remove(i));
        }
    }
}
Example #8
0
 static int groupplayers()
 {
     int numgroups = 0;
     spectators.shrink(0);
     loopv(players)
     {
         fpsent *o = players[i];
         if(!showconnecting && !o->name[0]) continue;
         if(o->state==CS_SPECTATOR) { spectators.add(o); continue; }
         const char *team = m_teammode && o->team[0] ? o->team : NULL;
         bool found = false;
         loopj(numgroups)
         {
             scoregroup &g = *groups[j];
             if(team!=g.team && (!team || !g.team || strcmp(team, g.team))) continue;
             if(team && (!cmode || !cmode->hidefrags())) g.score += o->frags;
             g.players.add(o);
             found = true;
         }
         if(found) continue;
         if(numgroups>=groups.length()) groups.add(new scoregroup);
         scoregroup &g = *groups[numgroups++];
         g.team = team;
         if(!team) g.score = 0;
         else if(cmode && cmode->hidefrags()) g.score = cmode->getteamscore(o->team);
         else g.score = o->frags;
         g.players.shrink(0);
         g.players.add(o);
     }
     loopi(numgroups) groups[i]->players.sort(playersort);
     spectators.sort(playersort);
     groups.sort(scoregroupcmp, 0, numgroups);
     return numgroups;
 }
Example #9
0
uint32_t get_next_shared_ptr_id() {
    shared_ptr_list_lock.lock();
    shared_ptr_is_alive.add(true);
    uint32_t ret = shared_ptr_is_alive.length() - 1;
    shared_ptr_list_lock.unlock();
    return ret;
}
Example #10
0
client &addclient(int type)
{
    client *c = NULL;
    loopv(clients) if(clients[i]->type==ST_EMPTY)
    {
        c = clients[i];
        break;
    }
    if(!c)
    {
        c = new client;
        c->num = clients.length();
        clients.add(c);
    }
    c->info = server::newclientinfo();
    c->type = type;
    switch(type)
    {
    case ST_TCPIP:
        nonlocalclients++;
        break;
    case ST_LOCAL:
        localclients++;
        break;
    }
    return *c;
}
vector unit_vector(const vector& v) {
	if (v.x == 0 && v.y == 0)
		return v;

	auto length = v.length();

	return{ v.x / length, v.y / length };
}
Example #12
0
int cleargui(int n = 0)
{
    int clear = guistack.length();
    if(n>0) clear = min(clear, n);
    loopi(clear) delete[] guistack.pop();
    if(!guistack.empty()) showgui(guistack.last());
    return clear;
};
Example #13
0
static int addnormal(const vec &key, const vec &surface)
{
    normalgroup &g = normalgroups.access(key, key);
    normal &n = normals.add();
    n.next = g.normals;
    n.surface = surface;
    return g.normals = normals.length()-1;
}
Example #14
0
static void addnormal(const vec &key, const vec &surface)
{
    nval &val = normalgroups[key];
    normal &n = normals.add();
    n.next = val.normals;
    n.surface = surface;
    val.normals = normals.length()-1;
}
Example #15
0
static int addnormal(const vec &pos, int smooth, const vec &surface)
{
    normalkey key = { pos, smooth };
    normalgroup &g = normalgroups.access(key, key);
    normal &n = normals.add();
    n.next = g.normals;
    n.surface = surface;
    return g.normals = normals.length()-1;
}
Example #16
0
static bool readzipdirectory(const char *archname, FILE *f, int entries, int offset, uint size, vector<zipfile> &files)
{
    uchar *buf = new uchar[size], *src = buf;
    if(fseek(f, offset, SEEK_SET) < 0 || fread(buf, 1, size, f) != size) { delete[] buf; return false; }
    loopi(entries)
    {
        if(src + ZIP_FILE_SIZE > &buf[size]) break;

        zipfileheader hdr;
        hdr.signature = lilswap(*(uint *)src); src += 4;
        hdr.version = lilswap(*(ushort *)src); src += 2;
        hdr.needversion = lilswap(*(ushort *)src); src += 2;
        hdr.flags = lilswap(*(ushort *)src); src += 2;
        hdr.compression = lilswap(*(ushort *)src); src += 2;
        hdr.modtime = lilswap(*(ushort *)src); src += 2;
        hdr.moddate = lilswap(*(ushort *)src); src += 2;
        hdr.crc32 = lilswap(*(uint *)src); src += 4;
        hdr.compressedsize = lilswap(*(uint *)src); src += 4;
        hdr.uncompressedsize = lilswap(*(uint *)src); src += 4;
        hdr.namelength = lilswap(*(ushort *)src); src += 2;
        hdr.extralength = lilswap(*(ushort *)src); src += 2;
        hdr.commentlength = lilswap(*(ushort *)src); src += 2;
        hdr.disknumber = lilswap(*(ushort *)src); src += 2;
        hdr.internalattribs = lilswap(*(ushort *)src); src += 2;
        hdr.externalattribs = lilswap(*(uint *)src); src += 4;
        hdr.offset = lilswap(*(uint *)src); src += 4;
        if(hdr.signature != ZIP_FILE_SIGNATURE) break;
        if(!hdr.namelength || !hdr.uncompressedsize || (hdr.compression && (hdr.compression != Z_DEFLATED || !hdr.compressedsize)))
        {
            src += hdr.namelength + hdr.extralength + hdr.commentlength;
            continue;
        }
        if(src + hdr.namelength > &buf[size]) break;

        string pname;
        int namelen = min((int)hdr.namelength, (int)sizeof(pname)-1);
        memcpy(pname, src, namelen);
        pname[namelen] = '\0';
        path(pname);
        char *name = newstring(pname);

        zipfile &f = files.add();
        f.name = name;
        f.header = hdr.offset;
        f.size = hdr.uncompressedsize;
        f.compressedsize = hdr.compression ? hdr.compressedsize : 0;
#ifndef STANDALONE
        if(dbgzip) conoutf(CON_DEBUG, "%s: file %s, size %d, compress %d, flags %x", archname, name, hdr.uncompressedsize, hdr.compression, hdr.flags);
#endif

        src += hdr.namelength + hdr.extralength + hdr.commentlength;
    }
    delete[] buf;

    return files.length() > 0;
}
Example #17
0
File: 1.cpp Project: saching1307/C-
class argument{
	public:
	int i;
}


void L1(vector<argument> P12){
	int sum = 0;
	for (int k = 0; k < P12.length(); k++) {
		sum += P12[k].i;
	}
}
Example #18
0
static void addtnormal(const vec &key, float offset, int normal1, int normal2, normalgroup *group1, normalgroup *group2)
{
    normalgroup &g = normalgroups.access(key, key);
    tnormal &n = tnormals.add();
    n.next = g.tnormals;
    n.offset = offset;
    n.normals[0] = normal1;
    n.normals[1] = normal2;
    n.groups[0] = group1;
    n.groups[1] = group2;
    g.tnormals = tnormals.length()-1;
}
Example #19
0
 void unite (int x, int y)
 {
     while(ufvals.length() <= max(x, y)) ufvals.add();
     x = compressfind(x);
     y = compressfind(y);
     if(x==y) return;
     ufval &xval = ufvals[x], &yval = ufvals[y];
     if(xval.rank < yval.rank) xval.next = y;
     else
     {
         yval.next = x;
         if(xval.rank==yval.rank) yval.rank++;
     }
 }
Example #20
0
static void addtnormal(const vec &pos, int smooth, float offset, int normal1, int normal2, const vec &pos1, const vec &pos2)
{
    normalkey key = { pos, smooth };
    normalgroup &g = normalgroups.access(key, key);
    tnormal &n = tnormals.add();
    n.next = g.tnormals;
    n.offset = offset;
    n.normals[0] = normal1;
    n.normals[1] = normal2;
    normalkey key1 = { pos1, smooth }, key2 = { pos2, smooth };
    n.groups[0] = normalgroups.access(key1);
    n.groups[1] = normalgroups.access(key2);
    g.tnormals = tnormals.length()-1;
}
Example #21
0
int main()
{
	string s, buf;
	int i;
	int k;
	for (k = 0; k < 9; k++){

		cin >> s;

		cout << s.length() << "\n";
		for (i = 0; i < s.length(); i++)
		{
			if (isalpha(s[i]))
				s[i] = tolower(s[i]);
			else
				s[i] = ' ';

		}

		stringstream ss(s);
		while (ss >> buf)
			dict.insert(buf);
		//cout << buf << "\n";
	}
	
 	set<string>::iterator it;
	int m = 0;
	for (it = dict.begin(); it != dict.end(); it++){
		cout << *it << "\n";
		//m++;
		//cout << m << "\n";
	}
	//cout << *(++dict.begin()) << "\n";
		//cout << s.length() << endl;
	return 0;
}
Example #22
0
soundchannel &newchannel(int n, soundsample *sample, int volume, const vec *loc = NULL, extentity *ent = NULL, int flags = 0, int radius = 0)
{
    if(ent) ent->flags |= EF_SOUND;
    while(!channels.inrange(n)) channels.add(channels.length());
    soundchannel &chan = channels[n];
    chan.reset();
    chan.inuse = true;
    if(loc) chan.loc = *loc;
    chan.sample = sample;
    chan.ent = ent;
    chan.svolume = volume;
    chan.flags = 0;
    chan.radius = radius;
    return chan;
}
Example #23
0
soundchannel &newchannel(int n, soundslot *slot, const vec *loc = NULL, extentity *ent = NULL, int radius = 0)
{
    if(ent)
    {
        loc = &ent->o;
        ent->visible = true;
    }
    while(!channels.inrange(n)) channels.add(channels.length());
    soundchannel &chan = channels[n];
    chan.reset();
    chan.inuse = true;
    if(loc) chan.loc = *loc;
    chan.slot = slot;
    chan.ent = ent;
    chan.radius = radius;
    return chan;
}
Example #24
0
void showgui(char *name)
{
    int pos = guistack.find(name);
    if(pos<0)
    {
        if(!guis.access(name)) return;
        if(guistack.empty()) menupos = menuinfrontofplayer();
        guistack.add(newstring(name));
    }
    else
    {
        pos = guistack.length()-pos-1;
        loopi(pos) delete[] guistack.pop();
    };
    menutab = 1;
    menustart = lastmillis;
};
Example #25
0
void listsubdirs(const char *dir, vector<char *> &subdirs, int (__cdecl *sf)(const char **, const char **))
{
    listsubdir(dir, subdirs);
    string s;
    if(homedir[0])
    {
        formatstring(s)("%s%s", homedir, dir);
        listsubdir(s, subdirs);
    }
    loopv(packagedirs)
    {
        formatstring(s)("%s%s", packagedirs[i], dir);
        listsubdir(s, subdirs);
    }
#ifndef STANDALONE
    listzipdirs(dir, subdirs);
#endif
    subdirs.sort(sf);
    for(int i = subdirs.length() - 1; i > 0; i--)
    { // remove doubles
        if(!strcmp(subdirs[i], subdirs[i - 1])) delstring(subdirs.remove(i));
    }
}
Example #26
0
int finddynlights()
{
    closedynlights.setsize(0);
    if(!usedynlights) return 0;
    physent e;
    e.type = ENT_CAMERA;
    e.collidetype = COLLIDE_AABB;
    loopvj(dynlights)
    {
        dynlight &d = dynlights[j];
        if(d.curradius <= 0) continue;
        d.dist = camera1->o.dist(d.o) - d.curradius;
        if(d.dist > dynlightdist || isfoggedsphere(d.curradius, d.o) || pvsoccluded(d.o, 2*int(d.curradius+1)))
            continue;
        e.o = d.o;
        e.radius = e.xradius = e.yradius = e.eyeheight = e.aboveeye = d.curradius;
        if(collide(&e, vec(0, 0, 0), 0, false)) continue;

        int insert = 0;
        loopvrev(closedynlights) if(d.dist >= closedynlights[i]->dist) { insert = i+1; break; }
        closedynlights.insert(insert, &d);
    }
    return closedynlights.length();
}
Example #27
0
// Date is Y[-M[-D]]
static bool parsedate(vector<string>::const_iterator& it,
                      vector<string>::const_iterator end, DateInterval *dip)
{
    dip->y1 = dip->m1 = dip->d1 = dip->y2 = dip->m2 = dip->d2 = 0;
    if (it->length() > 4 || !it->length() ||
            it->find_first_not_of("0123456789") != string::npos) {
        return false;
    }
    if (it == end || sscanf(it++->c_str(), "%d", &dip->y1) != 1) {
        return false;
    }
    if (it == end || *it == "/") {
        return true;
    }
    if (*it++ != "-") {
        return false;
    }

    if (it->length() > 2 || !it->length() ||
            it->find_first_not_of("0123456789") != string::npos) {
        return false;
    }
    if (it == end || sscanf(it++->c_str(), "%d", &dip->m1) != 1) {
        return false;
    }
    if (it == end || *it == "/") {
        return true;
    }
    if (*it++ != "-") {
        return false;
    }

    if (it->length() > 2 || !it->length() ||
            it->find_first_not_of("0123456789") != string::npos) {
        return false;
    }
    if (it == end || sscanf(it++->c_str(), "%d", &dip->d1) != 1) {
        return false;
    }

    return true;
}
Example #28
0
inline double angle_between(const vector& from, const vector& to) noexcept {
    return std::acos(dot(from, to) / (from.length() * to.length()));
}
Example #29
0
 bool hasslot(const soundslot *p, const vector<soundslot> &v) const
 {
     return p >= v.getbuf() + slots && p < v.getbuf() + slots+numslots && slots+numslots < v.length(); 
 }
Example #30
0
void mapmodelreset(int *n)
{
    if(!(identflags&IDF_OVERRIDDEN) && !game::allowedittoggle()) return;
    mapmodels.shrink(clamp(*n, 0, mapmodels.length()));
}