void renderbackground(const char *caption, Texture *mapshot, const char *mapname, const char *mapinfo, bool restore, bool force) { if(!inbetweenframes && !force) return; stopsounds(); // stop sounds while loading int w = screen->w, h = screen->h; if(forceaspect) w = int(ceil(h*forceaspect)); getbackgroundres(w, h); gettextres(w, h); static int lastupdate = -1, lastw = -1, lasth = -1; static float backgroundu = 0, backgroundv = 0, detailu = 0, detailv = 0; static int numdecals = 0; static struct decal { float x, y, size; int side; } decals[12]; if((renderedframe && !mainmenu && lastupdate != lastmillis) || lastw != w || lasth != h) { lastupdate = lastmillis; lastw = w; lasth = h; backgroundu = rndscale(1); backgroundv = rndscale(1); detailu = rndscale(1); detailv = rndscale(1); numdecals = sizeof(decals)/sizeof(decals[0]); numdecals = numdecals/3 + rnd((numdecals*2)/3 + 1); float maxsize = min(w, h)/16.0f; loopi(numdecals) { decal d = { rndscale(w), rndscale(h), maxsize/2 + rndscale(maxsize/2), rnd(2) }; decals[i] = d; } }
/* * Scenario code UUID (version 4) generator for OctaForge * Based on a JS snippet from here * * http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript * */ void generate_scenario_code() { copystring(scenario_code, "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"); int r = 0; string tmp; for (char *it = scenario_code; *it; ++it) { if (*it == '4' || *it == '-') continue; r = (int)floor(rndscale(1) * 16); formatstring(tmp)("%x", (*it == 'x') ? r : ((r&0x3)|0x8)); *it = tmp[0]; } }
/* * Scenario code UUID (version 4) generator for OctaForge * Based on a JS snippet from here * * http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript * */ void generate_scenario_code() { scenario_code = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"; int r = 0; types::String tmp; char *it = scenario_code.begin(); for (; it < scenario_code.end (); it++) { if (*it == '4' || *it == '-') continue; r = (int)floor(rndscale(1) * 16); tmp.format("%x", (*it == 'x') ? r : ((r&0x3)|0x8)); *it = tmp[0]; } }
void renderbackground(const char *caption, Texture *mapshot, const char *mapname, const char *mapinfo, bool restore, bool force) { if(!inbetweenframes && !force) return; stopsounds(); // stop sounds while loading int w = screen->w, h = screen->h; getbackgroundres(w, h); gettextres(w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w, h, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); defaultshader->set(); glEnable(GL_TEXTURE_2D); static int lastupdate = -1, lastw = -1, lasth = -1; static float backgroundu = 0, backgroundv = 0; #if 0 static float detailu = 0, detailv = 0; static int numdecals = 0; static struct decal { float x, y, size; int side; } decals[12]; #endif if((renderedframe && !gui::mainmenu && lastupdate != lastmillis) || lastw != w || lasth != h) { lastupdate = lastmillis; lastw = w; lasth = h; backgroundu = rndscale(1); backgroundv = rndscale(1); #if 0 detailu = rndscale(1); detailv = rndscale(1); numdecals = sizeof(decals)/sizeof(decals[0]); numdecals = numdecals/3 + rnd((numdecals*2)/3 + 1); float maxsize = min(w, h)/16.0f; loopi(numdecals) { decal d = { rndscale(w), rndscale(h), maxsize/2 + rndscale(maxsize/2), rnd(2) }; decals[i] = d; } #endif }