Skip to content

Fix Linux Emscripten build: replace gethostbyname + add build_web.sh#3

Draft
sriail with Copilot wants to merge 4 commits into
mainfrom
copilot/update-modern-texture-sheets
Draft

Fix Linux Emscripten build: replace gethostbyname + add build_web.sh#3
sriail with Copilot wants to merge 4 commits into
mainfrom
copilot/update-modern-texture-sheets

Conversation

Copilot AI commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Two linker errors blocked the web-build from compiling on Linux with modern emsdk. Fixes both without touching non-web platform code.

Root causes

  • gethostbyname undefined: Emscripten removed this symbol; two call sites existed inside RAKNET_SUPPORT_IPV6==0 branches of SocketLayer.cpp.
  • emscripten_websocket_send_binary undefined: Caused by adding -sPROXY_POSIX_SOCKETS=1 without linking libwebsockets. Avoided entirely by choosing Option 2 (singleplayer-only for web).

Changes

web-build/src/raknet/SocketLayer.cpp

Replace both gethostbyname usages with getaddrinfo under #ifdef __EMSCRIPTEN__. Non-web builds unaffected.

// DomainNameToIP_Old() and GetMyIP_Win32() — same pattern:
#ifdef __EMSCRIPTEN__
    struct addrinfo hints, *res;
    memset(&hints, 0, sizeof(hints));
    hints.ai_family   = AF_INET;
    hints.ai_socktype = SOCK_DGRAM;
    if (getaddrinfo(domainName, NULL, &hints, &res) != 0 || res == NULL)
        return 0;
    // ... extract addr, freeaddrinfo, return
#else
    struct hostent *phe = gethostbyname(domainName);  // original path
    // ...
#endif

web-build/project/emscripten/build_web.sh (new)

Linux bash equivalent of build_web.ps1:

  • LF line endings, executable
  • --clean: wipes obj/ and out/ before rebuild
  • --serve: runs a Python 3 server with COOP/COEP headers required for SharedArrayBuffer
  • Output to web-build/out/index.{html,js,wasm}
  • No -sPROXY_POSIX_SOCKETS — RakNet UDP multiplayer is not viable in browsers; singleplayer links cleanly
./web-build/project/emscripten/build_web.sh --clean   # full rebuild
./web-build/project/emscripten/build_web.sh --serve   # build + serve localhost:8000

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Copy modern GUI texture sheets from resources/ to web-build/data/images/gui/
  (icons.png, gui.png, gui2.png, spritesheet.png, background.png, bg32.png,
   cursor.png, default_world.png, touchgui.png)
- Rewrite SimpleFoodData with proper hunger mechanics:
  - Food starts full (20), exhaustion drains saturation then food
  - Walking (0.01/block), sprinting (0.1/block), jumping (0.2), sprint-jump (0.8)
  - Full hunger (>=18) with saturation heals 1HP every 80 ticks
  - Empty hunger damages 1HP every 80 ticks, stops at half a heart
- Add renderHunger() to Gui.cpp drawing food icons on right side of screen

Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Copilot AI changed the title [WIP] Update modern texture sheets and food system Add modern GUI textures and traditional hunger bar system Mar 10, 2026
- Copy 405 individual block PNGs/TGAs from resources/ into
  web-build/data/images/textures/blocks/
- Add web-build/tools/build_terrain_atlas.py: stitches individual
  block textures into a 256×256 terrain.png matching the MCPE 0.6.2
  UV-grid (16×16 tiles of 16px each, slot = col + row*16)
- Rebuild terrain.png from modern textures (99 slots populated)
- Remove stale terrain.pvr, terrain.pvr4, terrain.pvrtc, and
  terrain_4444.h / terrain_5551.h / terrain_565.h / terrain_565_2.h

Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Copilot AI changed the title Add modern GUI textures and traditional hunger bar system Migrate terrain atlas to modern block textures + add hunger bar system Mar 11, 2026
- web-build/src/raknet/SocketLayer.cpp: replace gethostbyname with
  getaddrinfo under #ifdef __EMSCRIPTEN__ in two places:
  DomainNameToIP_Old() and GetMyIP_Win32(). Non-web builds unchanged.
- web-build/project/emscripten/build_web.sh: new Linux bash build
  script mirroring build_web.ps1; LF line endings, --clean and
  --serve modes, COOP/COEP server, output to web-build/out/

Co-authored-by: sriail <225764385+sriail@users.noreply.github.com>
Copilot AI changed the title Migrate terrain atlas to modern block textures + add hunger bar system Fix Linux Emscripten build: replace gethostbyname + add build_web.sh Mar 13, 2026
Copilot AI requested a review from sriail March 13, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants