MCPcopy Index your code
hub / github.com/assaultcube/AC / addigraph

Function addigraph

source/src/rendertext.cpp:470–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468vector<igraph *> usedigraphs; // char codes ('\1' + n)
469
470void addigraph(char *fname)
471{
472 char *b, *s = newstring(fname), *mnem = strtok_r(s, "_", &b), *r;
473 if(mnem && *mnem && !igraphs.access(mnem))
474 { // new mnem
475 defformatstring(filename)("%s%s.png", IGRAPHPATH, fname);
476 Texture *tex = textureload(filename);
477 if(tex != notexture && tex->xs && tex->ys)
478 {
479 igraph &ig = igraphs[newstring(mnem)];
480 ig.fname = fname;
481 ig.tex = tex;
482 ig.used = !mnem[1] && *mnem >= '1' && *mnem <= '9' ? *mnem - '0' : 0;
483 if(ig.used && usedigraphs.inrange(ig.used)) usedigraphs[ig.used] = &ig; // hardcode "1".."9"
484 while((r = strtok_r(NULL, "_", &b))) ig.frames.add(max(5, (int)ATOI(r)));
485 if(ig.frames.empty()) ig.frames.add(igraphdefaultframetime);
486 while(ig.frames.length() < tex->xs / tex->ys) ig.frames.add(ig.frames.last());
487 loopv(ig.frames) if(i) ig.frames[i] += ig.frames[i - 1];
488#ifdef _DEBUG
489 clientlogf(" loaded igraph \"%s\", short \"%s\", %dx%d, %d frame%s", fname, mnem, tex->xs, tex->ys, ig.frames.length(), ig.frames.length() > 1 ? "s" : "");
490#endif
491 }
492 }
493 igraphsi[fname] = 0;
494 delstring(s);
495}
496
497void updateigraphs() // read all filenames and parse new ones (also preloads the textures)
498{

Callers 1

loopvrevFunction · 0.85

Calls 12

newstringFunction · 0.85
strtok_rFunction · 0.85
textureloadFunction · 0.85
maxFunction · 0.85
clientlogfFunction · 0.85
delstringFunction · 0.85
accessMethod · 0.80
inrangeMethod · 0.80
loopvFunction · 0.70
addMethod · 0.45
emptyMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected