Skip to content

Commit

Permalink
Add net mml distribution from gatherer to improve synchronization bet…
Browse files Browse the repository at this point in the history
…ween players
  • Loading branch information
Kolfering committed Sep 21, 2024
1 parent 93459bc commit 6979a2e
Show file tree
Hide file tree
Showing 35 changed files with 458 additions and 95 deletions.
12 changes: 5 additions & 7 deletions Source_Files/Files/game_wad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,7 @@ bool goto_level(
// LP: doing this here because level-specific MML may specify which level-specific
// textures to load.
ResetLevelScript();
if (!game_is_networked || use_map_file(((game_info*)NetGetGameData())->parent_checksum))
{
RunLevelScript(entry->level_number);
}

#if !defined(DISABLE_NETWORKING)
/* If the game is networked, then I must call the network code to do the right */
/* thing with the map.. */
if(game_is_networked)
Expand All @@ -807,10 +802,13 @@ bool goto_level(
/* then calls process_map_wad on it. Non-server receives the map and then */
/* calls process_map_wad on it. */
success= NetChangeMap(entry);

if (use_map_file(((game_info*)NetGetGameData())->parent_checksum))
RunLevelScript(entry->level_number);
}
else
#endif // !defined(DISABLE_NETWORKING)
else
{
RunLevelScript(entry->level_number);
/* Load it and then rock.. */
load_level_from_map(entry->level_number);
if(error_pending()) success= false;
Expand Down
25 changes: 25 additions & 0 deletions Source_Files/GameWorld/devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,3 +993,28 @@ void parse_mml_control_panels(const InfoTree& root)
}
}
}

void write_net_mml_panels(InfoTree& root)
{
InfoTree panel_root;
panel_root.put_attr("reach", control_panel_settings.ReachDistance);
panel_root.put_attr("horiz", control_panel_settings.ReachHorizontal);
panel_root.put_attr("single_energy", control_panel_settings.SingleEnergy);
panel_root.put_attr("single_energy_rate", control_panel_settings.SingleEnergyRate);
panel_root.put_attr("double_energy", control_panel_settings.DoubleEnergy);
panel_root.put_attr("double_energy_rate", control_panel_settings.DoubleEnergyRate);
panel_root.put_attr("triple_energy", control_panel_settings.TripleEnergy);
panel_root.put_attr("triple_energy_rate", control_panel_settings.TripleEnergyRate);

for (int i = 0; i < NUMBER_OF_CONTROL_PANELS; i++)
{
const auto& panel = control_panel_definitions[i];
InfoTree panel_node;
panel_node.put_attr("index", i);
panel_node.put_attr("type", panel._class);
panel_node.put_attr("item", panel.item);
panel_root.add_child("panel", panel_node);
}

root.add_child("control_panels", panel_root);
}
24 changes: 24 additions & 0 deletions Source_Files/GameWorld/dynamic_limits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ void parse_mml_dynamic_limits(const InfoTree& root)
reallocate_dynamic_limits();
}

void write_net_mml_dynamic_limits(InfoTree& root)
{
InfoTree dynamic_limit_root;

std::vector<std::pair<std::string, int>> dynamic_limits_list =
{
{"objects", _dynamic_limit_objects},
{"monsters", _dynamic_limit_monsters},
{"paths", _dynamic_limit_paths},
{"projectiles", _dynamic_limit_projectiles},
{"effects", _dynamic_limit_effects},
{"local_collision", _dynamic_limit_local_collision},
{"global_collision", _dynamic_limit_global_collision}
};

for (const auto& dynamic_limits_item : dynamic_limits_list)
{
InfoTree dynamic_item_node;
dynamic_item_node.put_attr("value", get_dynamic_limit(dynamic_limits_item.second));
dynamic_limit_root.add_child(dynamic_limits_item.first, dynamic_item_node);
}

root.add_child("dynamic_limits", dynamic_limit_root);
}

// Accessor
uint16 get_dynamic_limit(int which) {
Expand Down
1 change: 1 addition & 0 deletions Source_Files/GameWorld/dynamic_limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum {

class InfoTree;
void parse_mml_dynamic_limits(const InfoTree& root);
void write_net_mml_dynamic_limits(InfoTree& root);
void reset_mml_dynamic_limits();

// Accessor
Expand Down
27 changes: 27 additions & 0 deletions Source_Files/GameWorld/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,3 +884,30 @@ void parse_mml_items(const InfoTree& root)
shape.read_shape(def.base_shape);
}
}


void write_net_mml_items(InfoTree& root)
{
InfoTree items_root;
for (int i = 0; i < NUMBER_OF_DEFINED_ITEMS; i++)
{
const auto& item = item_definitions[i];
InfoTree item_node;
item_node.put_attr("index", i);
item_node.put_attr("maximum", item.maximum_count_per_player);
item_node.put_attr("invalid", item.invalid_environments);
item_node.put_attr("type", item.item_kind);

for (int j = 0; j < NUMBER_OF_GAME_DIFFICULTY_LEVELS; j++)
{
InfoTree difficulty_node;
difficulty_node.put_attr("index", j);
difficulty_node.put_attr("maximum", item.extended_maximum_count[j]);
item_node.add_child("difficulty", difficulty_node);
}

items_root.add_child("item", item_node);
}

root.add_child("items", items_root);
}
1 change: 1 addition & 0 deletions Source_Files/GameWorld/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ void animate_items(void);

class InfoTree;
void parse_mml_items(const InfoTree& root);
void write_net_mml_items(InfoTree& root);
void reset_mml_items();

#endif
Expand Down
26 changes: 26 additions & 0 deletions Source_Files/GameWorld/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,29 @@ void parse_mml_liquids(const InfoTree& root)
}
}
}

void write_net_mml_liquids(InfoTree& root)
{
InfoTree liquid_root;
for (int i = 0; i < NUMBER_OF_MEDIA_TYPES; i++)
{
const auto& media = media_definitions[i];
InfoTree liquid_node;
liquid_node.put_attr("index", i);
liquid_node.put_attr("damage_freq", media.damage_frequency);
liquid_node.write_damage(media.damage);

for (int j = 0; j < NUMBER_OF_MEDIA_DETONATION_TYPES; j++)
{
const auto& effect = media.detonation_effects[j];
InfoTree effect_node;
effect_node.put_attr("type", j);
effect_node.put_attr("which", effect);
liquid_node.add_child("effect", effect_node);
}

liquid_root.add_child("liquid", liquid_node);
}

root.add_child("liquids", liquid_root);
}
1 change: 1 addition & 0 deletions Source_Files/GameWorld/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ uint8 *pack_media_data(uint8 *Stream, media_data* Objects, size_t Count);
class InfoTree;
void parse_mml_liquids(const InfoTree& root);
void reset_mml_liquids();
void write_net_mml_liquids(InfoTree& root);

#endif

32 changes: 32 additions & 0 deletions Source_Files/GameWorld/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3923,6 +3923,24 @@ void reset_mml_damage_kicks()
}
}

void write_net_mml_damage_kicks(InfoTree& root)
{
InfoTree damage_root;
for (int i = 0; i < NUMBER_OF_DAMAGE_TYPES; i++)
{
const auto& damage = damage_kick_definitions[i];
InfoTree damage_node;
damage_node.put_attr("index", i);
damage_node.put_attr("base", damage.base_value);
damage_node.put_attr("mult", damage.delta_vitality_multiplier);
damage_node.put_attr("vertical", damage.is_also_vertical);
damage_node.put_attr("death_action", damage.death_action);
damage_root.add_child("kick", damage_node);
}

root.add_child("damage_kicks", damage_root);
}

void parse_mml_damage_kicks(const InfoTree& root)
{
// back up old values first
Expand Down Expand Up @@ -3965,3 +3983,17 @@ void parse_mml_monsters(const InfoTree& root)
monster_must_be_exterminated[index] = exterminate;
}
}

void write_net_mml_monsters(InfoTree& root)
{
InfoTree monster_root;
for (int i = 0; i < NUMBER_OF_MONSTER_TYPES; i++)
{
InfoTree monster_node;
monster_node.put_attr("index", i);
monster_node.put_attr("must_be_exterminated", monster_must_be_exterminated[i]);
monster_root.add_child("monster", monster_node);
}

root.add_child("monsters", monster_root);
}
2 changes: 2 additions & 0 deletions Source_Files/GameWorld/monsters.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,10 @@ void init_monster_definitions();

class InfoTree;
void parse_mml_damage_kicks(const InfoTree& root);
void write_net_mml_damage_kicks(InfoTree& root);
void reset_mml_damage_kicks();
void parse_mml_monsters(const InfoTree& root);
void write_net_mml_monsters(InfoTree& root);
void reset_mml_monsters();

#endif
16 changes: 16 additions & 0 deletions Source_Files/GameWorld/platforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,3 +1289,19 @@ void parse_mml_platforms(const InfoTree& root)
}
}
}

void write_net_mml_platforms(InfoTree& root)
{
InfoTree platforms_root;
for (int i = 0; i < NUMBER_OF_PLATFORM_TYPES; i++)
{
const auto& platform = platform_definitions[i];
InfoTree platform_node;
platform_node.put_attr("index", i);
platform_node.put_attr("item", platform.key_item_index);
platform_node.write_damage(platform.damage);
platforms_root.add_child("platform", platform_node);
}

root.add_child("platforms", platforms_root);
}
1 change: 1 addition & 0 deletions Source_Files/GameWorld/platforms.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ uint8 *pack_platform_data(uint8 *Stream, platform_data *Objects, size_t Count);

class InfoTree;
void parse_mml_platforms(const InfoTree& root);
void write_net_mml_platforms(InfoTree& root);
void reset_mml_platforms();

#endif
48 changes: 48 additions & 0 deletions Source_Files/GameWorld/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2551,3 +2551,51 @@ void parse_mml_player(const InfoTree& root)
}
}

void write_net_mml_player(InfoTree& root)
{
InfoTree player_root;
player_root.put_attr("energy", player_settings.InitialEnergy);
player_root.put_attr("oxygen", player_settings.InitialOxygen);
player_root.put_attr("stripped", player_settings.StrippedEnergy);
player_root.put_attr("oxygen_deplete", player_settings.OxygenDepletion);
player_root.put_attr("oxygen_replenish", player_settings.OxygenReplenishment);
player_root.put_attr("vulnerability", player_settings.Vulnerability);
player_root.put_attr("guided", player_settings.PlayerShotsGuided);
player_root.put_attr("half_visual_arc", player_settings.PlayerHalfVisualArc);
player_root.put_attr("half_vertical_visual_arc", player_settings.PlayerHalfVertVisualArc);
player_root.put_attr("visual_range", player_settings.PlayerHalfVisualArc);
player_root.put_attr("dark_visual_range", player_settings.PlayerHalfVertVisualArc);
player_root.put_attr("single_energy", player_settings.SingleEnergy);
player_root.put_attr("double_energy", player_settings.DoubleEnergy);
player_root.put_attr("triple_energy", player_settings.TripleEnergy);
player_root.put_attr("can_swim", player_settings.CanSwim);

for (int i = 0; i < NUMBER_OF_PLAYER_INITIAL_ITEMS; i++)
{
InfoTree item_node;
item_node.put_attr("index", i);
item_node.put_attr("type", player_initial_items[i]);
player_root.add_child("item", item_node);
}

InfoTree powerup_assign_node;
powerup_assign_node.put_attr("invincibility", player_powerups.Powerup_Invincibility);
powerup_assign_node.put_attr("invisibility", player_powerups.Powerup_Invisibility);
powerup_assign_node.put_attr("infravision", player_powerups.Powerup_Infravision);
powerup_assign_node.put_attr("extravision", player_powerups.Powerup_Extravision);
powerup_assign_node.put_attr("triple_energy", player_powerups.Powerup_TripleEnergy);
powerup_assign_node.put_attr("double_energy", player_powerups.Powerup_DoubleEnergy);
powerup_assign_node.put_attr("energy", player_powerups.Powerup_Energy);
powerup_assign_node.put_attr("oxygen", player_powerups.Powerup_Oxygen);
player_root.add_child("powerup_assign", powerup_assign_node);

InfoTree powerup_node;
powerup_node.put_attr("invincibility", kINVINCIBILITY_DURATION);
powerup_node.put_attr("invisibility", kINVISIBILITY_DURATION);
powerup_node.put_attr("infravision", kINFRAVISION_DURATION);
powerup_node.put_attr("extravision", kEXTRAVISION_DURATION);
player_root.add_child("powerup", powerup_node);

root.add_child("player", player_root);
}

1 change: 1 addition & 0 deletions Source_Files/GameWorld/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ int get_ticks_since_local_player_in_terminal();

class InfoTree;
void parse_mml_player(const InfoTree& root);
void write_net_mml_player(InfoTree& root);
void reset_mml_player();

#endif
Expand Down
16 changes: 16 additions & 0 deletions Source_Files/GameWorld/scenery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,19 @@ void parse_mml_scenery(const InfoTree& root)

reset_scenery_solidity();
}

void write_net_mml_scenery(InfoTree& root)
{
InfoTree scenery_root;
for (int i = 0; i < NUMBER_OF_SCENERY_DEFINITIONS; i++)
{
const auto& scenery = scenery_definitions[i];
InfoTree scenery_node;
scenery_node.put_attr("index", i);
scenery_node.put_attr("flags", scenery.flags);
scenery_node.put_attr("destruction", scenery.destroyed_effect);
scenery_root.add_child("object", scenery_node);
}

root.add_child("scenery", scenery_root);
}
1 change: 1 addition & 0 deletions Source_Files/GameWorld/scenery.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool get_damaged_scenery_collection(short scenery_type, short& collection);

class InfoTree;
void parse_mml_scenery(const InfoTree& root);
void write_net_mml_scenery(InfoTree& root);
void reset_mml_scenery();

#endif
14 changes: 14 additions & 0 deletions Source_Files/GameWorld/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4580,3 +4580,17 @@ void parse_mml_weapons(const InfoTree& root)
order.read_indexed("weapon", weapon_ordering_array[index], NUMBER_OF_WEAPONS);
}
}

void write_net_mml_weapons(InfoTree& root)
{
InfoTree weapons_root;
for (int i = 0; i < NUMBER_OF_WEAPONS; i++)
{
InfoTree weapon_node;
weapon_node.put_attr("index", i);
weapon_node.put_attr("weapon", weapon_ordering_array[i]);
weapons_root.add_child("order", weapon_node);
}

root.add_child("weapons", weapons_root);
}
1 change: 1 addition & 0 deletions Source_Files/GameWorld/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ size_t get_number_of_weapon_types();

class InfoTree;
void parse_mml_weapons(const InfoTree& root);
void write_net_mml_weapons(InfoTree& root);
void reset_mml_weapons();

#endif
Expand Down
2 changes: 1 addition & 1 deletion Source_Files/Misc/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ static bool make_restored_game_relevant(bool inNetgame, const player_start_data*
// ZZZ: this will get called (eventually) shortly after NetUpdateJoinState() returns netStartingResumeGame
bool join_networked_resume_game()
{
ResetLevelScript();
bool success = true;

// Get the saved-game data
Expand All @@ -695,7 +696,6 @@ bool join_networked_resume_game()
bool found_map = false;
if(success)
{
ResetLevelScript();
uint32 theParentChecksum = theWadHeader.parent_checksum;
found_map = use_map_file(theParentChecksum);

Expand Down
Loading

0 comments on commit 6979a2e

Please sign in to comment.