Skip to content

Refactor egs_sheets and ai_sheets into standalone libraries, remove preprocessor hacks#791

Open
Copilot wants to merge 7 commits into
core4from
copilot/refactor-egs-sheets-library
Open

Refactor egs_sheets and ai_sheets into standalone libraries, remove preprocessor hacks#791
Copilot wants to merge 7 commits into
core4from
copilot/refactor-egs-sheets-library

Conversation

Copilot AI commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

The sheets_packer_shard tool couldn't build on Linux because EGS and AI sheets code was entangled with service globals via NO_EGS_VARS and NO_AI_COMP preprocessor guards. This refactors both into clean base classes usable by tools, with service-specific behavior in proper subclasses.

EGS sheets → ryzom_egs_sheets library

  • Extracted egs_sheets/ into a standalone static library under ryzom/server/src/egs_sheets/
  • Replaced extern CVariable<bool> references (LoadOutposts, EGSLight) with static setters on CSheets
  • Replaced hardcoded IService::WriteFilesDirectory with CSheets::setWriteDirectory()
  • Moved EGS-only method implementations (getBaseWeight, selectRandomLootSet, selectRandomCustomLootSet, QuarteringQuantityByVariable) to egs_sheets_egs_impl.cpp in EGS proper

AI sheets → base/subclass split

  • Made CCreature::readGeorges()/serial() virtual, added onScriptComp() hook (no-op in base)
  • CCreatureAI overrides onScriptComp() to create fight script comps via CFightScriptCompReader
  • CSheetsAI overrides packSheets() to load CCreatureAI objects into the base _Sheets map
  • Split ai_script_comp_base.h from ai_script_comp.h so sheets.h doesn't pull in CFightSelectFilter (which has vtable in ai_script_comp.cpp)
// Packer uses base classes directly — no script comp processing needed
AISHEETS::CSheets::getInstance()->packSheets(dir);

// AI service registers its subclass before init
AISHEETS::CSheetsAI::initInstance();
AISHEETS::CSheets::getInstance()->init();  // polymorphic, loads CCreatureAI

Build changes

  • Removed WIN32 gate from sheets_packer_shard (now builds on Linux)
  • Removed NO_EGS_VARS and NO_AI_COMP compile definitions entirely
  • ryzom_egs_sheets library builds under WITH_RYZOM_TOOLS OR WITH_RYZOM_SERVER
Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor egs_sheets to separate library</issue_title>
<issue_description>Original report by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).


Refactor egs_sheets to seperate library for cleaner integration with shard sheets packer tool.

EGS sheets code does not crucially depend on EGS, so should be fairly easy.

There are several trivial dependencies to EGS caused by simple convenience functions which can easily be handled by giving the EGS itself a convenience subclass of the egs_sheets class.

Packed sheets write directory for init function should be passed as parameter preferably, instead of getting this from a function.
</issue_description>

<agent_instructions>We had trouble building the server sheet packing tool on Linux because of this, it's one of the remaining blockers that's keeping the whole gamedata pipeline from working on Linux :)</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@ryzom-pipeline **Original comment by Jan Boon (Bitbucket: [Jan Boon](https://bitbucket.org/Jan Boon), ).**

The dependencies that need to be worked around are marked with NO_EGS_VARS


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…d on Linux

- Create ryzom_egs_sheets library from existing egs_sheets source files with NO_EGS_VARS
- Update sheets_packer_shard to link the new library instead of compiling files directly
- Remove WIN32 restriction from sheets_packer_shard build
- Add egs_sheets library to server/src build when tools or server enabled

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor egs_sheets to separate library for integration Refactor egs_sheets into separate library, enable sheets_packer_shard on Linux Feb 17, 2026
Copilot AI requested a review from kaetemi February 17, 2026 13:28
Copilot AI and others added 2 commits February 17, 2026 14:47
…_impl.cpp

- Replace writeDirectory() conditional compilation with CSheets::setWriteDirectory()
  settable from outside (EGS sets from IService, packer sets from arg)
- Move CStaticItem::getBaseWeight() to egs_sheets_egs_impl.cpp (depends on
  CWeaponCraftParameters)
- Move CStaticLootTable::selectRandomLootSet() and
  selectRandomCustomLootSet() to egs_sheets_egs_impl.cpp (depends on
  RandomGenerator)
- Move QuarteringQuantityByVariable initialization to egs_sheets_egs_impl.cpp
  (depends on EGS CVariable globals)
- Remove all #ifndef NO_EGS_VARS guards from egs_sheets source files
- Remove NO_EGS_VARS from CMakeLists.txt files

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
…QuarteringForcedQuantities linkage

Move QuarteringForcedQuantities definition entirely to egs_sheets_egs_impl.cpp
as static const (no cross-TU linkage needed since it's only used locally).
Remove unused nel/net/service.h and NLNET namespace from egs_sheets_egs_impl.cpp.

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot AI changed the title Refactor egs_sheets into separate library, enable sheets_packer_shard on Linux Refactor egs_sheets: remove NO_EGS_VARS hack, clean library separation Feb 17, 2026
…y and sheets_packer_shard

- Replace extern CVariable<bool> LoadOutposts/EGSLight with CSheets static
  members (setEGSLight/setLoadOutposts), resolving undefined references
- Add resists.cpp to ryzom_egs_sheets library for CCreatureResists symbols
- Fix DNO_AI_COMP -> NO_AI_COMP typo (CMake adds -D prefix automatically)
- Guard registerScriptComp() with #ifndef NO_AI_COMP in ai_service/sheets
- Remove unused EGSLight/LoadOutposts CVariable defs from sheets_packer_shard
- Remove resists.cpp from sheets_packer_shard (now in the library)

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot AI changed the title Refactor egs_sheets: remove NO_EGS_VARS hack, clean library separation Refactor egs_sheets to separate library, remove NO_EGS_VARS hack Feb 17, 2026
- Make CCreature::readGeorges/serial virtual, add onScriptComp() hook
- Create CCreatureAI subclass that overrides onScriptComp to create
  fight script comps (depends on ai_script_comp.cpp)
- Create CSheetsAI subclass that overrides packSheets to load
  CCreatureAI objects instead of plain CCreature
- AI service calls CSheetsAI::initInstance() before CSheets::getInstance()
- Move script comp lists to protected for subclass access
- Remove NO_AI_COMP compile definition from sheets_packer_shard

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot AI changed the title Refactor egs_sheets to separate library, remove NO_EGS_VARS hack Refactor egs_sheets and ai_sheets into clean libraries, remove all preprocessor hacks Feb 17, 2026
…ightSelectFilter vtable dependency

The sheets_packer_shard linker failed with 'undefined reference to vtable
for CFightSelectFilter' because sheets.h included ai_script_comp.h which
declared CFightSelectFilter with virtual methods defined in ai_script_comp.cpp
(not compiled by the packer).

Fix: Extract CFightScriptComp base class into ai_script_comp_base.h.
sheets.h now includes only ai_script_comp_base.h (no CFightSelectFilter).
ai_script_comp.h includes ai_script_comp_base.h for backward compatibility.

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot AI changed the title Refactor egs_sheets and ai_sheets into clean libraries, remove all preprocessor hacks Refactor egs_sheets and ai_sheets into standalone libraries, remove preprocessor hacks Feb 18, 2026
@kaetemi kaetemi marked this pull request as ready for review February 18, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Refactor egs_sheets to separate library

2 participants