void _ol_ldap_program_init(void) { start_new_program(); ADD_STORAGE(OLSTORAGE); set_init_callback(init_ldap); set_exit_callback(exit_ldap); ADD_FUNCTION("create", f_create, tFunc(tString, tVoid), 0); ADD_FUNCTION("bind", f_ldap_bind, tFunc(tOr(tString, tVoid) tOr(tString, tVoid) tOr(tInt, tVoid), tInt), 0); ADD_FUNCTION("unbind", f_ldap_unbind, tFunc(tVoid, tInt), 0); ADD_FUNCTION("enable_cache", f_ldap_enable_cache, tFunc(tOr(tInt, tVoid) tOr(tInt, tVoid), tInt), 0); ADD_FUNCTION("disable_cache", f_ldap_disable_cache, tFunc(tVoid, tVoid), 0); ADD_FUNCTION("destroy_cache", f_ldap_destroy_cache, tFunc(tVoid, tVoid), 0); ADD_FUNCTION("flush_cache", f_ldap_flush_cache, tFunc(tVoid, tVoid), 0); ADD_FUNCTION("uncache_entry", f_ldap_uncache_entry, tFunc(tString, tVoid), 0); ADD_FUNCTION("set_cache_options", f_ldap_set_cache_options, tFunc(tInt, tVoid), 0); ADD_FUNCTION("err2string", f_ldap_err2string, tFunc(tInt, tVoid), 0); ADD_FUNCTION("set_base_dn", f_set_base_dn, tFunc(tString, tString), 0); ADD_FUNCTION("set_basedn", f_set_base_dn, tFunc(tString, tString), 0); ADD_FUNCTION("set_scope", f_set_scope, tFunc(tInt, tVoid), 0); ADD_FUNCTION("dn2ufn", f_ldap_dn2ufn, tFunc(tString, tString), 0); ADD_FUNCTION("explode_dn", f_ldap_explode_dn, tFunc(tString tOr(tInt, tVoid), tArr(tString)), 0); ADD_FUNCTION("search", f_ldap_search, tFunc(tOr(tMapping, tString tOr(tArray, tVoid) tOr(tInt, tVoid) tOr(tInt, tVoid)), tOr(tObj, tInt)), 0); ADD_FUNCTION("modify", f_ldap_modify, tFunc(tString tArr(tMap(tString, tMixed)), tVoid), 0); ADD_FUNCTION("add", f_ldap_add, tFunc(tString tArr(tMap(tString, tMixed)), tVoid), 0); ADD_FUNCTION("delete", f_ldap_delete, tFunc(tString, tVoid), 0); _ol_result_program_init(); ldap_program = end_program(); add_program_constant("Client", ldap_program, 0); add_program_constant("client", ldap_program, 0); }
void init_image_xbm(void) { ADD_FUNCTION( "_decode", image_xbm__decode, tFunc(tStr tOr(tVoid,tMapping),tMap(tStr,tObj)), 0); ADD_FUNCTION( "decode", image_xbm_decode, tFunc(tStr,tObj), 0); ADD_FUNCTION( "encode", image_xbm_encode, tFunc(tObj tOr(tVoid,tMapping),tStr), 0); param_name=make_shared_string("name"); param_fg=make_shared_string("fg"); param_bg=make_shared_string("bg"); param_invert=make_shared_string("invert"); }
void createPermutation(hash_map<int,int> hm,vector<int> cur,vector<vector<int> >& res){ if(hm.size()){ for(hash_map<int,int>::iterator it=hm.begin();it!=hm.end();it++){ vector<int> tVec(cur); hash_map<int,int> tMap(hm); tVec.push_back(it->first); if(tMap[it->first]==1) tMap.erase(it->first); else tMap[it->first]--; createPermutation(tMap,tVec,res); } } else res.push_back(cur); }
CCrossTableBuilder::CCrossTableBuilder(LPCSTR caProjectName) { FILE_NAME caFileName; strconcat (sizeof(caFileName),caFileName,caProjectName,GAME_LEVEL_GRAPH); Phase ("Loading level graph"); CGameGraph tGraph(caFileName); Phase ("Loading AI map"); CLevelGraph tMap(caProjectName); Phase ("Building dynamic objects"); FLOAT_VECTOR_VECTOR tDistances; int iVertexCount = tGraph.header().vertex_count(); R_ASSERT2 (iVertexCount > 0,"There are no graph points in the graph!"); int iNodeCount = tMap.header().vertex_count(); xr_vector<bool> tMarks; tMarks.assign (tMap.header().vertex_count(),false); { for (int i=0; i<iVertexCount; i++) vfRecurseMark(tMap,tMarks,tGraph.vertex(i)->level_vertex_id()); tMarks.flip (); } tDistances.resize (iVertexCount); { FLOAT_VECTOR_IT I = tDistances.begin(); FLOAT_VECTOR_IT E = tDistances.end(); for ( ; I != E; I++) { (*I).resize (iNodeCount); FLOAT_IT i = (*I).begin(); FLOAT_IT e = (*I).end(); for ( ; i != e; i++) *i = u32(-1); } } Phase ("Building cross table"); Progress(0.f); for (int i=0; i<iVertexCount; ++i) { if (i) for (int k=0; k<(int)tMap.header().vertex_count(); k++) tDistances[i][k] = tDistances[i - 1][k]; g_tDistances = &tDistances[i]; g_tMap = &tMap; g_tMarks = &tMarks; vfRecurseUpdate(tGraph.vertex(i)->level_vertex_id(),i,iVertexCount); Progress(float(i + 1)/float(iVertexCount)); } Progress (1.f); Phase ("Saving cross table"); CMemoryWriter tMemoryStream; CGameLevelCrossTable::CHeader tCrossTableHeader; tCrossTableHeader.dwVersion = XRAI_CURRENT_VERSION; tCrossTableHeader.dwNodeCount = iNodeCount; tCrossTableHeader.dwGraphPointCount = iVertexCount; tCrossTableHeader.m_level_guid = tMap.header().guid(); tCrossTableHeader.m_game_guid = tGraph.header().guid(); tMemoryStream.open_chunk (CROSS_TABLE_CHUNK_VERSION); tMemoryStream.w (&tCrossTableHeader,sizeof(tCrossTableHeader)); tMemoryStream.close_chunk (); tMemoryStream.open_chunk (CROSS_TABLE_CHUNK_DATA); { for (int i=0; i<iNodeCount; i++) { FLOAT_VECTOR_IT I = tDistances.begin(), B = I; FLOAT_VECTOR_IT E = tDistances.end(); CGameLevelCrossTable::CCell tCrossTableCell; tCrossTableCell.fDistance = flt_max; tCrossTableCell.tGraphIndex = u16(-1); for ( ; I != E; I++) if (float((*I)[i])*tMap.header().cell_size() < tCrossTableCell.fDistance) { tCrossTableCell.fDistance = float((*I)[i])*tMap.header().cell_size(); tCrossTableCell.tGraphIndex = GameGraph::_GRAPH_ID(I - B); } for (int j=0; j<iVertexCount; j++) if ((tGraph.vertex(j)->level_vertex_id() == (u32)i) && (tCrossTableCell.tGraphIndex != j)) { Msg("! Warning : graph points are too close, therefore cross table is automatically validated"); Msg("%d : [%f][%f][%f] %d[%f] -> %d[%f]",i,VPUSH(tGraph.vertex(j)->level_point()),tCrossTableCell.tGraphIndex,tCrossTableCell.fDistance,j,tDistances[j][i]); tCrossTableCell.fDistance = float(tDistances[j][i])*tMap.header().cell_size(); tCrossTableCell.tGraphIndex = (GameGraph::_GRAPH_ID)j; } tMemoryStream.w(&tCrossTableCell,sizeof(tCrossTableCell)); } } tMemoryStream.close_chunk(); strconcat (sizeof(caFileName),caFileName,caProjectName,CROSS_TABLE_NAME_RAW); tMemoryStream.save_to(caFileName); }