/* void dump (CDetailManager::vis_list& lst) { for (int i=0; i<lst.size(); i++) { Msg("%8x / %8x / %8x", lst[i]._M_start, lst[i]._M_finish, lst[i]._M_end_of_storage._M_data); } } */ void CDetailManager::Load () { // Open file stream if (!FS.exist("$level$","level.details")) { dtFS = NULL; return; } string256 fn; FS.update_path (fn,"$level$","level.details"); dtFS = FS.r_open(fn); // Header dtFS->r_chunk_safe (0,&dtH,sizeof(dtH)); R_ASSERT (dtH.version == DETAIL_VERSION); u32 m_count = dtH.object_count; // Models IReader* m_fs = dtFS->open_chunk(1); for (u32 m_id = 0; m_id < m_count; m_id++) { CDetail* dt = xr_new<CDetail> (); IReader* S = m_fs->open_chunk(m_id); dt->Load (S); objects.push_back (dt); S->close (); } m_fs->close (); // Get pointer to database (slots) IReader* m_slots = dtFS->open_chunk(2); dtSlots = (DetailSlot*)m_slots->pointer(); m_slots->close (); // Initialize 'vis' and 'cache' for (u32 i=0; i<3; ++i) visible[i].resize(objects.size()); cache_Initialize (); // Make dither matrix bwdithermap (2,dither); // Hardware specific optimizations if (UseVS()) hw_Load (); else soft_Load (); // swing desc // normal swing_desc[0].amp1 = pSettings->r_float("details","swing_normal_amp1"); swing_desc[0].amp2 = pSettings->r_float("details","swing_normal_amp2"); swing_desc[0].rot1 = pSettings->r_float("details","swing_normal_rot1"); swing_desc[0].rot2 = pSettings->r_float("details","swing_normal_rot2"); swing_desc[0].speed = pSettings->r_float("details","swing_normal_speed"); // fast swing_desc[1].amp1 = pSettings->r_float("details","swing_fast_amp1"); swing_desc[1].amp2 = pSettings->r_float("details","swing_fast_amp2"); swing_desc[1].rot1 = pSettings->r_float("details","swing_fast_rot1"); swing_desc[1].rot2 = pSettings->r_float("details","swing_fast_rot2"); swing_desc[1].speed = pSettings->r_float("details","swing_fast_speed"); }
void EDetailManager::InvalidateCache() { // resize visible m_visibles[0].resize (objects.size()); // dump(visible[0]); m_visibles[1].resize (objects.size()); // dump(visible[1]); m_visibles[2].resize (objects.size()); // dump(visible[2]); // Initialize 'vis' and 'cache' cache_Initialize (); }
struct AmmServer_Instance * AmmServer_Start( const char * name , const char * ip, unsigned int port, const char * conf_file, const char * web_root_path, const char * templates_root_path ) { fprintf(stderr,"Binding AmmarServer v%s to %s:%u\n",FULLVERSION_STRING,ip,port); fprintf(stderr,"\n\nDISCLAIMER : \n"); fprintf(stderr,"Please note that this server version is not thoroughly\n"); fprintf(stderr," pen-tested so it is not meant for production deployment..\n"); fprintf(stderr,"Bug reports and feedback are very welcome.. \n"); fprintf(stderr,"via https://github.com/AmmarkoV/AmmarServer/issues\n\n"); //log/ could be a global directory snprintf(AccessLog,MAX_FILE_PATH,"log/%s_access.log",name); snprintf(ErrorLog,MAX_FILE_PATH,"log/%s_error.log",name); fprintf(stderr,"Access logged @ %s , Errors logged @ %s \n ",AccessLog,ErrorLog); //Allocate and Clear instance.. struct AmmServer_Instance * instance = (struct AmmServer_Instance *) malloc(sizeof(struct AmmServer_Instance)); if (!instance) { fprintf(stderr,"AmmServer_Start failed to allocate a new instance \n"); } else { memset(instance,0,sizeof(struct AmmServer_Instance)); } fprintf(stderr,"Initial AmmServer_Start instance pointing @ %p \n",instance);//Clear instance..! instance->threads_pool = (pthread_t *) malloc( sizeof(pthread_t) * MAX_CLIENT_THREADS); if (!instance->threads_pool) { fprintf(stderr,"AmmServer_Start failed to allocate %u records for a thread pool\n",MAX_CLIENT_THREADS); } else { memset(instance->threads_pool,0,sizeof(pthread_t)*MAX_CLIENT_THREADS); } strncpy(instance->instanceName , name , MAX_INSTANCE_NAME_STRING); // TODO: check for MAX_INSTANCE_NAME_STRING fprintf(stderr,"Initial AmmServer_Start ( name %s ) thread pool pointing @ %p \n",instance->instanceName,instance->threads_pool);//Clear instance..! instance->prespawned_pool = (void *) malloc( sizeof(struct PreSpawnedThread) * MAX_CLIENT_PRESPAWNED_THREADS); if (!instance->prespawned_pool) { fprintf(stderr,"AmmServer_Start failed to allocate %u records for a prespawned thread pool\n",MAX_CLIENT_PRESPAWNED_THREADS); }else { if (MAX_CLIENT_PRESPAWNED_THREADS>0) { memset(instance->prespawned_pool,0,sizeof(pthread_t)*MAX_CLIENT_PRESPAWNED_THREADS); } } //LoadConfigurationFile happens before dropping root id so we are more sure that we will manage to read the configuration file.. LoadConfigurationFile(instance,conf_file); //LoadConfigurationFile may set a binding port but if the parent call set a nonzero a port setting here it overrides configuration file.... if (port!=0) { instance->settings.BINDING_PORT = port; } //This line explains configuration conflicts in a user understandable manner :p EmmitPossibleConfigurationWarnings(instance); cache_Initialize( instance, /*These are the file cache settings , file caching is the mechanism that holds dynamic content and speeds up file serving by not accessing the whole disk drive subsystem ..*/ MAX_SEPERATE_CACHE_ITEMS , /*Seperate items*/ MAX_CACHE_SIZE_IN_MB , /*MB Limit for the WHOLE Cache*/ MAX_CACHE_SIZE_FOR_EACH_FILE_IN_MB /*MB Max Size of Individual File*/ ); if (StartHTTPServer(instance,ip,instance->settings.BINDING_PORT,web_root_path,templates_root_path)) { //All is well , we return a valid instance AccessLogAppend("127.0.0.1",0,"startup",1,0,"startup","ammarserver"); return instance; } else { AmmServer_Stop(instance); return 0; } return 0; }