Guest
Public paste!

BlueLights

By: a guest | Mar 19th, 2010 | Syntax: C++ | Size: 2.85 KB | Hits: 85 | Expires: Never
Copy text to clipboard
  1. // Modified on 10 July 2007 by Nicholas "Snobaste" Fetcko
  2. // Using blue lights instead of black for his "Frozen Core"
  3. // model change.
  4.  
  5. #include "stdafx.h"
  6.  
  7. struct SMOLight // 04-29-2005 By ObscuR
  8. {
  9.                         int Flags;
  10. /*004h*/  unsigned int color;  
  11. /*008h*/  float position[3];
  12. /*014h*/  float intensity;
  13. /*018h*/  float attenStart;
  14. /*01Ch*/  float attenEnd;
  15. /*020h*/  float unk1;
  16. /*024h*/  float unk2;
  17. /*028h*/  float unk3;
  18. /*02Ch*/  float unk4;
  19. /*030h*/  
  20. };
  21.  
  22. struct MODD
  23. {
  24.         int     Fake[9];
  25.         unsigned int color;
  26. };
  27.  
  28.  
  29.  
  30. char *nextChunk(char *buffer)
  31. {
  32.         unsigned int offset;
  33.         offset=*(unsigned int *)(buffer+4);
  34.         return buffer+offset+8;
  35. }
  36.  
  37. int main(int argc, char *argv[])
  38. {
  39.         FILE *f;
  40.         char *buffer;
  41.         char *pos;
  42.         int     Length;
  43.  
  44.         if(argc<2)
  45.                 printf("LightsOut <WMO File>\n");
  46.  
  47.         f=fopen(argv[1],"rb+");
  48.         if(f==0)
  49.         {
  50.                 printf("ERROR: Couldn't open %s\n",argv[1]);
  51.                 return 0;
  52.         }
  53.         fseek(f,0,SEEK_END);
  54.         Length=ftell(f);
  55.         fseek(f,0,SEEK_SET);
  56.         buffer=new char[Length];
  57.         fread(buffer,Length,1,f);
  58.         fclose(f);
  59.  
  60.        
  61.         unsigned int HeaderType;
  62.         char *Temp;
  63.         Temp=(char *)&HeaderType;
  64.  
  65.         HeaderType=*(unsigned int *)(buffer+12);
  66.  
  67.         printf("Checking File Type %c%c%c%c\n",Temp[3],Temp[2],Temp[1],Temp[0]);
  68.  
  69.         if(HeaderType==0x4d4f4750)
  70.         {
  71.                 printf("Processing a Group WMO\n");
  72.                 pos=buffer+88;
  73.         }
  74.         else if(HeaderType==0x4d4f4844)
  75.         {
  76.                 printf("Processing a Root WMO\n");
  77.                 pos=buffer+84;
  78.         }
  79.  
  80.         while(((pos-buffer)<Length)&&(*(unsigned int *)pos!=0x4d4f4356)&&(*(unsigned int *)pos!=0x4d4f4C54))
  81.         {
  82.                 printf("Skipping chunk %c%c%c%c\n",pos[3],pos[2],pos[1],pos[0]);
  83.                 pos=nextChunk(pos);
  84.         }
  85.  
  86.         printf("Found chunk %c%c%c%c\n",pos[3],pos[2],pos[1],pos[0]);
  87.  
  88.         if(((pos-buffer)<Length)&&(*(unsigned int *)pos==0x4d4f4C54))
  89.         {
  90.                 int count=(*(int *)(pos+4))/sizeof(SMOLight);
  91.                 SMOLight *Lights;
  92.                 Lights=(SMOLight *)(pos+8);
  93.  
  94.                 printf("Setting %d light colors to (0,0,0,1)\n",count);
  95.                
  96.                 for(int i=0;i<count;i++)
  97.                         Lights[i].color=0x2266ccff;
  98.  
  99.                 printf("Looking for MODD\n");
  100.  
  101.                 pos=buffer+84;
  102.  
  103.                 while(((pos-buffer)<Length)&&(*(unsigned int *)pos!=0x4d4f4444))
  104.                 {
  105.                         printf("Skipping chunk %c%c%c%c\n",pos[3],pos[2],pos[1],pos[0]);
  106.                         pos=nextChunk(pos);
  107.                 }
  108.  
  109.                 if(((pos-buffer)<Length)&&(*(unsigned int *)pos==0x4d4f4444))
  110.                 {
  111.                         int count=(*(int *)(pos+4))/sizeof(MODD);
  112.                         MODD *Models;
  113.                         Models=(MODD *)(pos+8);
  114.  
  115.                         printf("Setting %d model colors to (0,0,0,1)\n",count);
  116.                
  117.                         for(int i=0;i<count;i++)
  118.                                 Models[i].color=0x2266ccff;
  119.                 }
  120.  
  121.         }
  122.         else if(((pos-buffer)<Length)&&(*(unsigned int *)pos==0x4d4f4356))
  123.         {
  124.                 int count=(*(int *)(pos+4))/4;
  125.                 unsigned int *light=(unsigned int *)(pos+8);
  126.  
  127.                 printf("Setting %d vertex colors to (0,0,0,1)\n",count);
  128.                
  129.                 for(int i=0;i<count;i++)
  130.                         light[i]=0x2266ccff;
  131.         }
  132.  
  133.         f=fopen(argv[1],"wb");
  134.         fwrite(buffer,Length,1,f);
  135.         fclose(f);
  136.         delete buffer;
  137.  
  138.         return 0;
  139. }