adventuregamestudio / ags

AGS editor and engine source code
Other
701 stars 160 forks source link

[question] A bird's eye view of AGS Codebase #1300

Closed ericoporto closed 3 years ago

ericoporto commented 3 years ago

ags_bird_eye_view

I have been wanting for a time now to write a little guide, a single page on the wiki here with a quick guide through the ags codebase. In the early days of the AGS source code release I wasn't around but looking around in ags forums it's clear people hacked around a lot their "forks" of the engine/editor, and a lot of these developments were useful for discussion and eventually evolved into things that make into the "main" code - like character facing a direction when changing room or more recently the blendmodes. With this in mind, I wanted to lower a little bit the barrier for people that want to take a shot at the code to fix that one annoying thing, even if for themselves only.

And for helping, my first thing in mind is a graph/drawing that represents a bit of the ags source code, and it can't be daunting, so some things have to be hidden. I also want the graph/drawing to be a bit change resistant, to avoid the need to update it often.

Here's Godot graph approach to this question (for reference) https://docs.godotengine.org/en/stable/development/cpp/introduction_to_godot_development.html#architecture-diagram


also trying to come up with a description for the main directories:

main components

platform specifics

IDE and building

Edit: I noticed now I should probably add an entry on the wiki about docker and continuous integration :/

messengerbag commented 3 years ago

Just wanted to say that as someone who doesn't know the codebase, this does look very helpful to me. In the diagram, I'm curious about "main" and why it's separate from "AC".

ericoporto commented 3 years ago

"AC" means "Adventure Creator", the original 1997 name of AGS. When AGS was opensourced (I think in 2011), all the game logic of the entities was done in a twenty eight thousand lines file called ac.cpp, in the initial refactor it was created a directory called AC and it was split in smaller logical units for "entities in the engine", meaning room objects, characters, inventory items, hotspot logic, ... All this stuff today is inside of this directory, it's mostly things that are far away from metal (except sys_events.cpp). There's no AC namespace and there's nothing that strictly ties these files to each other, so other than some boilerplate in the files I am not sure how to logically tie them together.

"main" on the other hand is the entry point of the engine, so it needs to understand the things at the game "boot", meaning command line parameters, config files and game28.dta (the file that contains the initial state and config of everything, plus the global scripts and dialogs).

I may be explaining things wrong though (lots of AGS history), and I don't know how to neatly note these stuff in the graph - but maybe it's better to add a small note below. 🤔

ivan-mogilko commented 3 years ago

Many things in the project tree are just historical and remains of early refactoring attempt which in retrospect had number of mistakes.

For instance, "AC": the earliest code we've got from CJ contain only several files, and there was a huge ac.cpp around 30k in size, iirc. When splitting it I put most of game logic in "ac" subdir because of that. Later I started picking things out into what seemed to be more logical directory names.

The "game" subdirectory is a relatively recent addition, it contains refactored and tidied up classes and functions from "ac" related to game data. Because these were rewritten almost completely anyway I decided to also put them in an appropriately named directory. I was planning to move everything gradually to "game" as things get refactored, but it kind of halted there for now.

The "Common/core" subdirectory is a very early planning mistake, and imo should have been removed eventually. Some of its contents could go into "util", but not certain about platform and types.h There's even a stream base class (stream_api) which must be deleted later, because it's again a remains of some early idea that did not go as planned.

ericoporto commented 3 years ago

Added info here: https://github.com/adventuregamestudio/ags/wiki/Quick-source-code-introduction