Crossfire Server, Trunk
|
#include <sys/stat.h>
#include "autoconf.h"
#include "global.h"
#include "compat.h"
#include "assets.h"
#include "AssetsManager.h"
#include "AssetCollector.h"
#include "TreasureLoader.h"
#include "ArchetypeLoader.h"
#include "PngLoader.h"
#include "FacesetLoader.h"
#include "FaceLoader.h"
#include "WrapperLoader.h"
#include "MessageLoader.h"
#include "QuestLoader.h"
#include "ArtifactLoader.h"
#include "Faces.h"
#include <string.h>
#include <string>
#include <set>
#include <unordered_map>
#include <memory>
#include "AssetWriter.h"
#include "TreasureWriter.h"
#include "FaceWriter.h"
#include "AnimationWriter.h"
#include "ArchetypeWriter.h"
#include "MessageWriter.h"
#include "image.h"
#include "FacesetWriter.h"
#include "ArtifactWriter.h"
#include "FormulaeWriter.h"
#include "QuestWriter.h"
#include "microtar.h"
#include "TarLoader.h"
Go to the source code of this file.
Macros | |
#define | MAX_PACK 100 |
Functions | |
static void | add_to_tar (mtar_t *tar, void *data, size_t len, const char *filename) |
void | archetypes_for_each (arch_op op) |
void | assets_collect (const char *datadir, int what) |
void | assets_end_load () |
void | assets_finish_archetypes_for_play () |
void | assets_free () |
void | assets_init () |
size_t | assets_number_of_treasurelists () |
size_t | assets_number_of_treasures () |
void | assets_pack (const char *what, const char *filename) |
static void | build_filename (const char *name, const char *prefix, char *dest, size_t max) |
static void | check_generators (void) |
static void | check_spells (void) |
void | check_summoned (void) |
static void | check_treasurelist (treasure *t, const treasurelist *tl) |
template<class T > | |
static void | do_pack (AssetWriter< T > *writer, AssetsCollection< T > *assets, StringBuffer *buf) |
void | faces_for_each (face_op op) |
Animations * | find_animation (const char *name) |
archetype * | find_archetype (const char *name) |
const Face * | find_face (const char *name) |
face_sets * | find_faceset (int id) |
treasurelist * | find_treasurelist (const char *name) |
const Face * | get_face_by_id (uint16_t id) |
size_t | get_faces_count () |
const GeneralMessage * | get_message_from_identifier (const char *identifier) |
archetype * | get_next_archetype (archetype *current) |
AssetsManager * | getManager () |
static void | pack_artifacts (StringBuffer *buf) |
static void | pack_formulae (StringBuffer *buf) |
static void | pack_images (mtar_t *tar) |
quest_definition * | quest_find_by_code (sstring code) |
void | quest_for_each (quest_op op, void *user) |
quest_definition * | quest_get_by_code (sstring code) |
size_t | quests_count (bool includeSystem) |
Animations * | try_find_animation (const char *name) |
archetype * | try_find_archetype (const char *name) |
const Face * | try_find_face (const char *name, const Face *error) |
Variables | |
static AssetsManager * | manager = nullptr |
size_t | nroftreasures = 0 |
Handles asset collection.
Definition in file assets.cpp.
#define MAX_PACK 100 |
|
static |
Add a file to a .tar file.
tar | where to add the file. |
data | file content. |
len | length of data. |
filename | name in the .tar file. |
Definition at line 382 of file assets.cpp.
References navar-midane_time::data, fatal(), npc_dialog::filename, llevError, LOG(), mtar_header_t::mode, MTAR_ESUCCESS, MTAR_TREG, mtar_write_data(), mtar_write_header(), mtar_header_t::mtime, mtar_header_t::name, SEE_LAST_ERROR, mtar_header_t::size, and mtar_header_t::type.
Referenced by assets_pack(), and pack_images().
void archetypes_for_each | ( | arch_op | op | ) |
Definition at line 301 of file assets.cpp.
References AssetsManager::archetypes(), AssetsCollection< T, Key >::each(), manager, and give::op.
Referenced by cast_create_food(), init_gods(), init_mon_info(), init_skills(), and spellpath_msg().
void assets_collect | ( | const char * | datadir, |
int | what | ||
) |
Collect all assets from the specified directory and all its subdirectories.
datadir | directory to search from. |
what | combination of |
Definition at line 113 of file assets.cpp.
References AssetCollector::addLoader(), AssetsManager::animations(), AssetsManager::archetypes(), ASSETS_ARCHETYPES, ASSETS_ARTIFACTS, ASSETS_ATTACK_MESSAGES, ASSETS_FACES, ASSETS_FACESETS, ASSETS_FORMULAE, ASSETS_MESSAGES, ASSETS_PNG, ASSETS_QUESTS, ASSETS_REGIONS, Settings::assets_tracker, ASSETS_TREASURES, AssetCollector::collect(), AssetsManager::faces(), AssetsManager::facesets(), Settings::hooks, Settings::hooks_count, Settings::hooks_filename, init_attackmess(), init_formulae(), init_regions(), llevInfo, LOG(), manager, AssetsManager::messages(), AssetsManager::quests(), settings, and AssetsManager::treasures().
Referenced by cctk_init_std_archetypes(), command_purge_quest_definitions(), load_assets(), and CREMainWindow::onToolReloadAssets().
void assets_end_load | ( | ) |
Called after collect is complete, to check various things.
Definition at line 227 of file assets.cpp.
References check_formulae(), check_generators(), check_recipes(), check_spells(), check_summoned(), AssetsCollection< T, Key >::each(), guildoracle::list, manager, and AssetsManager::treasures().
Referenced by load_assets().
void assets_finish_archetypes_for_play | ( | ) |
Definition at line 509 of file assets.cpp.
References archininventory::arch, AssetsManager::archetypes(), AssetsCollection< T, Key >::each(), manager, and give::op.
Referenced by command_recollect(), and init_beforeplay().
void assets_free | ( | ) |
Free all assets-related memory.
Definition at line 72 of file assets.cpp.
References manager.
Referenced by free_globals(), and teardown().
void assets_init | ( | ) |
Init assets-related variables.
Definition at line 65 of file assets.cpp.
References manager.
Referenced by cctk_init_std_archetypes(), init_library(), and setup().
size_t assets_number_of_treasurelists | ( | ) |
Definition at line 258 of file assets.cpp.
References AssetsCollection< T, Key >::count(), manager, and AssetsManager::treasures().
Referenced by malloc_info().
size_t assets_number_of_treasures | ( | ) |
Definition at line 255 of file assets.cpp.
References nroftreasures.
Referenced by malloc_info().
void assets_pack | ( | const char * | type, |
const char * | filename | ||
) |
Pack the specified assets in a file.
type | assets type, see actual implementation. |
filename | destination file. |
Definition at line 418 of file assets.cpp.
References add_to_tar(), AssetsManager::animations(), AssetsManager::archetypes(), buf, disinfect::count, navar-midane_time::data, do_pack(), AssetsManager::faces(), AssetsManager::facesets(), fatal(), npc_dialog::filename, llevError, LOG(), manager, MAX_PACK, AssetsManager::messages(), mtar_close(), MTAR_ESUCCESS, mtar_finalize(), mtar_open(), give::name, make_face_from_files::out, pack_artifacts(), pack_formulae(), pack_images(), AssetsManager::quests(), SEE_LAST_ERROR, split(), split_string(), strdup_local, stringbuffer_delete(), stringbuffer_finish(), stringbuffer_length(), stringbuffer_new(), Floor::t, AssetsManager::treasures(), and is_valid_types_gen::type.
Referenced by server_pack_assets().
|
static |
Definition at line 360 of file assets.cpp.
References convert::dest, say::max, give::name, and castle_read::prefix.
Referenced by pack_images().
|
static |
Check all generators have the other_arch set or something in inventory.
Definition at line 154 of file assets.cpp.
References archininventory::arch, AssetsManager::archetypes(), AssetsCollection< T, Key >::each(), fatal(), FLAG_CONTENT_ON_GEN, FLAG_GENERATOR, if(), manager, QUERY_FLAG, and SEE_LAST_ERROR.
Referenced by assets_end_load().
|
static |
This ensures:
Definition at line 198 of file assets.cpp.
References archininventory::arch, AssetsManager::archetypes(), AssetsCollection< T, Key >::each(), llevError, LOG(), manager, and SPELL.
Referenced by assets_end_load().
void check_summoned | ( | void | ) |
This checks all summonable items for move_type and other things. Will call fatal() if an error is found.
Definition at line 181 of file assets.cpp.
References archininventory::arch, AssetsManager::archetypes(), AssetsCollection< T, Key >::each(), manager, SP_SUMMON_GOLEM, and SPELL.
Referenced by assets_end_load().
|
static |
Definition at line 333 of file assets.cpp.
References buf, AssetsCollection< T, Key >::each(), and AssetWriter< T >::write().
Referenced by assets_pack().
void faces_for_each | ( | face_op | op | ) |
Definition at line 297 of file assets.cpp.
References AssetsCollection< T, Key >::each(), AssetsManager::faces(), manager, and give::op.
Animations* find_animation | ( | const char * | name | ) |
Definition at line 274 of file assets.cpp.
References AssetsManager::animations(), AssetsCollection< T, Key >::get(), manager, and give::name.
Referenced by mimic_type_apply(), transport_type_apply(), and while().
archetype* find_archetype | ( | const char * | name | ) |
Definition at line 266 of file assets.cpp.
References AssetsManager::archetypes(), AssetsCollection< T, Key >::get(), manager, and give::name.
Referenced by alchemyTable(), animate_bomb(), apply_builder_window(), apply_map_builder(), can_pay(), cast_raise_dead_spell(), cctk_create_game_object(), change_luck(), CREMapInformationManager::checkItem(), ArtifactPanel::computeMadeViaAlchemy(), RecipeWrapper::displayIcon(), RecipeWrapper::displayName(), drain_specific_stat(), find_enclosed_spot(), find_next_coin(), fix_flesh_item(), init_archetype_pointers(), kill_player_not_permadeath(), kill_player_permadeath(), make_formula_book(), monsterFight(), msgfile_msg(), object_replace_insert_in_map(), op_on_battleground(), pay_from_container(), place_exits(), place_fountain_with_specials(), poison_living(), process_map(), put_in_icecube(), remove_depletion(), restore_player(), save_object_in_sb(), sell_item(), slow_living_by(), START_TEST(), and while().
const Face* find_face | ( | const char * | name | ) |
Definition at line 282 of file assets.cpp.
References AssetsManager::faces(), AssetsCollection< T, Key >::get(), manager, and give::name.
Referenced by MessageLoader::load(), FaceLoader::loadAnimationBlock(), and while().
face_sets* find_faceset | ( | int | id | ) |
Definition at line 328 of file assets.cpp.
References AssetsManager::facesets(), Facesets::findById(), and manager.
Referenced by esrv_send_face(), get_face_fallback(), is_valid_faceset(), main(), process_map(), send_image_sums(), and test_faceset().
const Face* get_face_by_id | ( | uint16_t | id | ) |
Get a face from its unique identifier.
id | face identifier. |
Definition at line 315 of file assets.cpp.
References AssetsManager::faces(), Faces::findById(), and manager.
Referenced by ask_smooth_cmd(), cfapi_system_find_face(), send_face_cmd(), send_image_sums(), and test_faceset().
size_t get_faces_count | ( | ) |
Definition at line 293 of file assets.cpp.
References AssetsCollection< T, Key >::count(), AssetsManager::faces(), and manager.
Referenced by init_connection(), main(), monsterFight(), new_connection(), reset_faces_sent(), send_image_info(), send_image_sums(), START_TEST(), and test_faceset().
const GeneralMessage* get_message_from_identifier | ( | const char * | identifier | ) |
Find the message from its identifier.
identifier | message's identifier. |
Definition at line 324 of file assets.cpp.
References AssetsCollection< T, Key >::find(), manager, and AssetsManager::messages().
Referenced by knowledge_message_detail(), knowledge_message_face(), knowledge_message_summary(), and knowledge_message_validate().
Definition at line 262 of file assets.cpp.
References AssetsManager::archetypes(), replace::current, manager, and AssetsCollection< T, Key >::next().
Referenced by artifact_get_face(), cfapi_archetype_get_property(), and main().
AssetsManager* getManager | ( | ) |
Definition at line 305 of file assets.cpp.
References manager.
Referenced by ArchetypesWrapper::addArchetype(), addArchetypes(), QuestsWrapper::addQuest(), CREResourcesWindow::addQuest(), AllAssets::AllAssets(), ArchetypeWrapper::appearsOnTreasureList(), ArchetypeComboBox::ArchetypeComboBox(), ArchetypesModel::ArchetypesModel(), ResourcesManager::archetypeUse(), ArtifactPanel::artifactChanged(), CREMapInformationManager::browseMaps(), build_class_list_reply(), build_race_list_reply(), MonsterResistances::buildGraph(), cfapi_system_get_archetype_vector(), create_archetype_by_object_name(), CRESubItemQuest::CRESubItemQuest(), TreasureWrapper::displayIcon(), TreasureListWrapper::drop(), TreasureWrapper::drop(), TreasurePanel::dropEvent(), dump_abilities(), dump_all_archetypes(), dump_animations(), dump_faces(), dump_monster_treasure(), dump_spells(), FaceComboBox::FaceComboBox(), fillEvents(), CREMainWindow::fillFacesets(), find_archetype_by_object_name(), find_archetype_by_object_type_name(), finish_races(), get_archetype_by_skill_name(), get_archetype_by_type_subtype(), get_player_archetype(), get_spell_by_name(), CREPixmap::init(), init_library(), isValidArchFlesh(), FaceMakerDialog::makeFaces(), malloc_info(), msgfile_msg(), CREMainWindow::onReportAlchemy(), CREMainWindow::onReportAlchemyGraph(), CREMainWindow::onReportArchetypes(), CREMainWindow::onReportDuplicate(), CREMainWindow::onReportLicenses(), CREMainWindow::onReportPlayer(), CREMainWindow::onReportQuests(), CREMainWindow::onReportSpellDamage(), CREMainWindow::onReportSpells(), CREMainWindow::onReportSummon(), polymorph_item(), polymorph_living(), print_monsters(), QuestComboBox::QuestComboBox(), recipe_find_ingredient_cost(), CRESubItemQuest::selectedQuestChanged(), send_image_info(), send_map_info(), CREPixmap::setFaceset(), ArchetypeWrapper::setRaw(), SoundsDialog::soundType(), spellsTable(), START_TEST(), treasureContains(), TreasureListComboBox::TreasureListComboBox(), RecipePanel::updateItem(), FacesetsPanel::updateItem(), and ArchetypeWrapper::uses().
|
static |
Definition at line 340 of file assets.cpp.
References buf, first_artifactlist, guildoracle::list, and ArtifactWriter::write().
Referenced by assets_pack().
|
static |
Definition at line 351 of file assets.cpp.
References buf, get_formulalist(), guildoracle::list, and FormulaeWriter::write().
Referenced by assets_pack().
|
static |
Pack all client-side images in the specified tar file.
tar | where to pack images. |
Definition at line 405 of file assets.cpp.
References add_to_tar(), build_filename(), AssetsCollection< T, Key >::each(), AssetsManager::faces(), AssetsManager::facesets(), npc_dialog::filename, and manager.
Referenced by assets_pack().
quest_definition* quest_find_by_code | ( | sstring | code | ) |
Find a quest from its code, logging if no matching quest.
code | quest to search. |
Definition at line 519 of file assets.cpp.
References llevError, LOG(), and quest_get_by_code().
Referenced by get_quest_by_number(), quest_display(), quest_get_player_state(), quest_info(), quest_set_state(), and quest_start().
void quest_for_each | ( | quest_op | op, |
void * | user | ||
) |
Iterate over all quests.
op | function to call for each quest. |
user | extra parameter to give the function. |
Definition at line 539 of file assets.cpp.
References AssetsCollection< T, Key >::each(), manager, give::op, item::q, and AssetsManager::quests().
Referenced by dump_quests(), main(), output_quests(), and update_quests().
quest_definition* quest_get_by_code | ( | sstring | code | ) |
Find a quest from its code if it exists.
Definition at line 530 of file assets.cpp.
References AssetsCollection< T, Key >::find(), manager, and AssetsManager::quests().
Referenced by command_quest(), quest_find_by_code(), quest_read_player_data(), and quest_send_initial_states().
size_t quests_count | ( | bool | includeSystem | ) |
Definition at line 543 of file assets.cpp.
References AssetsCollection< T, Key >::count(), manager, AssetsManager::quests(), and Quests::visibleCount().
Animations* try_find_animation | ( | const char * | name | ) |
Definition at line 278 of file assets.cpp.
References AssetsManager::animations(), AssetsCollection< T, Key >::find(), manager, and give::name.
Referenced by add_abilities(), apply_anim_suffix(), apply_changes_to_player(), cfapi_object_set_property(), cfapi_system_find_animation(), move_aura(), object_give_identified_properties(), and write_rune().
archetype* try_find_archetype | ( | const char * | name | ) |
Definition at line 270 of file assets.cpp.
References AssetsManager::archetypes(), AssetsCollection< T, Key >::find(), manager, and give::name.
Referenced by alchemy_object(), annotate_ob(), artifact_describe(), artifact_get_face(), cast_consecrate(), cast_create_missile(), cast_heal(), cfapi_map_find_by_archetype_name(), cfapi_object_create(), cfapi_object_find_archetype_inside(), check_formulae(), check_probe(), check_recipe(), command_create(), create_archetype(), create_player_cmd(), do_artifact(), do_harvest(), do_test(), dump_alchemy(), dump_alchemy_costs(), fix_walls(), get_npc(), knowledge_alchemy_can_use_item(), knowledge_alchemy_detail(), knowledge_alchemy_summary(), knowledge_god_face(), knowledge_monster_detail(), knowledge_monster_face(), knowledge_monster_summary(), knowledge_monster_validate(), magic_wall(), perceive_self(), pick_joined_wall(), place_exits(), put_a_monster(), recipe_get_face(), retrofit_joined_wall(), send_arch_info(), send_class_info(), send_race_info(), and town_portal_destroy_existing().
Definition at line 286 of file assets.cpp.
References report::error(), AssetsManager::faces(), AssetsCollection< T, Key >::find(), is_valid_types_gen::found, manager, and give::name.
Referenced by add_abilities(), cfapi_object_set_property(), cfapi_system_find_face(), fix_flesh_item(), knowledge_process_incremental(), knowledge_send_info(), object_give_identified_properties(), send_account_players(), set_object_face_main(), set_object_face_other(), transport_type_apply(), and write_rune().
|
static |
Definition at line 60 of file assets.cpp.
Referenced by archetypes_for_each(), assets_collect(), assets_end_load(), assets_finish_archetypes_for_play(), assets_free(), assets_init(), assets_number_of_treasurelists(), assets_pack(), check_generators(), check_spells(), check_summoned(), CREMapPanel::CREMapPanel(), CREMessagePanel::CREMessagePanel(), CREPrePostList::CREPrePostList(), faces_for_each(), find_animation(), find_archetype(), find_face(), find_faceset(), find_treasurelist(), get_face_by_id(), get_faces_count(), get_message_from_identifier(), get_next_archetype(), getManager(), operator<<(), operator>>(), pack_images(), PrePostWidget::PrePostWidget(), quest_for_each(), quest_get_by_code(), quests_count(), try_find_animation(), try_find_archetype(), and try_find_face().
size_t nroftreasures = 0 |
Number of treasure items, for malloc info.
Definition at line 80 of file assets.cpp.
Referenced by assets_number_of_treasures(), and TreasureLoader::loadTreasure().