Esempio n. 1
0
static int Create(lua_State *L, int arg, size_t alignment)
    {
    const char *data = NULL;
    char *ptr;
    size_t size;

    if(lua_type(L, arg) == LUA_TSTRING)
        {
        if(!lua_isnoneornil(L, arg+1))
            return CreatePack(L, arg, alignment);
    
        data = luaL_checklstring(L, arg, &size);
        if(size == 0) 
            return luaL_argerror(L, arg, errstring(ERR_LENGTH));
        }
    else
        {
        size = luaL_checkinteger(L, arg);
        if(size == 0) 
            return luaL_argerror(L, arg, errstring(ERR_VALUE));
        }

    ptr = (char*)AlignedAlloc(alignment, size); // (char*)Malloc(L, size);
    if(!ptr)
        return luaL_error(L, "failed to allocate page aligned memory");
            
    if(data)
        memcpy(ptr, data, size);
    else
        memset(ptr, 0, size);

    CreateAllocated(L, ptr, size);
    return 1;
    }
TextureDetails RenderSystem::CreateTextureDetails(TextureDetails texinfo, ID3D11Texture2D* texture, uint32_t width, uint32_t height)
{
	TextureDetails tex(0, 0, 0, width, height);

	// Create a new pack for this texture
	uint16_t packID = CreatePack(texture, width, height);
	
	// Now create a texture details
	return CreateTextureDetails(tex, packID);
}
Esempio n. 3
0
//
// main
//
// da big cheese
//
int __cdecl main(int argc, char *argv[])
{
  char pack[_MAX_FNAME] = "";
  char dir[_MAX_PATH] = ".";
  char *mask = "*.*";
  int subs = 0;
  enum { CREATE, EXTRACT, LIST } command = CREATE;

  printf("Dark Reign 2 - Pack Utility, %s %s\n\n", __DATE__, __TIME__);

  // get exe name
  exeName = PackTool::NameFromPath(*argv);

  // required arguments
  if (argc < 3)
  {
    Usage();
  }

  // be picky about single char command
  if (argv[1][1] != '\0')
  {
    printf("Unknown command '%s'\n\n", argv[1]);   
    Usage();
  }

  // set command
  switch (*argv[1])
  {
    case 'c' :
      command = CREATE;     
      break;

    case 'x' :
      command = EXTRACT;
      break;

    case 'l' :
      command = LIST;
      break;

    default:
      printf("Unknown command '%s'\n\n", argv[1]);
      Usage();
  }

  // parse remaining arguments
  for (int i = 2; i < argc; i++)
  {
    // is this an option
    if (*argv[i] == '-')
    {
      switch (argv[i][1])
      {
        case 'r' : 
          subs = 1;
          break;

        case 'm' :
          if ((mask = strchr(argv[i], '=')) == 0)
          {
            Usage();
          }
          mask++;         
          break;

        default:
          printf("Unknown option '-%c'\n\n", argv[i][1]);
          Usage();
      }
    }
    else
    {
      // is this the pack name
      if (*pack == '\0')
      {
        strcpy(pack, argv[i]);
      }
      else
      {
        // must be the dir
        strcpy(dir, argv[i]);
      }
    }
  }

  // check that we got a pack name
  if (*pack == '\0')
  {
    printf("No pack file name supplied\n\n");
    Usage();  
  }

  // packtool throws char* exceptions
  try 
  {
    // do the operation
    switch (command)
    {
      case CREATE:
        CreatePack(pack, dir, mask, subs);
        break;

      case EXTRACT:
        ExtractPack(pack, dir);
        break;

      case LIST:
        ListPack(pack);
        break;

      default:
        Usage();
    }
	} 
  catch (char *msg)
	{
    printf("\nError : %s", msg);
	}

  return (0);  
}