Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_pre.php on line 387

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_pre.php on line 387

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 337

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 339

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 341

Warning: Non-static method vBSEO_Storage::path() should not be called statically in ..../vbseo/includes/functions_vbseo_seo.php on line 343
Optimization

Results 1 to 2 of 2

Thread: Optimization

  1. #1
    Semi-Coder t00ny's Avatar
    Join Date
    Jan 2008
    Posts
    361

    Optimization

    Hello, is there a way to optimize my code ? Because it takes a lot of memory (i think) because my game crashes afetr 1 or 2 maps. The game is CoD4;

    Here's my code:
    Code:
    //Globals
    const int MAX_SIZE=4;
    
    // *** OPFOR ***
    // numVertices
    const int opf_AssaultNV[MAX_SIZE]={ 3124, 1970, 1252, 470 };
    const int opf_SpecOpsNV[MAX_SIZE]={ 3531, 2188, 1325, 499 };
    const int opf_HvyGunrNV[MAX_SIZE]={ 2715, 1620,  943, 441 };
    const int opf_DemolNV[MAX_SIZE] =  { 2816, 1733, 1150, 435 };
    const int opf_SniperNV[MAX_SIZE] = { 2818, 1715, 1101, 481 };
    // primCount
    const int opf_AssaultPC[MAX_SIZE]={ 4132, 2186, 1160, 352 };
    const int opf_SpecOpsPC[MAX_SIZE]={ 4526, 2386, 1194, 352 };
    const int opf_HvyGunrPC[MAX_SIZE]={ 3588, 1886,  908, 308 };
    const int opf_DemolPC[MAX_SIZE]  = { 3642, 2022, 1086, 320 };
    const int opf_SniperPC[MAX_SIZE] = { 3672, 1950, 1066, 350 };
    
    // *** SPETSNAZ *** 
    const int spe_AssaultNV[MAX_SIZE]={ 4358, 3278, 1633, 840 };
    const int spe_SpecOpsNV[MAX_SIZE]={ 4242, 2391, 1689, 969 };
    const int spe_HvyGunrNV[MAX_SIZE]={ 4270, 2755, 1317, 809 };
    const int spe_DemolNV[MAX_SIZE] ={ 3891, 2510, 1398, 994 };
    const int spe_SniperNV[MAX_SIZE]={ 3326, 2140, 1315, 726 };
    // primCount
    const int spe_AssaultPC[MAX_SIZE]={ 4864, 3188, 1322, 618 };
    const int spe_SpecOpsPC[MAX_SIZE]={ 5028, 2488, 1422, 708 };
    const int spe_HvyGunrPC[MAX_SIZE]={ 4804, 2494, 1054, 590 };
    const int spe_DemolPC[MAX_SIZE] ={ 4598, 2470, 1176, 714 };
    const int spe_SniperPC[MAX_SIZE]={ 4336, 2310, 1170, 556 };
    
    // *** MARINES & S.A.S. ***
    // numVertices
    const int mar_AssaultNV[MAX_SIZE]={ 2613, 1842, 1034, 447 };
    const int mar_SpecOpsNV[MAX_SIZE]={ 3790, 2784, 1572, 634 };
    const int mar_HvyGunrNV[MAX_SIZE]={ 3597, 2301, 1341, 580 };
    const int mar_DemolNV[MAX_SIZE] = { 4050, 2540, 1488, 592 };
    const int mar_SniperNV[MAX_SIZE] ={ 2516, 1726, 1020, 587 };
    // primCount
    const int mar_AssaultPC[MAX_SIZE]={ 3248, 1978,  904, 312 };
    const int mar_SpecOpsPC[MAX_SIZE]={ 4078, 2384, 1166, 372 };
    const int mar_HvyGunrPC[MAX_SIZE]={ 4280, 2364, 1132, 380 };
    const int mar_DemolPC[MAX_SIZE] = { 4486, 2444, 1114, 374 };
    const int mar_SniperPC[MAX_SIZE] ={ 2940, 1760,  872, 370 };
    
    // *** S.A.S. ***
    // numVertices
    const int sas_AssaultNV[MAX_SIZE]={ 3935, 2640, 1373, 585 };
    const int sas_SpecOpsNV[MAX_SIZE]={ 3585, 2525, 1498, 695 };
    const int sas_HvyGunrNV[MAX_SIZE]={ 3716, 2578, 1412, 568 };
    const int sas_DemolNV[MAX_SIZE] = { 3562, 2509, 1402, 628 };
    const int sas_SniperNV[MAX_SIZE]= { 3667, 2460, 1479, 552 };
    const int sas_Sniper2[MAX_SIZE] = { 2578, 2328, 2286, 349 }; 
    // primCount
    const int sas_AssaultPC[MAX_SIZE]={ 5226, 3070, 1256, 440 };
    const int sas_SpecOpsPC[MAX_SIZE]={ 4858, 3022, 1304, 478 };
    const int sas_HvyGunrPC[MAX_SIZE]={ 5064, 2994, 1330, 470 };
    const int sas_DemolPC[MAX_SIZE] = { 4784, 2954, 1164, 450 };
    const int sas_SniperPC[MAX_SIZE]= { 4952, 2882, 1402, 452 };
    const int sas_Sniper2PC[MAX_SIZE]={ 2192, 1992, 1184, 254 };
    
    // *** Objects ***
    //numVertices
    const int laptops[2] = {392, 225 };
    const int clays[2] = {469, 68 };
    //primCount
    const int laptopsPC[2] = {282, 154 };
    const int claysPC[2] = {316, 44 };
    
    //Wallhack func :
    void XQZwh(IDirect3DDevice9* device, LPDIRECT3DTEXTURE9 tex1, LPDIRECT3DTEXTURE9 tex2, D3DPRIMITIVETYPE Type,INT BaseVertexIndex,UINT MinVertexIndex,UINT NumVertices,UINT startIndex,UINT primCount) 
    { 
        DWORD dwOldZEnable; 
        device->SetTexture(0,NULL); 
        device->SetTexture(0,tex1); 
        device->GetRenderState(D3DRS_ZENABLE,&dwOldZEnable); 
        device->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE); 
        device->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER); 
        device->DrawIndexedPrimitive(Type,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount); 
        device->SetRenderState(D3DRS_ZENABLE,dwOldZEnable); 
        device->SetRenderState(D3DRS_ZFUNC,D3DCMP_LESSEQUAL); 
        device->SetTexture(0,tex2); 
    } 
    
    //DrawIndexedPrimitives
        for(int mar_val = 0; mar_val <= MAX_SIZE-1; mar_val++)
        {
          if( NumVertices == mar_AssaultNV[mar_val] && primCount == mar_AssaultPC[mar_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);               
          }
          if( NumVertices == mar_SpecOpsNV[mar_val] && primCount == mar_SpecOpsPC[mar_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == mar_HvyGunrNV[mar_val] && primCount == mar_HvyGunrPC[mar_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == mar_DemolNV[mar_val] && primCount == mar_DemolPC[mar_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == mar_SniperNV[mar_val] && primCount == mar_SniperPC[mar_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
        }
        for(int opf_val = 0; opf_val <= MAX_SIZE-1; opf_val++)
        {
          if( NumVertices == opf_AssaultNV[opf_val] && primCount == opf_AssaultPC[opf_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);               
          }
          if( NumVertices == opf_SpecOpsNV[opf_val] && primCount == opf_SpecOpsPC[opf_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == opf_HvyGunrNV[opf_val] && primCount == opf_HvyGunrPC[opf_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == opf_DemolNV[opf_val] && primCount == opf_DemolPC[opf_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == opf_SniperNV[opf_val] && primCount == opf_SniperPC[opf_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
        }
        for(int sas_val = 0; sas_val <= MAX_SIZE-1; sas_val++)
        {
          if( NumVertices == sas_AssaultNV[sas_val] && primCount == sas_AssaultPC[sas_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);               
          }
          if( NumVertices == sas_SpecOpsNV[sas_val] && primCount == sas_SpecOpsPC[sas_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == sas_HvyGunrNV[sas_val] && primCount == sas_HvyGunrPC[sas_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == sas_DemolNV[sas_val] && primCount == sas_DemolPC[sas_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == sas_SniperNV[sas_val] && primCount == sas_SniperPC[sas_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == sas_Sniper2[sas_val] && primCount == sas_Sniper2PC[sas_val])
          {
                XQZwh(or_IDirect3DDevice9, texBlue, texYellow, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
        }
        for(int spe_val = 0; spe_val <= MAX_SIZE-1; spe_val++)
        {
          if( NumVertices == spe_AssaultNV[spe_val] && primCount == spe_AssaultPC[spe_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);               
          }
          if( NumVertices == spe_SpecOpsNV[spe_val] && primCount == spe_SpecOpsPC[spe_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == spe_HvyGunrNV[spe_val] && primCount == spe_HvyGunrPC[spe_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == spe_DemolNV[spe_val] && primCount == spe_DemolPC[spe_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == spe_SniperNV[spe_val] && primCount == spe_SniperPC[spe_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
        }
        for(int obj_val = 0; obj_val <= 2-1; obj_val++)
        {
          if( NumVertices == clays[obj_val] && primCount == claysPC[obj_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
          if( NumVertices == laptops[obj_val] && primCount == laptopsPC[obj_val])
          {
                XQZwh(or_IDirect3DDevice9, texRed, texGreen, Type, BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount); 
          }
        }
    So, can you help me ? Thanks !;D
    Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest. - I.A

  2. #2
    VIP null's Avatar
    Join Date
    Apr 2006
    Posts
    1,796

    Re: Optimization

    Instead of just plain if, try to use else if.. other then that not much that I see, although I havent done much (read: any) D3D coding.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •