Advertisement
expired6978

DeleteFaceGenData

Jul 13th, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1.     SInt32 DeleteFaceGenData(StaticFunctionTag*, TESNPC * npc)
  2.     {
  3.         SInt32 ret = 0;
  4.         if (!npc) {
  5.             _ERROR("%s - invalid actorbase.", __FUNCTION__);
  6.             return -1;
  7.         }
  8.  
  9.         char * modName = NULL;
  10.         UInt8 modIndex = npc->formID >> 24;
  11.         UInt32 modForm = (npc->formID & 0xFFFFFF);
  12.         DataHandler * dataHandler = DataHandler::GetSingleton();
  13.         if (dataHandler) {
  14.             ModInfo * modInfo = dataHandler->modList.modInfoList.GetNthItem(modIndex);
  15.             if (modInfo)
  16.                 modName = modInfo->name;
  17.         }
  18.  
  19.         enum
  20.         {
  21.             kReturnDeletedNif = 1,
  22.             kReturnDeletedDDS = 2
  23.         };
  24.        
  25.         char tempPath[MAX_PATH];
  26.         sprintf_s(tempPath, "Data\\Meshes\\Actors\\Character\\FaceGenData\\FaceGeom\\%s\\%08X.nif", modName, modForm);
  27.         if (!DeleteFile(tempPath)) {
  28.             UInt32 lastError = GetLastError();
  29.             switch (lastError) {
  30.             case ERROR_FILE_NOT_FOUND: // We don't need to display a message for this
  31.                 break;
  32.             case ERROR_ACCESS_DENIED:
  33.                 _ERROR("%s - access denied could not delete %s", __FUNCTION__, tempPath);
  34.                 break;
  35.             default:
  36.                 _ERROR("%s - error deleting file %s (Error %d)", __FUNCTION__, tempPath, lastError);
  37.                 break;
  38.             }
  39.         }
  40.         else
  41.             ret |= kReturnDeletedNif;
  42.  
  43.         sprintf_s(tempPath, "Data\\Textures\\Actors\\Character\\FaceGenData\\FaceTint\\%s\\%08X.dds", modName, modForm);
  44.         if (!DeleteFile(tempPath)) {
  45.             UInt32 lastError = GetLastError();
  46.             switch (lastError) {
  47.             case ERROR_FILE_NOT_FOUND: // We don't need to display a message for this
  48.                 break;
  49.             case ERROR_ACCESS_DENIED:
  50.                 _ERROR("%s - access denied could not delete %s", __FUNCTION__, tempPath);
  51.                 break;
  52.             default:
  53.                 _ERROR("%s - error deleting file %s (Error %d)", __FUNCTION__, tempPath, lastError);
  54.                 break;
  55.             }
  56.         }
  57.         else
  58.             ret |= kReturnDeletedDDS;
  59.  
  60.         return ret;
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement