Esempio n. 1
0
void MakeJoinedGameCommand(int net_player_flags, int net_player_x4,
    int save_player_id, int save_player_unique_id, uint32_t save_hash, bool create)
{
    if (*bw::joined_game_packet == nullptr)
        *bw::joined_game_packet = (uint8_t *)SMemAlloc(0x12, __FILE__, __LINE__, 8);
    uint8_t *buf = *bw::joined_game_packet;
    buf[0] = commands::JoinedGame;
    buf[1] = save_player_id;
    buf[2] = save_player_unique_id;
    *(uint32_t *)(buf + 0x3) = save_hash;
    *(uint16_t *)(buf + 0x7) = net_player_flags;
    *(uint16_t *)(buf + 0x9) = net_player_x4;
    *(uint16_t *)(buf + 0xb) = ProtocolVersion;
    if (create)
    {
        Command_JoinedGame(buf, *bw::local_net_player, true);
        SMemFree(*bw::joined_game_packet, __FILE__, __LINE__, 0);
        *bw::joined_game_packet = nullptr;
    }
}
Esempio n. 2
0
		bool read_virtual_button_blp(const char* filepath, const void** buffer_ptr, uint32_t* size_ptr, uint32_t reserve_size, OVERLAPPED* overlapped_ptr)
		{
			auto it = g_virtualblp.find(filepath);
			if (it == g_virtualblp.end())
			{
				return false;
			}
			image::buffer& blp = it->second;
			void* result = SMemAlloc(blp.size() + reserve_size);
			if (!result)
			{
				return false;
			}
			memcpy(result, blp.data(), blp.size());
			*buffer_ptr = result;
			if (reserve_size) memset((unsigned char*)result + blp.size(), 0, reserve_size);
			if (size_ptr) *size_ptr = blp.size();
			if (overlapped_ptr && overlapped_ptr->hEvent) ::SetEvent(overlapped_ptr->hEvent);
			return true;
		}
Esempio n. 3
0
		bool disable_button_blp(const char* filename, const void** buffer_ptr, uint32_t* size_ptr, uint32_t reserve_size)
		{
			image::buffer input;
			image::buffer output;
			if (!read_button_blp(filename, input))
			{
				return false;
			}
			if (!BlpDisable(input, output))
			{
				return false;
			}

			void* result = SMemAlloc(output.size() + reserve_size);
			if (!result)
			{
				return false;
			}
			memcpy(result, output.data(), output.size());
			*buffer_ptr = result;
			if (reserve_size) memset((unsigned char*)result + output.size(), 0, reserve_size);
			if (size_ptr) *size_ptr = output.size();
			return true;
		}
Esempio n. 4
0
//--------------------------------------------- MEM ALLOC HOOK -----------------------------------------------
void *__stdcall _SMemAlloc(int amount, char *logfilename, int logline, char defaultValue)
{
  /* Call the original function */
  void *rval = nullptr;
  if ( _SMemAllocOld )
    rval = _SMemAllocOld(amount, logfilename, logline, defaultValue);
  else
    rval = SMemAlloc(amount, logfilename, logline, defaultValue);

  if ( isCorrectVersion )
  {
    if ( lastFile == "dlgs\\protoss.grp" || 
         lastFile == "dlgs\\terran.grp"  ||
         lastFile == "dlgs\\zerg.grp" )
    {
      if ( strcmpi(logfilename, ".?AU_DLGGRP@@") == 0 )
      {
        if ( leakUIClassLoc )
          SMFree(leakUIClassLoc);
        leakUIClassLoc = rval;
        BW::BWDATA_customList_UIDlgData[0] = BW::BWDATA_customList_UIDlgData;  // list with custom allocator?
        BW::BWDATA_customList_UIDlgData[1] = (void*)~(u32)BW::BWDATA_customList_UIDlgData;
      }
      else if ( strcmpi(logfilename, "Starcraft\\SWAR\\lang\\game.cpp") == 0 )
      {
        if ( leakUIGrpLoc )
          SMFree(leakUIGrpLoc);
        leakUIGrpLoc = rval;
        BW::BWDATA_customList_UIDlgData[0] = BW::BWDATA_customList_UIDlgData;  // list with custom allocator?
        BW::BWDATA_customList_UIDlgData[1] = (void*)~(u32)BW::BWDATA_customList_UIDlgData;
      }
    }
  } // isCorrectVer

  /* Save the allocated string table pointer */
  if ( lastFile == "rez\\stat_txt.tbl" )
  {
    BW::BWDATA_StringTableOff = (char*)rval;
    lastFile = "";
  }

  /* Save the allocated fog of war pointer */
  if ( amount == 0x40000 && strcmpi(logfilename, "Starcraft\\SWAR\\lang\\Gamemap.cpp") == 0 && logline == 606 )
  {
    BW::BWDATA_ActiveTileArray = (BW::activeTile*)rval;
  }

  /* Save the allocated mini-tile flags pointer */
  if ( lastFile.find(".vf4") != std::string::npos )
  {
    BW::BWDATA_MiniTileFlags = (BW::MiniTileMaps_type*)rval;
    lastFile = "";
  }

  /* Save the allocated SAI_Paths pointer */
  if ( strcmpi(logfilename, "Starcraft\\SWAR\\lang\\sai_PathCreate.cpp") == 0 && logline == 210 )
  {
    BW::BWDATA_SAIPathing = (BW::SAI_Paths*)rval;
  }

  /* Save the allocated tileset pointer */
  if ( lastFile.find(".cv5") != std::string::npos )
  {
    BW::BWDATA_TileSet    = (BW::TileType*)rval;
    lastFile = "";
  }

  /* Save the allocated map tile array pointer */
  if ( amount == 0x20000 && strcmpi(logfilename, "Starcraft\\SWAR\\lang\\Gamemap.cpp") == 0 && logline == 603 )
  {
    BW::BWDATA_MapTileArray = (u16*)rval;
  }

  return rval;
}