UnknownShadow200 df5e41ebf9 Fix error recreating D3D9 context crash. A big thank you to SpicyCombo for running a debug version of the game for an extended period of time to allow me to track down the cause.
The circumstances that cause this to happen are quite rare, which is why I had great difficulty getting it to occur myself. Approximate steps to cause this error are:
1) Do something that causes the Direct3D9 context to be lost for a long period of time, like running a fullscreen Direct3D9 game
2) Get the texture pack changed in ClassiCube while it's still running in the background (e.g. someone summons you to another map)
3) Now come back to this game
4) Gfx_RecreateContext gets called, triggering each subscriber to the ContextRecreated event
5) One of the first subscribers is the TexturePack component, which reload the texture pack (because of step 2). Sometimes this causes default.png to be changed, which will then cause the Gui to call OnContextRecreated on all the current screens/menus
6) One of the last subscribers is the Gui component, which causes the Gui to call OnContextRecreated on all of the current screens/menus
The problem is that step 5) and 6) means OnContextRecreated is called twice in a row without an OnContextLost, causing some D3D9 resources allocated in step 5) to get leaked, and hence crashing the game later with D3DERR_INVALIDCALL. So the solution is to change Screen_CreateVb to always try deleting the existing vb first before replacing, so that way it doesn't leak
2020-12-09 23:51:21 +11:00
2018-07-18 13:42:55 +10:00
2020-08-12 21:48:19 +10:00

ClassiCube is a custom Minecraft Classic and ClassiCube client written in C that works on Windows, OSX, Linux, BSD, Solaris, Haiku, and in a browser. It is not affiliated with (or supported by) Mojang AB, Minecraft, or Microsoft in any way.

screenshot_n

You can grab the latest stable binaries from here and the very latest builds from here.

What ClassiCube is

  • A complete re-implementation of Minecraft Classic, with optional additions.
  • Lightweight, minimal memory usage compared to the vanilla client.
  • Works with effectively all graphics cards that support OpenGL or Direct3D 9.

It does not work with 'modern/premium' Minecraft servers.

Requirements

  • Windows: 2000 or later. (Windows 98 with KernelEx also technically works)
  • macOS: macOS 10.5 or later. (Can be compiled to work with 10.3/10.4 though)
  • Linux: libcurl and libopenal.

Note: When running from within VirtualBox, disable Mouse Integration, otherwise the camera will not work properly.

Instructions

Initially, you will need to run ClassiCube.exe to download the required assets from minecraft.net. Just click 'OK' to the dialog menu that appears when you start the launcher.

Singleplayer Run ClassiCube.exe, then click Singleplayer at the main menu.

Multiplayer Run ClassiCube.exe. You can connect to LAN/locally hosted servers, minecraft.net servers, and classicube.net servers through the launcher.

Windows specific

If you are stuck using the built-in OpenGL 1.1 software renderer, you can use the MESA software renderer from here for slightly better performance. Typically though, this occurs because you have not installed GPU drivers.

Compiling - Windows

Using Visual Studio

Open ClassiCube.sln and compile it.

If you get a The Windows SDK version 5.1 was not found compilation error, see here for how to fix

Using Visual Studio (command line)
  1. Use 'Developer Tools for Visual Studio' from Start Menu
  2. Navigate to directory with game's source code
  3. Enter cl.exe *.c /link user32.lib gdi32.lib crypt32.lib ws2_32.lib wininet.lib winmm.lib dbghelp.lib d3d9.lib shell32.lib /out:ClassiCube.exe
Using MinGW-w64

I am assuming you used the installer from https://sourceforge.net/projects/mingw-w64/

  1. Install MinGW-W64
  2. Use either Run Terminal from Start Menu or run mingw-w64.bat in the installation folder
  3. Navigate to directory with game's source code
  4. Enter gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9
Using MinGW

I am assuming you used the installer from http://www.mingw.org/

  1. Install MinGW. You need mingw32-base-bin and msys-base-bin packages.
  2. Run msys.bat in the C:\MinGW\msys\1.0 folder.
  3. Navigate to directory with game's source code
  4. Enter gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9

Compiling - Linux

Using gcc/clang

Install appropriate libs as required. For ubuntu these are: libx11-dev, libxi-dev and libgl1-mesa-dev

gcc *.c -o ClassiCube -lm -lpthread -lX11 -lXi -lGL -ldl

Cross compiling for windows:

i686-w64-mingw32-gcc *.c -o ClassiCube.exe -mwindows -lws2_32 -lwininet -lwinmm -limagehlp -lcrypt32 -ld3d9

Raspberry pi

Although the regular linux compiliation flags will work fine, to take full advantage of the hardware:

gcc *.c -o ClassiCube -DCC_BUILD_RPI -lm -lpthread -lX11 -lEGL -lGLESv2 -ldl

Compiling - macOS

Using gcc/clang (32 bit)

cc *.c -o ClassiCube -framework Carbon -framework AGL -framework OpenGL

Using gcc/clang (64 bit)

cc *.c -o ClassiCube -framework Cocoa -framework OpenGL -lobjc

Compiling - other desktop OSes

FreeBSD

clang *.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo

OpenBSD

Install libexecinfo, curl and openal package if needed.

cc *.c -o ClassiCube -I /usr/X11R6/include -I /usr/local/include -L /usr/X11R6/lib -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo

NetBSD

gcc *.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lpthread -lX11 -lXi -lGL -lexecinfo

DragonflyBSD

gcc *.c -o ClassiCube -I /usr/local/include -L /usr/local/lib -lm -lpthread -lX11 -lXi -lGL -lexecinfo

Solaris

gcc *.c -o ClassiCube -lm -lsocket -lX11 -lXi -lGL

NOTE: You have to change entry->d_type == DT_DIR to Directory_Exists(&path) (TODO do this automatically)

Haiku

Install libsdl2_devel, openal_devel, and libexecinfo_devel package if needed.

gcc *.c -o ClassiCube -lm -lexecinfo -lGL -lnetwork -lSDL2

NOTE: You have to change entry->d_type == DT_DIR to Directory_Exists(&path) (TODO do this automatically)

Compiling - other

Web

emcc *.c -s FETCH=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file texpacks/default.zip

The generated javascript file has some issues. See here for how to fix

Other

You'll have to write the necessary code. You should read portability.md in doc folder.

Known compilation errors

Fixes for compilation errors when using musl or old glibc for C standard library

Documentation

Functions and variables in .h files are mostly documented.

Further information (e.g. style) for the game's source code can be found in the doc and misc folders.

Tips

  • Press escape (after joining a world) or pause to switch to the pause menu.

  • Pause menu -> Options -> Controls lists all of the key combinations used by the client.

  • Note that toggling 'vsync' to on will minimise CPU usage, while off will maximimise chunk loading speed.

  • Press F to cycle view distance. A smaller number of visible chunks can improve performance.

  • If the server has disabled hacks, key combinations such as fly and speed will not do anything.

  • To see the list of built in commands, type /client.

  • To see help for a given built in command, type /client help <command name>.

Open source technologies

  • curl - HTTP/HTTPS for linux and macOS
  • FreeType - Font handling for all platforms
  • GCC - Compiles client for linux
  • MinGW-w64 - Compiles client for windows
  • Clang - Compiles client for macOS
  • Emscripten - Compiles client for web
Description
Custom Minecraft Classic / ClassiCube client written in C from scratch (formerly ClassicalSharp in C#)
Readme 59 MiB
Languages
C 95.9%
Assembly 1%
C++ 0.8%
Objective-C 0.7%
Makefile 0.6%
Other 0.7%