mevent_server_ish --> mevent_client

This commit is contained in:
PikalaxALT 2019-04-02 14:02:13 -04:00 committed by huderlem
parent d220f876fc
commit d0384ee95e
6 changed files with 96 additions and 96 deletions

View file

@ -3,13 +3,13 @@
#include "mevent_server_helpers.h"
struct mevent_cmd_ish
struct mevent_client_cmd
{
u32 instr;
u32 parameter;
};
struct mevent_srv_ish
struct mevent_client
{
u32 unk_00;
u32 param;
@ -18,16 +18,16 @@ struct mevent_srv_ish
u32 cmdidx;
void * sendBuffer;
void * recvBuffer;
struct mevent_cmd_ish * cmdBuffer;
struct mevent_client_cmd * cmdBuffer;
void * buffer;
struct mevent_srv_sub manager;
u32 unk_4C;
};
void mevent_srv_ish_do_init(u32 arg);
u32 mevent_srv_ish_do_exec(u16 * a0);
void mevent_srv_ish_inc_flag(void);
void * mevent_srv_ish_get_buffer(void);
void mevent_srv_ish_set_param(u32 a0);
void mevent_client_do_init(u32 arg);
u32 mevent_client_do_exec(u16 * a0);
void mevent_client_inc_flag(void);
void * mevent_client_get_buffer(void);
void mevent_client_set_param(u32 a0);
#endif //GUARD_MEVENT_SERVER_ISH_H

View file

@ -61,7 +61,7 @@ SECTIONS {
src/mevent2.o(.text);
src/mevent_801BAAC.o(.text);
src/mevent_server.o(.text);
src/mevent_server_ish.o(.text);
src/mevent_client.o(.text);
src/mevent_server_helpers.o(.text);
src/mevent_news.o(.text);
src/union_room_chat.o(.text);
@ -417,7 +417,7 @@ SECTIONS {
src/mevent2.o(.rodata);
src/mevent_801BAAC.o(.rodata);
src/mevent_server.o(.rodata);
src/mevent_server_ish.o(.rodata);
src/mevent_client.o(.rodata);
src/mevent_scripts.o(.rodata);
src/union_room_chat.o(.rodata);
data/union_room_chat.o(.rodata);

View file

@ -6,55 +6,55 @@
#include "battle_tower.h"
#include "mevent.h"
#include "mystery_event_script.h"
#include "mevent_server_ish.h"
#include "mevent_client.h"
EWRAM_DATA struct mevent_srv_ish * s_mevent_srv_ish_ptr = NULL;
EWRAM_DATA struct mevent_client * s_mevent_client_ptr = NULL;
static void mevent_srv_ish_init(struct mevent_srv_ish *, u32, u32);
static u32 mevent_srv_ish_exec(struct mevent_srv_ish *);
static void mevent_srv_ish_free_resources(struct mevent_srv_ish *);
static void mevent_client_init(struct mevent_client *, u32, u32);
static u32 mevent_client_exec(struct mevent_client *);
static void mevent_client_free_resources(struct mevent_client *);
extern const struct mevent_cmd_ish gUnknown_082F2598[];
extern const struct mevent_client_cmd gUnknown_082F2598[];
void mevent_srv_ish_do_init(u32 arg)
void mevent_client_do_init(u32 arg)
{
s_mevent_srv_ish_ptr = AllocZeroed(sizeof(struct mevent_srv_ish));
mevent_srv_ish_init(s_mevent_srv_ish_ptr, 1, 0);
s_mevent_srv_ish_ptr->unk_4C = arg;
s_mevent_client_ptr = AllocZeroed(sizeof(struct mevent_client));
mevent_client_init(s_mevent_client_ptr, 1, 0);
s_mevent_client_ptr->unk_4C = arg;
}
u32 mevent_srv_ish_do_exec(u16 * a0)
u32 mevent_client_do_exec(u16 * a0)
{
u32 result;
if (s_mevent_srv_ish_ptr == NULL)
if (s_mevent_client_ptr == NULL)
return 6;
result = mevent_srv_ish_exec(s_mevent_srv_ish_ptr);
result = mevent_client_exec(s_mevent_client_ptr);
if (result == 6)
{
*a0 = s_mevent_srv_ish_ptr->param;
mevent_srv_ish_free_resources(s_mevent_srv_ish_ptr);
Free(s_mevent_srv_ish_ptr);
s_mevent_srv_ish_ptr = NULL;
*a0 = s_mevent_client_ptr->param;
mevent_client_free_resources(s_mevent_client_ptr);
Free(s_mevent_client_ptr);
s_mevent_client_ptr = NULL;
}
return result;
}
void mevent_srv_ish_inc_flag(void)
void mevent_client_inc_flag(void)
{
s_mevent_srv_ish_ptr->flag++;
s_mevent_client_ptr->flag++;
}
void * mevent_srv_ish_get_buffer(void)
void * mevent_client_get_buffer(void)
{
return s_mevent_srv_ish_ptr->buffer;
return s_mevent_client_ptr->buffer;
}
void mevent_srv_ish_set_param(u32 a0)
void mevent_client_set_param(u32 a0)
{
s_mevent_srv_ish_ptr->param = a0;
s_mevent_client_ptr->param = a0;
}
static void mevent_srv_ish_init(struct mevent_srv_ish * svr, u32 sendPlayerNo, u32 recvPlayerNo)
static void mevent_client_init(struct mevent_client * svr, u32 sendPlayerNo, u32 recvPlayerNo)
{
svr->unk_00 = 0;
svr->mainseqno = 0;
@ -66,7 +66,7 @@ static void mevent_srv_ish_init(struct mevent_srv_ish * svr, u32 sendPlayerNo, u
mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
}
static void mevent_srv_ish_free_resources(struct mevent_srv_ish * svr)
static void mevent_client_free_resources(struct mevent_client * svr)
{
Free(svr->sendBuffer);
Free(svr->recvBuffer);
@ -74,20 +74,20 @@ static void mevent_srv_ish_free_resources(struct mevent_srv_ish * svr)
Free(svr->buffer);
}
static void mevent_srv_ish_jmp_buffer(struct mevent_srv_ish * svr)
static void mevent_client_jmp_buffer(struct mevent_client * svr)
{
memcpy(svr->cmdBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
svr->cmdidx = 0;
}
static void mevent_srv_ish_send_word(struct mevent_srv_ish * svr, u32 ident, u32 word)
static void mevent_client_send_word(struct mevent_client * svr, u32 ident, u32 word)
{
CpuFill32(0, svr->sendBuffer, ME_SEND_BUF_SIZE);
*(u32 *)svr->sendBuffer = word;
mevent_srv_sub_init_send(&svr->manager, ident, svr->sendBuffer, sizeof(u32));
}
static u32 ish_mainseq_0(struct mevent_srv_ish * svr)
static u32 ish_mainseq_0(struct mevent_client * svr)
{
// init
memcpy(svr->cmdBuffer, gUnknown_082F2598, ME_SEND_BUF_SIZE);
@ -97,14 +97,14 @@ static u32 ish_mainseq_0(struct mevent_srv_ish * svr)
return 0;
}
static u32 ish_mainseq_1(struct mevent_srv_ish * svr)
static u32 ish_mainseq_1(struct mevent_client * svr)
{
// done
return 6;
}
static u32 ish_mainseq_2(struct mevent_srv_ish * svr)
static u32 ish_mainseq_2(struct mevent_client * svr)
{
// do recv
if (mevent_srv_sub_recv(&svr->manager))
@ -115,7 +115,7 @@ static u32 ish_mainseq_2(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_3(struct mevent_srv_ish * svr)
static u32 ish_mainseq_3(struct mevent_client * svr)
{
// do send
if (mevent_srv_sub_send(&svr->manager))
@ -126,10 +126,10 @@ static u32 ish_mainseq_3(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
static u32 ish_mainseq_4(struct mevent_client * svr)
{
// process command
struct mevent_cmd_ish * cmd = &svr->cmdBuffer[svr->cmdidx];
struct mevent_client_cmd * cmd = &svr->cmdBuffer[svr->cmdidx];
++svr->cmdidx;
switch (cmd->instr)
{
@ -155,20 +155,20 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
svr->flag = 0;
break;
case 19:
mevent_srv_ish_send_word(svr, 0x12, GetGameStat(cmd->parameter));
mevent_client_send_word(svr, 0x12, GetGameStat(cmd->parameter));
svr->mainseqno = 3;
svr->flag = 0;
break;
case 6:
if (svr->param == 0)
mevent_srv_ish_jmp_buffer(svr);
mevent_client_jmp_buffer(svr);
break;
case 7:
if (svr->param == 1)
mevent_srv_ish_jmp_buffer(svr);
mevent_client_jmp_buffer(svr);
break;
case 4:
mevent_srv_ish_jmp_buffer(svr);
mevent_client_jmp_buffer(svr);
break;
case 5:
memcpy(svr->buffer, svr->recvBuffer, 0x40);
@ -194,7 +194,7 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
mevent_srv_sub_init_send(&svr->manager, 0x11, svr->sendBuffer, sizeof(struct MEventStruct_Unk1442CC));
break;
case 14:
mevent_srv_ish_send_word(svr, 0x13, svr->param);
mevent_client_send_word(svr, 0x13, svr->param);
break;
case 10:
sub_801B21C(svr->recvBuffer);
@ -203,10 +203,10 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
if (!sub_801B1A4(svr->recvBuffer))
{
sub_801B078(svr->recvBuffer);
mevent_srv_ish_send_word(svr, 0x13, 0);
mevent_client_send_word(svr, 0x13, 0);
}
else
mevent_srv_ish_send_word(svr, 0x13, 1);
mevent_client_send_word(svr, 0x13, 1);
break;
case 15:
svr->mainseqno = 6;
@ -232,7 +232,7 @@ static u32 ish_mainseq_4(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_5(struct mevent_srv_ish * svr)
static u32 ish_mainseq_5(struct mevent_client * svr)
{
// wait flag
if (svr->flag)
@ -243,7 +243,7 @@ static u32 ish_mainseq_5(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_6(struct mevent_srv_ish * svr)
static u32 ish_mainseq_6(struct mevent_client * svr)
{
// ???
switch (svr->flag)
@ -263,7 +263,7 @@ static u32 ish_mainseq_6(struct mevent_srv_ish * svr)
return 1;
}
static u32 ish_mainseq_7(struct mevent_srv_ish * svr)
static u32 ish_mainseq_7(struct mevent_client * svr)
{
// exec arbitrary code
u32 (*func)(u32 *, struct SaveBlock2 *, struct SaveBlock1 *) = (void *)gDecompressionBuffer;
@ -275,9 +275,9 @@ static u32 ish_mainseq_7(struct mevent_srv_ish * svr)
return 1;
}
static u32 mevent_srv_ish_exec(struct mevent_srv_ish * svr)
static u32 mevent_client_exec(struct mevent_client * svr)
{
u32 (*funcs[])(struct mevent_srv_ish *) = {
u32 (*funcs[])(struct mevent_client *) = {
ish_mainseq_0,
ish_mainseq_1,
ish_mainseq_2,

View file

@ -1,38 +1,38 @@
#include "global.h"
#include "mevent_server_ish.h"
#include "mevent_client.h"
#include "mevent_server.h"
const u8 gText_CanceledReadingCard[] = _("Canceled reading\nthe Card.");
const struct mevent_cmd_ish gUnknown_082F2598[] = {
const struct mevent_client_cmd gUnknown_082F2598[] = {
{.instr = 2, .parameter = 16},
{.instr = 4, .parameter = 0}
};
const struct mevent_cmd_ish gUnknown_082F25A8[] = {
const struct mevent_client_cmd gUnknown_082F25A8[] = {
{.instr = 8, .parameter = 0},
{.instr = 3, .parameter = 0},
{.instr = 2, .parameter = 16},
{.instr = 4, .parameter = 0}
};
const struct mevent_cmd_ish gUnknown_082F25C8[] = {
const struct mevent_client_cmd gUnknown_082F25C8[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 10}
};
const struct mevent_cmd_ish gUnknown_082F25D8[] = {
const struct mevent_client_cmd gUnknown_082F25D8[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 11}
};
const struct mevent_cmd_ish gUnknown_082F25E8[] = {
const struct mevent_client_cmd gUnknown_082F25E8[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 0}
};
const struct mevent_cmd_ish gUnknown_082F25F8[] = {
const struct mevent_client_cmd gUnknown_082F25F8[] = {
{.instr = 2, .parameter = 22},
{.instr = 10, .parameter = 0},
{.instr = 2, .parameter = 25},
@ -41,7 +41,7 @@ const struct mevent_cmd_ish gUnknown_082F25F8[] = {
{.instr = 1, .parameter = 2}
};
const struct mevent_cmd_ish gUnknown_082F2628[] = {
const struct mevent_client_cmd gUnknown_082F2628[] = {
{.instr = 2, .parameter = 23},
{.instr = 9, .parameter = 0},
{.instr = 3, .parameter = 0},
@ -49,17 +49,17 @@ const struct mevent_cmd_ish gUnknown_082F2628[] = {
{.instr = 4, .parameter = 0}
};
const struct mevent_cmd_ish gUnknown_082F2650[] = {
const struct mevent_client_cmd gUnknown_082F2650[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 7}
};
const struct mevent_cmd_ish gUnknown_082F2660[] = {
const struct mevent_client_cmd gUnknown_082F2660[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 3}
};
const struct mevent_cmd_ish gUnknown_082F2670[] = {
const struct mevent_client_cmd gUnknown_082F2670[] = {
{.instr = 13, .parameter = 0},
{.instr = 14, .parameter = 0},
{.instr = 3, .parameter = 0},
@ -67,17 +67,17 @@ const struct mevent_cmd_ish gUnknown_082F2670[] = {
{.instr = 4, .parameter = 0}
};
const struct mevent_cmd_ish gUnknown_082F2698[] = {
const struct mevent_client_cmd gUnknown_082F2698[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 9}
};
const struct mevent_cmd_ish gUnknown_082F26A8[] = {
const struct mevent_client_cmd gUnknown_082F26A8[] = {
{.instr = 20, .parameter = 0},
{.instr = 1, .parameter = 5}
};
const struct mevent_cmd_ish gUnknown_082F26B8[] = {
const struct mevent_client_cmd gUnknown_082F26B8[] = {
{.instr = 2, .parameter = 21},
{.instr = 12, .parameter = 0},
{.instr = 20, .parameter = 0},

View file

@ -25,7 +25,7 @@
#include "mevent_801BAAC.h"
#include "save.h"
#include "link.h"
#include "mevent_server_ish.h"
#include "mevent_client.h"
#include "event_data.h"
#include "link_rfu.h"
#include "mevent_news.h"
@ -1269,7 +1269,7 @@ void task00_mystery_gift(u8 taskId)
{
ClearScreenInBg0(TRUE);
data->state = 7;
mevent_srv_ish_do_init(data->IsCardOrNews);
mevent_client_do_init(data->IsCardOrNews);
}
else if (gSpecialVar_Result == 5)
{
@ -1282,7 +1282,7 @@ void task00_mystery_gift(u8 taskId)
data->state = 8;
break;
case 8:
switch (mevent_srv_ish_do_exec(&data->curPromptWindowId))
switch (mevent_client_do_exec(&data->curPromptWindowId))
{
case 6:
task_add_05_task_del_08FA224_when_no_RfuFunc();
@ -1290,8 +1290,8 @@ void task00_mystery_gift(u8 taskId)
data->state = 13;
break;
case 5:
memcpy(data->buffer, mevent_srv_ish_get_buffer(), 0x40);
mevent_srv_ish_inc_flag();
memcpy(data->buffer, mevent_client_get_buffer(), 0x40);
mevent_client_inc_flag();
break;
case 3:
data->state = 10;
@ -1306,29 +1306,29 @@ void task00_mystery_gift(u8 taskId)
}
break;
case 9:
switch ((u32)mevent_message_print_and_prompt_yes_no(&data->textState, &data->curPromptWindowId, FALSE, mevent_srv_ish_get_buffer()))
switch ((u32)mevent_message_print_and_prompt_yes_no(&data->textState, &data->curPromptWindowId, FALSE, mevent_client_get_buffer()))
{
case 0:
mevent_srv_ish_set_param(0);
mevent_srv_ish_inc_flag();
mevent_client_set_param(0);
mevent_client_inc_flag();
data->state = 7;
break;
case 1:
mevent_srv_ish_set_param(1);
mevent_srv_ish_inc_flag();
mevent_client_set_param(1);
mevent_client_inc_flag();
data->state = 7;
break;
case -1u:
mevent_srv_ish_set_param(1);
mevent_srv_ish_inc_flag();
mevent_client_set_param(1);
mevent_client_inc_flag();
data->state = 7;
break;
}
break;
case 10:
if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, mevent_srv_ish_get_buffer()))
if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, mevent_client_get_buffer()))
{
mevent_srv_ish_inc_flag();
mevent_client_inc_flag();
data->state = 7;
}
break;
@ -1342,19 +1342,19 @@ void task00_mystery_gift(u8 taskId)
}
else
{
mevent_srv_ish_set_param(0);
mevent_srv_ish_inc_flag();
mevent_client_set_param(0);
mevent_client_inc_flag();
data->state = 7;
}
break;
case 1:
mevent_srv_ish_set_param(1);
mevent_srv_ish_inc_flag();
mevent_client_set_param(1);
mevent_client_inc_flag();
data->state = 7;
break;
case -1u:
mevent_srv_ish_set_param(1);
mevent_srv_ish_inc_flag();
mevent_client_set_param(1);
mevent_client_inc_flag();
data->state = 7;
break;
}
@ -1363,18 +1363,18 @@ void task00_mystery_gift(u8 taskId)
switch ((u32)mevent_message_print_and_prompt_yes_no(&data->textState, &data->curPromptWindowId, FALSE, gText_HaventReceivedCardsGift))
{
case 0:
mevent_srv_ish_set_param(0);
mevent_srv_ish_inc_flag();
mevent_client_set_param(0);
mevent_client_inc_flag();
data->state = 7;
break;
case 1:
mevent_srv_ish_set_param(1);
mevent_srv_ish_inc_flag();
mevent_client_set_param(1);
mevent_client_inc_flag();
data->state = 7;
break;
case -1u:
mevent_srv_ish_set_param(1);
mevent_srv_ish_inc_flag();
mevent_client_set_param(1);
mevent_client_inc_flag();
data->state = 7;
break;
}

View file

@ -13,7 +13,7 @@
.include "src/mevent2.o"
.include "src/mevent_801BAAC.o"
.include "src/mevent_server.o"
.include "src/mevent_server_ish.o"
.include "src/mevent_client.o"
@ union_room_chat
.align 2