Author Topic: Op2mapperhelper  (Read 2683 times)

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Op2mapperhelper
« on: January 22, 2011, 03:52:43 PM »
Recently I finally wanted to find the infamous "Plymouth Cold War" bug, but about 10 seconds after looking at all these (map_id)s, I lost my interest. Since it's a problem that the mapper is generating hardly readable code, i wrote this simple console application that replaces the map_ids with their enum equivalent. Drop the text file onto the .exe.

example:
Code: [Select]
TethysGame::CreateUnit(x, (map_id)1, LOCATION(90+31, 35-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)1, LOCATION(92+31, 35-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)1, LOCATION(93+31, 36-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)2, LOCATION(88+31, 38-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)2, LOCATION(89+31, 39-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)2, LOCATION(88+31, 39-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)27, LOCATION(97+31, 38-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)13, LOCATION(92+31, 39-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)23, LOCATION(82+31, 39-1), 0, (map_id)59, 0);
TethysGame::CreateUnit(x, (map_id)23, LOCATION(84+31, 40-1), 0, (map_id)59, 0);
TethysGame::CreateUnit(x, (map_id)26, LOCATION(95+31, 41-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)26, LOCATION(97+31, 41-1), 0, (map_id)0, 0);
TethysGame::CreateUnit(x, (map_id)7, LOCATION(79+31, 40-1), 0, (map_id)61, 0);
TethysGame::CreateUnit(x, (map_id)7, LOCATION(83+31, 36-1), 0, (map_id)61, 0);
to
Code: [Select]
TethysGame::CreateUnit(x, mapCargoTruck, LOCATION(90+31, 35-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapCargoTruck, LOCATION(92+31, 35-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapCargoTruck, LOCATION(93+31, 36-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapConVec, LOCATION(88+31, 38-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapConVec, LOCATION(89+31, 39-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapConVec, LOCATION(88+31, 39-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapForum, LOCATION(97+31, 38-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapEvacuationTransport, LOCATION(92+31, 39-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapGuardPost, LOCATION(82+31, 39-1), 0, mapAcidCloud, 0);
TethysGame::CreateUnit(x, mapGuardPost, LOCATION(84+31, 40-1), 0, mapAcidCloud, 0);
TethysGame::CreateUnit(x, mapRareStorage, LOCATION(95+31, 41-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapRareStorage, LOCATION(97+31, 41-1), 0, mapNone, 0);
TethysGame::CreateUnit(x, mapTiger, LOCATION(79+31, 40-1), 0, mapLaser, 0);
TethysGame::CreateUnit(x, mapTiger, LOCATION(83+31, 36-1), 0, mapLaser, 0);
« Last Edit: January 25, 2011, 07:35:15 AM by Flashy »
Praise the mighty light towers!!!

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
Op2mapperhelper
« Reply #1 on: January 22, 2011, 07:32:44 PM »
Hey good idea. Actually, if you post the source, maybe someone can work the conversion right into the mapper?
 

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Op2mapperhelper
« Reply #2 on: January 23, 2011, 02:47:53 PM »
If it helps, there is the reader. Please note that it was intended to be functional, not efficient or such a thing.
Praise the mighty light towers!!!

Offline Zardox Xheonov

  • Sr. Member
  • ****
  • Posts: 274
Op2mapperhelper
« Reply #3 on: February 03, 2011, 12:46:13 PM »
so i take it this is a reader of some sort? meaning it translates the code into easier code to read?

nice peace of work, i'd like to understand what it does just to be sure im not slacking off in my studies.
 
Hit me up on discord, if I am online, you know I'll be gaming.

(Lord Of Pain is no more, I am currently now "Zardox" and have been for awhile on other platforms.)

Offline TH300

  • Hero Member
  • *****
  • Posts: 1404
    • http://op3game.net
Op2mapperhelper
« Reply #4 on: February 03, 2011, 03:13:02 PM »
Quote
so i take it this is a reader of some sort? meaning it translates the code into easier code to read?

nice peace of work, i'd like to understand what it does just to be sure im not slacking off in my studies.
You probably know the op2 map editor (also known as "op2mapper") written by BlackBox. This mapper has some feature that automatically generates code which places units and beacons and similar things that are on the map when the game starts. This code can then be modified and/or compiled into a mission dll. But in order to modify it you have to first understand it and understanding it is hard if it uses numbers instead of names for the units (which is currently the case). Thats why Flashy made this small tool. It converts numbers into names, so that its easier to understand the automatically generated code.

Offline Flashy

  • Sr. Member
  • ****
  • Posts: 391
Op2mapperhelper
« Reply #5 on: February 04, 2011, 07:41:11 AM »
Correct. It just searches a text file for "(map_id)", reads whatever follows as a number (the unit number) and replaces (map_id)<number> with map<unit name>, like (map_id)1 to mapCargoTruck.
Praise the mighty light towers!!!