Merge branch 'issue_#5' of https://gitlab.com/Nemirtingas/goldberg_emulator into inventory_pr
commit
f56503fcd0
@ -0,0 +1,60 @@
|
||||
/* Copyright (C) 2019 Nemirtingas (Maxime P)
|
||||
This file is part of the Goldberg Emulator
|
||||
|
||||
The Goldberg Emulator is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
The Goldberg Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the Goldberg Emulator; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
#include "item_db_loader.h"
|
||||
|
||||
#include <fstream>
|
||||
#include "../json/json.hpp"
|
||||
|
||||
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, std::atomic_bool *is_loadedb)
|
||||
{
|
||||
std::ifstream items_file(items_db);
|
||||
// If there is a file and we opened it
|
||||
if( items_file )
|
||||
{
|
||||
items_file.seekg(0, std::ios::end);
|
||||
size_t size = items_file.tellg();
|
||||
std::string buffer(size, '\0');
|
||||
items_file.seekg(0);
|
||||
// Read it entirely, if the .json file gets too big,
|
||||
// I should look into this and split reads into smaller parts.
|
||||
items_file.read(&buffer[0], size);
|
||||
items_file.close();
|
||||
|
||||
try
|
||||
{
|
||||
std::map<SteamItemDef_t, std::map<std::string, std::string>> tmp;
|
||||
nlohmann::json json = nlohmann::json::parse(buffer);
|
||||
|
||||
for (auto& i : json.items())
|
||||
{
|
||||
SteamItemDef_t key = std::stoi((*i).key());
|
||||
nlohmann::json& value = (*i).value();
|
||||
for (auto& j : value.items())
|
||||
{
|
||||
tmp[key][(*j).key()] = (*j).value();
|
||||
}
|
||||
}
|
||||
|
||||
items->swap(tmp);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
PRINT_DEBUG("Error while parsing json: %s", e.what());
|
||||
}
|
||||
}
|
||||
*is_loadedb = true;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/* Copyright (C) 2019 Nemirtingas (Maxime P)
|
||||
This file is part of the Goldberg Emulator
|
||||
|
||||
The Goldberg Emulator is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
The Goldberg Emulator is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the Goldberg Emulator;*/
|
||||
#ifndef __ITEM_DB_LOADER_INCLUDED__
|
||||
#define __ITEM_DB_LOADER_INCLUDED__
|
||||
|
||||
#include "base.h" // For SteamItemDef_t
|
||||
|
||||
#include <atomic>
|
||||
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, std::atomic_bool *is_loaded);
|
||||
|
||||
#endif//__ITEM_DB_LOADER_INCLUDED__
|
@ -0,0 +1,5 @@
|
||||
#include "steam_inventory.h"
|
||||
|
||||
std::once_flag Steam_Inventory::items_loading;
|
||||
std::atomic_bool Steam_Inventory::items_loaded(false);
|
||||
std::map<SteamItemDef_t, std::map<std::string, std::string>> Steam_Inventory::items;
|
@ -0,0 +1,95 @@
|
||||
{
|
||||
"2001": {
|
||||
"Timestamp": "2018-01-09T19:30:03Z",
|
||||
"modified": "20180109T193003Z",
|
||||
"date_created": "20180109T193003Z",
|
||||
"type": "bundle",
|
||||
"display_type": "Bundle",
|
||||
"name": "Foster Classic Bundle",
|
||||
"bundle": "2011x1;2012x1;3358x1",
|
||||
"description": "Comes with Foster's Classic Suit Uniform (includes 9 skin styles), Classic Tie Accessory (includes 8 skin styles) and Bow Tie Accessory. Not tradeable or marketable.",
|
||||
"background_color": "000000",
|
||||
"icon_url": "http://art.tripwirecdn.com/TestItemIcons/Bundle_ClassicFoster_96.png",
|
||||
"icon_url_large": "http://art.tripwirecdn.com/TestItemIcons/Bundle_ClassicFoster_360.png",
|
||||
"name_color": "7a0000",
|
||||
"tradable": "false",
|
||||
"marketable": "false",
|
||||
"commodity": "false",
|
||||
"drop_interval": "0",
|
||||
"drop_max_per_window": "0",
|
||||
"workshopid": "0",
|
||||
"tw_unique_to_own": "true",
|
||||
"item_quality": "0",
|
||||
"tw_price": "$4.99",
|
||||
"tw_type": "skc",
|
||||
"tw_client_visible": "1",
|
||||
"tw_icon_small": "CHR_MrFoster_Item_TEX.ClassicSuit.UniformBundle_FostersSuit",
|
||||
"tw_icon_large": "CHR_MrFoster_Item_TEX.ClassicSuit.UniformBundle_FostersSuit",
|
||||
"tw_description": "<FosterClassicBundleDescription:Bundles>",
|
||||
"tw_client_name": "<FosterClassicBundleName:Bundles>",
|
||||
"tw_client_type": "<BundleType:Bundles>",
|
||||
"tw_rarity": "crate"
|
||||
},
|
||||
"2002": {
|
||||
"Timestamp": "2018-01-09T19:30:03Z",
|
||||
"modified": "20180109T193003Z",
|
||||
"date_created": "20180109T193003Z",
|
||||
"type": "bundle",
|
||||
"display_type": "Bundle",
|
||||
"name": "Briar's Bobby Bundle",
|
||||
"bundle": "2021x1;2022x1",
|
||||
"description": "Comes with Briar's London Uniform (includes 5 skin styles), and Custodian Helmet Cosmetic Accessory (includes 3 skin styles) Not tradeable or marketable.",
|
||||
"background_color": "000000",
|
||||
"icon_url": "http://art.tripwirecdn.com/TestItemIcons/Bundle_BriarBobby_96.png",
|
||||
"icon_url_large": "http://art.tripwirecdn.com/TestItemIcons/Bundle_BriarBobby_360.png",
|
||||
"name_color": "7a0000",
|
||||
"tradable": "false",
|
||||
"marketable": "false",
|
||||
"commodity": "false",
|
||||
"drop_interval": "0",
|
||||
"drop_max_per_window": "0",
|
||||
"workshopid": "0",
|
||||
"tw_unique_to_own": "true",
|
||||
"item_quality": "0",
|
||||
"tw_price": "$4.99",
|
||||
"tw_type": "skc",
|
||||
"tw_client_visible": "1",
|
||||
"tw_icon_small": "CHR_Briar_Item_TEX.BobbyUniform.UniformBundle_BriarBobby",
|
||||
"tw_icon_large": "CHR_Briar_Item_TEX.BobbyUniform.UniformBundle_BriarBobby",
|
||||
"tw_description": "<BriarsBobbyBundleDescription:Bundles>",
|
||||
"tw_client_name": "<BriarsBobbyBundleName:Bundles>",
|
||||
"tw_client_type": "<BundleType:Bundles>",
|
||||
"tw_rarity": "crate"
|
||||
},
|
||||
"2003": {
|
||||
"Timestamp": "2018-01-09T19:30:03Z",
|
||||
"modified": "20180109T193003Z",
|
||||
"date_created": "20180109T193003Z",
|
||||
"type": "bundle",
|
||||
"display_type": "Bundle",
|
||||
"name": "Tanaka's Biker Bundle",
|
||||
"bundle": "2031x1;2032x1",
|
||||
"description": "Comes with Tanaka's Motorcycle Uniform (includes 7 skin styles) and Helmet Cosmetic Accessory (includes 7 skin styles) Not tradeable or marketable.",
|
||||
"background_color": "000000",
|
||||
"icon_url": "http://art.tripwirecdn.com/TestItemIcons/Bundle_BikerTanaka_96.png",
|
||||
"icon_url_large": "http://art.tripwirecdn.com/TestItemIcons/Bundle_BikerTanaka_360.png",
|
||||
"name_color": "7a0000",
|
||||
"tradable": "false",
|
||||
"marketable": "false",
|
||||
"commodity": "false",
|
||||
"drop_interval": "0",
|
||||
"drop_max_per_window": "0",
|
||||
"workshopid": "0",
|
||||
"tw_unique_to_own": "true",
|
||||
"item_quality": "0",
|
||||
"tw_price": "$4.99",
|
||||
"tw_type": "skc",
|
||||
"tw_client_visible": "1",
|
||||
"tw_icon_small": "CHR_Tanaka_01_Item_TEX.BikerUniform.UniformBundle_TanakaBiker",
|
||||
"tw_icon_large": "CHR_Tanaka_01_Item_TEX.BikerUniform.UniformBundle_TanakaBiker",
|
||||
"tw_description": "<TanakasBikerBundleDescription:Bundles>",
|
||||
"tw_client_name": "<TanakasBikerBundleName:Bundles>",
|
||||
"tw_client_type": "<BundleType:Bundles>",
|
||||
"tw_rarity": "crate"
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue