Git Product home page Git Product logo

d2mapapi's Introduction

d2mapapi

Diablo II map rest API to retrieve the map layout per area given a map id.

A diablo 2 1.13C installation is required, but the result returned by this API should work for all versions of diablo 2, since the map generation has stayed the same across all verisons.

Note: for 1.09 and lower, higher difficulties do not generate larger maps, hence when interfacing with the API, always use difficulty normal.

Installation

This project assumes you have VS2022 installed with .NET 8.0 and C++ workloads.

Usage Examples

./D2Map.Api.exe Diablo2Directory="C:\Diablo II1.13c"
./D2Map.Api.exe --urls https://localhost:8080 Diablo2Directory="C:\Diablo II1.13c"
./D2Map.Api.exe --urls https://0.0.0.0:8080 Diablo2Directory="C:\Diablo II1.13c"

Note: to run from source use dotnet run or simply start the project from visual studio.

Running in Docker

This requires Docker Desktop

Example Dockerfile:

FROM tianon/wine
ENV WINEARCH=win32
ENV WINEDEBUG=-all
# change this to your Diablo 2 installation
COPY [ "C:\Diablo II1.13c", "/app/game" ]
WORKDIR /app
# d2mapapi should be in the same folder as your dockerfile
COPY ./d2mapapi .
EXPOSE 8080
CMD ["wine", "D2Map.Api.exe", "Diablo2Directory=/app/game", "--urls=https://0.0.0.0:8080"]

Download the latest release

Place the d2mapapi folder the dockerfile in the same folder, and navigate their via command line then run docker build -t d2mapapi .

Once that completes run docker run d2mapapi

API

GET https://localhost:5001/maps?mapid=1053646565&area=BloodMoor&difficulty=Normal

GET https://localhost:5001/maps?mapid=1053646565&area=2&difficulty=0

List Of Areas

d2mapapi's People

Contributors

jcageman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

d2mapapi's Issues

Crashes for a specific seed/difficulty/level

Using v1.1, d2mapapi.exe crashes/terminates when requesting the below information:

Seed: 1445251180
Difficulty: Hell
Level: Durance of Hate Level 1 (id = 100)

This is the whole log

[2022-05-08 17:11:21.604] TRACE: starting server on 127.0.0.1:8080
[2022-05-08 17:11:21.605]  INFO: init accept #0
[2022-05-08 17:11:21.605]  INFO: server started on 127.0.0.1:8080
[2022-05-08 17:11:36.048] TRACE: accept connection from 127.0.0.1:59012 on socket #0
[2022-05-08 17:11:36.050] TRACE: [connection:1] start connection with 127.0.0.1:59012
[2022-05-08 17:11:36.050] TRACE: [connection:1] start waiting for request
[2022-05-08 17:11:36.050] TRACE: [connection:1] continue reading request
[2022-05-08 17:11:36.050] TRACE: [connection:1] received 208 bytes
[2022-05-08 17:11:36.050] TRACE: [connection:1] continue reading request
[2022-05-08 17:11:36.427] TRACE: [connection:1] received 35 bytes
[2022-05-08 17:11:36.427] TRACE: [connection:1] request received (#0): POST /sessions/
[2022-05-08 17:11:36.429] TRACE: [connection:1] append response (#0), flags: { final_parts, connection_keepalive }, write group size: 2
[2022-05-08 17:11:36.429] TRACE: [connection:1] start next write group for response (#0), size: 2
[2022-05-08 17:11:36.429] TRACE: [connection:1] start response (#0): HTTP/1.1 201 Created
[2022-05-08 17:11:36.429] TRACE: [connection:1] sending resp data, buf count: 2, total size: 260
[2022-05-08 17:11:36.429] TRACE: [connection:1] start waiting for request
[2022-05-08 17:11:36.429] TRACE: [connection:1] continue reading request
[2022-05-08 17:11:36.429] TRACE: [connection:1] outgoing data was sent: 260 bytes
[2022-05-08 17:11:36.429] TRACE: [connection:1] finishing current write group
[2022-05-08 17:11:36.429] TRACE: [connection:1] should keep alive
[2022-05-08 17:11:36.429] TRACE: [connection:1] start waiting for request
[2022-05-08 17:11:36.429] TRACE: [connection:1] skip read operation: already running
[2022-05-08 17:11:36.532] TRACE: [connection:1] received 140 bytes
[2022-05-08 17:11:36.532] TRACE: [connection:1] request received (#1): GET /sessions/53bfacc2-7fbb-47ef-8ffe-99ccdd184105/areas/100

Trying to run in docker but I get no output

I've decided to try and run this in a windows based docker container but I am having some trouble, and I wonder if you could help?

Basically I have a local installation of Diablo2 and this is my dockerfile:

FROM mcr.microsoft.com/windows:20H2
LABEL maintainer="[email protected]"
WORKDIR "c:/"
EXPOSE 8080
RUN dism.exe /online /enable-feature /all /featurename:iis-webserver /NoRestart
COPY ["./Diablo2", "c:/Diablo2"]

I build it like this:

docker build -t d2mapcontainer .

and run it like this:

docker run -it -p 8080 d2mapcontainer

and then I navigate to d2mapapi and run it manually:

d2mapapi.exe ../Diablo2

On my local machine I am able to run the mapapi fine and I see this output:

[2021-10-19 10:48:56.218] TRACE: starting server on 127.0.0.1:8080
[2021-10-19 10:48:56.219]  INFO: init accept #0
[2021-10-19 10:48:56.219]  INFO: server started on 127.0.0.1:8080

but when inside the docker container I get NO output

C:\Diablo2\mapstuff>d2mapapi.exe ../Diablo2

so I'm not sure why it isn't working, but I'm guessing my docker image is missing some dependencies? I am currently working on building vcpkg inside Docker to see if installing the dependencies you list in the readme will solve it, but I did not do that on my own system so I am unsure and just wanted to check and see if you had any thoughts as to what could be going wrong

Arguments problem

These arguments dosent work. If i type any of below examples it will fail, if i dont use arguments it will work.

tried many diffrent ways like

d2mapapi.exe "pathtomydiablo2" this will work but dosent have arguments, but the rest i try to change port.

d2mapapi.exe "pathtomydiablo2" "-p 1234" not working
d2mapapi.exe "pathtomydiablo2" -p 1234 not working
d2mapapi.exe "pathtomydiablo2" -p 12342 not working
d2mapapi.exe "pathtomydiablo2" --port=8080 not working
d2mapapi.exe "pathtomydiablo2" "--port=8080" not working
d2mapapi.exe "pathtomydiablo2" --port=8080 not working

any chance list of rooms per level can be added?

i was going to try but i have zero c++ experience... i think you have to loop over the rooms using pRoomNext / pRoomsNear, basically i want the positions and size of all the rooms that make up the level. I think the created output object in the array would just need the PosX,PosY,SizeX,SizeY.

if its possible thanks.

struct Room1 {
   Room1** pRoomsNear;    //0x00
   DWORD _1[3];         //0x04
   Room2* pRoom2;         //0x10
   DWORD _2[3];         //0x14
   CollMap* Coll;         //0x20
   DWORD dwRoomsNear;      //0x24
   DWORD _3[9];         //0x28
   DWORD dwPosX;         //0x4C
   DWORD dwPosY;         //0x50
   DWORD dwSizeX;         //0x54
   DWORD dwSizeY;         //0x58
   DWORD _4[6];         //0x5C
   UnitAny* pUnitFirst;   //0x74
   DWORD _5;            //0x78
   Room1* pRoomNext;      //0x7C
}; 

404 On every request

Hello please let me know what I'm doing wrong.
python:
url = 'http://127.0.0.1:8181/maps'
mapseed = 1063547977 # have tried many
params = {'mapid':mapseed, 'area':area, 'difficulty':difficulty}
ret = requests.get(url, params, timeout=5, proxies={'http':None})

output:
[2022-02-15 14:00:53.528] TRACE: starting server on 127.0.0.1:8181
[2022-02-15 14:00:53.529] INFO: init accept #0
[2022-02-15 14:00:53.529] INFO: server started on 127.0.0.1:8181
[2022-02-15 14:03:33.704] TRACE: accept connection from 127.0.0.1:11633 on socket #0
[2022-02-15 14:03:33.704] TRACE: [connection:2] start connection with 127.0.0.1:11633
[2022-02-15 14:03:33.704] TRACE: [connection:2] start waiting for request
[2022-02-15 14:03:33.704] TRACE: [connection:2] continue reading request
[2022-02-15 14:03:33.704] TRACE: [connection:2] received 190 bytes
[2022-02-15 14:03:33.704] TRACE: [connection:2] request received (#0): GET /maps?mapid=1063547977&area=1&difficulty=2
[2022-02-15 14:03:33.704] TRACE: [connection:2] append response (#0), flags: { final_parts, connection_close }, write group size: 1
[2022-02-15 14:03:33.704] TRACE: [connection:2] start next write group for response (#0), size: 1
[2022-02-15 14:03:33.705] TRACE: [connection:2] start response (#0): HTTP/1.1 404 Not Found
[2022-02-15 14:03:33.705] TRACE: [connection:2] sending resp data with connection-close attribute buf count: 1, total size: 101
[2022-02-15 14:03:33.706] TRACE: [connection:2] outgoing data was sent: 101 bytes
[2022-02-15 14:03:33.706] TRACE: [connection:2] finishing current write group
[2022-02-15 14:03:33.707] TRACE: [connection:2] close
[2022-02-15 14:03:33.707] TRACE: [connection:2] close: close socket
[2022-02-15 14:03:33.707] TRACE: [connection:2] close: timer canceled
[2022-02-15 14:03:33.708] TRACE: [connection:2] close: reset responses data
[2022-02-15 14:03:33.708] TRACE: [connection:2] destructor called

I'm not interested in a piped interface right now; prefer http. Have tried https as in your example, but it just hangs. I know this is working for other programs, but not for mine. What am I doing wrong? Thanks.

Shrines act 3-5

MapApi does not appear to pass object data specifically for shrines in acts 3-5. Any ideas?

Player unit not found

Hello everybody.
Till the patch today. You get the error Player unit not found.

Could you investigate this Problem.

Thx

collisionmap?

i saw the source code contains collision map stuff. how can i take it ?

Exception Unhandled: System.AccessViolationException

Error received upon receiving any GET request.

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Encountered via the release version as well as the self compile (with launchSettings configured).

Call Stack:
[External Code]

D2Map.Core.dll!D2Map.Core.Models.Session.GetMap(D2Map.Core.Models.Area area) Line 28 C#
D2Map.Core.dll!D2Map.Core.MapService.GetCollisionMap(uint mapId, D2Map.Core.Models.Difficulty difficulty, D2Map.Core.Models.Area area) Line 25 C#
D2Map.Api.dll!D2Map.Api.Controllers.MapApiController.Get(D2Map.Api.Controllers.Models.MapParameters parameters) Line 21 C#
[External Code]

is there a argument to change the adress?

is there a argument to change it from localhost to 0.0.0.0? looks like there is not just making sure, i can't figure out how to build this using Linux as i don't have Windows.

host it in a cloud

to host it in a cloud, do i use the public ip address of my vps instead of localhost?

Compiling under Linux?

Hi,

I was trying to compile this app on Linux but ended up hitting walls where it complains about not being able to find windows.h. I tried with dotnet build and also with msbuild but didn't have much success.

It's not immediately clear to me if this app can be compiled directly for Linux but with it working so well under Wine, I wouldn't mind cross-compiling itβ€”I'm just really confused by what I'd need to actually make that work.

The goal here is to build it in Docker.

dll version

Is it possible to put this in an dll to integrate it into a c# webservice?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.