Skip to content

Commit

Permalink
network: client sends protocol version; shrugger glitch
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-programmer committed Jan 29, 2017
1 parent 1b37a14 commit 020fd98
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 86 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Version 0.6.1
- Bugfixes (hence, v0.6 <-> v0.6.1 multiplayer mode is not compatible)
- Bugfixes (note: multiplayer mode is not compatible with v0.6)

Version 0.6
- Added 2 player mode via 3DS local wifi connection
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN_FLAGS :=

VERSION_MAJOR := 0
VERSION_MINOR := 6
VERSION_MICRO := 0
VERSION_MICRO := 1

# 3DS CONFIGURATION #

Expand Down
57 changes: 13 additions & 44 deletions include/network.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#ifndef NETWORK_H
#define NETWORK_H
#include <3ds.h>
#include "level.h"
#include "main_data.h"
#include "control.h"

#define WLAN_ID 0x40F91730
#define WLAN_PASS "Lemmings for 3DS rulez"
#define NETWORK_PROTOCOL_VERSION 1
#define NETWORK_MIN_PROTOCOL_VERSION 1
#define NETWORK_PROTOCOL_VERSION 2
#define NETWORK_MIN_PROTOCOL_VERSION 2

// network messages
#define NW_ERROR 0 // communication error (maybe just cancel connection...; implement handling later)
#define NW_PROTOCOL_VERSION 42
#define NW_INITIALIZE 1 // confirm that the server WILL start the game; params: num of (active) players, num of lemmings per player, player id of receiver
#define NW_LEVEL_INFO 2 // receive level data (first packet: Info. then: Chunks)
#define NW_LEVEL_DATA_CHUNK 3 // send back (with zero length) to confirm receivement
Expand All @@ -30,7 +29,15 @@
#define NETWORK_ERROR_PARSE_LEVEL_ERROR 5
#define NETWORK_ERROR_OUT_OF_MEM 6
#define NETWORK_ERROR_ASYNCHRONOUS 7
#define NETWORK_ERROR_OTHER 8
#define NETWORK_ERROR_NO_2P_LEVELS 8
#define NETWORK_ERROR_OTHER 9

// sent by client on connect (until server confirms receivement)
struct NW_ProtocolVersion {
u8 msg_type;
u8 version_major;
u8 version_minor;
};

struct NW_GameInit {
u8 msg_type;
Expand All @@ -40,6 +47,7 @@ struct NW_GameInit {
u8 lvl_id;
u8 game_id;
u8 glitch_direct_drop;
u8 glitch_shrugger;
u8 timeout; // 2p time limit settings
u8 inspect_level; // inspect level before it starts?
};
Expand Down Expand Up @@ -85,43 +93,4 @@ struct NW_Level_Result {
};

int connection_alive();

int server_prepare_level(
udsBindContext* bindctx,
const u8* lemmings, // number of lemmings the players start with
u8 game_id,
u8 level_id,
struct Level* output);

// important: overwrites settings.glitch_direct_drop.
// therefore the local value has to be stored before this function is called
int client_prepare_level(
udsBindContext* bindctx,
const u8* lemmings, // number of lemmings the players start with
u8* lvl_id,
u8 game_id,
struct Level* output);

int server_run_level(
udsBindContext* bindctx,
struct Level* level,
const char* level_id,
u8* lemmings, // number of lemmings the players have rescued
struct MainMenuData* menu_data,
struct MainInGameData* main_data);
int client_run_level(
udsBindContext* bindctx,
struct Level* level,
const char* level_id,
u8* lemmings,
u16* won,
struct MainMenuData* menu_data,
struct MainInGameData* main_data);

int server_send_result(
udsBindContext* bindctx,
u8 lemmings[2],
u16 won[2]);

#define CHUNK_SIZE (UDS_DATAFRAME_MAXSIZE - sizeof(struct NW_LevelData_Chunk))
#endif
4 changes: 2 additions & 2 deletions include/view_networks.h → include/network_game.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef VIEW_NETWORKS_H
#define VIEW_NETWORKS_H
#ifndef NETWORK_GAME_H
#define NETWORK_GAME_H
#include <3ds.h>
#include "menu.h"
#include "savegame.h"
Expand Down
45 changes: 45 additions & 0 deletions include/network_run_level.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef NETWORK_RUN_LEVEL_H
#define NETWORK_RUN_LEVEL_H
#include <3ds.h>
#include "level.h"
#include "main_data.h"

int server_prepare_level(
udsBindContext* bindctx,
const u8* lemmings, // number of lemmings the players start with
u8 game_id,
u8 level_id,
struct Level* output);

// important: overwrites settings.glitch_direct_drop.
// therefore the local value has to be stored before this function is called
int client_prepare_level(
udsBindContext* bindctx,
const u8* lemmings, // number of lemmings the players start with
u8* lvl_id,
u8 game_id,
struct Level* output);

int server_run_level(
udsBindContext* bindctx,
struct Level* level,
const char* level_id,
u8* lemmings, // number of lemmings the players have rescued
struct MainMenuData* menu_data,
struct MainInGameData* main_data);
int client_run_level(
udsBindContext* bindctx,
struct Level* level,
const char* level_id,
u8* lemmings,
u16* won,
struct MainMenuData* menu_data,
struct MainInGameData* main_data);

int server_send_result(
udsBindContext* bindctx,
u8 lemmings[2],
u16 won[2]);

#define CHUNK_SIZE (UDS_DATAFRAME_MAXSIZE - sizeof(struct NW_LevelData_Chunk))
#endif
5 changes: 3 additions & 2 deletions src/lemming.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,8 +1235,9 @@ int assign_climb(struct Lemming* lem1, struct Lemming* lem2, struct Level* level
lem1->current_action != LEMACTION_EXPLODE) {
lem1->abilities |= LEMABILITY_CLIMB;
if (lem1->current_action == LEMACTION_SHRUG) {
if (settings.glitch_shrugger && level->num_players == 1) {
lem1->current_action = LEMACTION_WALK; // this triggers a bug of the original game since draw_action is not updated
if (settings.glitch_shrugger) {
// this triggers a bug of the original game since draw_action is not updated
lem1->current_action = LEMACTION_WALK;
}else{
set_lemaction(lem1,LEMACTION_WALK);
}
Expand Down
Loading

0 comments on commit 020fd98

Please sign in to comment.