Results 1 to 15 of 15

Thread: Puzzle for the day: How to identify in code which map you are on?

  1. #1
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Puzzle for the day: How to identify in code which map you are on?

    Is there some way in code to recognize which map the mission is running on? Say Tobruk vs Cliffs of Dover vs. Volcanic Island or whatever?

    Beyond that, can you determine Summer vs Winter maps for CoD?

    Best I've been able to come up with so far is just set a variable by hand and then change it when moving code to a mission with a different map.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  2. #2
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Good question...

    The only things I can think of are:
    - gameplay.gpBirthPlaces: get all the spawn points and see if one from map A or B are there
    - gameplay.gpLandType: Choose a point in the map where one is, for example, water and the other is land.

  3. #3
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    My solution would be to read it from the .mis file

    SampleMission-v1.0.3 contains the CSectFile module to read that kind of files, the CRadar module contains an example where I read the battle area sector size.

    EDIT [2023-01-16]:

    Current location: https://www.team-fusion-simulations....ns/Multiplayer

    Original (INVALID): https://mega.nz/file/sz51CIxL#IU_Fwj...jgTxkLp8D5gGbE
    Last edited by Artist; Jan-16-2023 at 10:46.

  4. #4
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    That link doesn't open for me, I just get a picture of a cloud
    I am Yo-Yo not YoYo (that's someone else)

  5. #5
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Quote Originally Posted by Yo-Yo View Post
    That link doesn't open for me, I just get a picture of a cloud
    Just checked. Does work. Try with Chrome.

  6. Likes Yo-Yo liked this post
  7. #6
    Supporting Member
    Join Date
    Dec 2019
    Posts
    473
    Post Thanks / Like
    Total Downloaded
    22.61 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Quote Originally Posted by Artist View Post
    Just checked. Does work. Try with Chrome.
    Thanks, chrome works.
    I am Yo-Yo not YoYo (that's someone else)

  8. #7
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Aha, thanks everyone for good and helpful suggestions.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  9. #8
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    FYI just in case it is every helpful to anyone, here is a specific way to get the current map from a mission file:
    Code:
    string filepath_mis = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/1C SoftClub/il-2 sturmovik cliffs of dover/missions/multi/mymissionfolder/mymission.mis";
                  
    ISectionFile main_mis = GamePlay.gpLoadSectionFile(filepath_mis);
    string map_name = "":
    if (main_mis.exist("MAIN", "MAP"))  map_name = main_mis.get("MAIN", "MAP");
    Similar code would get the mission start time ("TIME"), battle area boundaries ("BattleArea"), or anything else in the .mis file.
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  10. #9
    Ace
    Join Date
    May 2015
    Location
    Kansas City, Missouri area
    Posts
    515
    Post Thanks / Like
    Total Downloaded
    130.02 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Quote Originally Posted by Artist View Post
    My solution would be to read it from the .mis file

    SampleMission-v1.0.3 contains the CSectFile module to read that kind of files, the CRadar module contains an example where I read the battle area sector size.

    https://mega.nz/file/sz51CIxL#IU_Fwj...jgTxkLp8D5gGbE
    It looks like this is now located at https://www.team-fusion-simulations....ns/Multiplayer

    If you unzip the SampleMission-vx.x.x.7z file and look in directory "modules" you will find "CSectionFile-v1.0.0.cs".

    (Thanks much to Artist for sharing that!)
    System: Microsoft Windows 10 Pro 64 bit, 10.0.18362 N/A Build 18362, 20,437 MB |
    ASUS GeForce GTX 1060 3GB | Intel Core i5-2500 Quad-Core Processor 3.3 GHz 6 MB Cache LGA 1155 | Intel DB65AL motherboard | ARCTIC Freezer i11 CPU Cooler | SVGA 500 watt power supply | Microsoft Sidewinder 2 Force Feedback joystick

  11. #10
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Quote Originally Posted by TWC_Flug View Post
    Code:
    string filepath_mis = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/1C SoftClub/il-2 sturmovik cliffs of dover/missions/multi/mymissionfolder/mymission.mis";
    Since patch 007 there's a mission property PathMyself, which allows for better portability than the literal "missions/multi/mymissionfolder/mymission.mis":

    Code:
    *** Mission Scripting API: AMission, new property 'string PathMyself'
    Contains the (relative) path/filename to the mission script itself.
    class Mission : AMission {
      ...
      SomeFunc()
      {
        GamePlay.gpLogServer(null, this.PathMyself, new object[] { }); /// output: "missions\server\MyMission\MyMission.cs"
      }
      ...
    }
    Code:
    filepath_mis = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/1C SoftClub/il-2 sturmovik cliffs of dover+"/"+Path.GetDirectoryName(this.PathMyself)+@""+Path.GetFileNameWithoutExtension(this.PathMyself)+".mis"

  12. Likes TWC_Flug liked this post
  13. #11
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    One line.

    string mapName = GamePlay.gpLoadSectionFile(BaseMissionPath + "MyMission.mis").get("MAIN", "MAP");

  14. Likes TWC_Flug liked this post
  15. #12
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,866
    Post Thanks / Like
    Total Downloaded
    319.97 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Quote Originally Posted by ATAG_Oskar View Post
    One line.

    string mapName = GamePlay.gpLoadSectionFile(BaseMissionPath + "MyMission.mis").get("MAIN", "MAP");
    Yeah, but you still need to update the literal whenever you use the code in another mission - or if you rename it.
    ;-)

  16. Likes TWC_Flug liked this post
  17. #13
    Combat pilot
    Join Date
    Oct 2021
    Posts
    113
    Post Thanks / Like
    Total Downloaded
    12.95 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Code:
    private void IdentifyCurrentMap()
        {
            foreach (AiAirport airport in GamePlay.gpAirports())
            {
                if (airport == null) return;
                
                if (airport.Name() == "Heathrow"){
                    DisplayHudMessage("Land$English_Channel");
                    break;
                }
                
                if (airport.Name() == "Airdrome0"){
                    DisplayHudMessage("Land$Online_Isles_of_Doom");
                    break;
                }
                
                if (airport.Name() == "_Airdrome0"){
                    DisplayHudMessage("Land$Online_Volcanic_Island");
                    break;
                }
                
                if (airport.Name() == "Tobruk_Seaplane_Base"){
                    DisplayHudMessage("Land$Tobruk");
                    break;
                }
            }
        }
    I see no differences between the English summer, autumn and winter maps other than the surface. Maybe in the future when temperatures and weather match the season...
    Last edited by GANIX; Jan-17-2023 at 09:32.

  18. Likes TWC_Flug liked this post
  19. #14
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Map temperatures have been updated for the next release.

  20. Likes GANIX, FG28_matkenhaus, TWC_Flug liked this post
  21. #15
    Combat pilot
    Join Date
    Oct 2021
    Posts
    113
    Post Thanks / Like
    Total Downloaded
    12.95 MB

    Re: Puzzle for the day: How to identify in code which map you are on?

    Yes

    Quote Originally Posted by ATAG_Oskar View Post
    Map temperatures have been updated for the next release.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •