Commit 2fbe3c02 authored by nanahira's avatar nanahira

make query_field_info return buffer length

parent e89bd614
......@@ -291,18 +291,22 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
duel* ptduel = (duel*)pduel;
*buf++ = MSG_RELOAD_FIELD;
*buf++ = ptduel->game_field->core.duel_rule;
int32 ct = 0;
for(int playerid = 0; playerid < 2; ++playerid) {
auto& player = ptduel->game_field->player[playerid];
*((int*)(buf)) = player.lp;
buf += 4;
ct += 4;
for(auto cit = player.list_mzone.begin(); cit != player.list_mzone.end(); ++cit) {
card* pcard = *cit;
if(pcard) {
*buf++ = 1;
*buf++ = pcard->current.position;
*buf++ = pcard->xyz_materials.size();
ct += 3;
} else {
*buf++ = 0;
ct++;
}
}
for(auto cit = player.list_szone.begin(); cit != player.list_szone.end(); ++cit) {
......@@ -310,8 +314,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
if(pcard) {
*buf++ = 1;
*buf++ = pcard->current.position;
ct += 2;
} else {
*buf++ = 0;
ct++;
}
}
*buf++ = player.list_main.size();
......@@ -320,8 +326,10 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*buf++ = player.list_remove.size();
*buf++ = player.list_extra.size();
*buf++ = player.extra_p_count;
ct += 6;
}
*buf++ = ptduel->game_field->core.current_chain.size();
ct++;
for(auto chit = ptduel->game_field->core.current_chain.begin(); chit != ptduel->game_field->core.current_chain.end(); ++chit) {
effect* peffect = chit->triggering_effect;
*((int*)(buf)) = peffect->get_handler()->data.code;
......@@ -333,8 +341,9 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*buf++ = chit->triggering_sequence;
*((int*)(buf)) = peffect->description;
buf += 4;
ct += 15;
}
return 0;
return ct;
}
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) {
((duel*)pduel)->set_responsei(value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment