Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

确保变量初始化 #2687

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gframe/CGUITTFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ void CGUITTFont::drawUstring(const core::ustring& utext, const core::rect<s32>&p
core::map<u32, CGUITTGlyphPage*> Render_Map;

// Start parsing characters.
u32 n;
u32 n = 0;
uchar32_t previousChar = 0;
core::ustring::const_iterator iter(utext);
while (!iter.atEnd()) {
Expand Down
16 changes: 8 additions & 8 deletions gframe/client_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void ClientField::Clear() {
tag_teammate_surrender = false;
}
void ClientField::Initial(int player, int deckc, int extrac) {
ClientCard* pcard;
ClientCard* pcard = nullptr;
for(int i = 0; i < deckc; ++i) {
pcard = new ClientCard;
deck[player].push_back(pcard);
Expand Down Expand Up @@ -360,7 +360,7 @@ void ClientField::UpdateFieldCard(int controler, int location, unsigned char* da
}
if(!lst)
return;
int len;
int len = 0;
for(auto cit = lst->begin(); cit != lst->end(); ++cit) {
len = BufferIO::ReadInt32(data);
if(len > LEN_HEADER)
Expand Down Expand Up @@ -438,8 +438,8 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
rnd.shuffle_vector(selectable_cards);
}
}
int startpos;
int ct;
int startpos = 0;
int ct = 0;
if(selectable_cards.size() <= 5) {
startpos = 30 + 125 * (5 - selectable_cards.size()) / 2;
ct = selectable_cards.size();
Expand Down Expand Up @@ -530,8 +530,8 @@ void ClientField::ShowSelectCard(bool buttonok, bool chain) {
mainGame->PopupElement(mainGame->wCardSelect);
}
void ClientField::ShowChainCard() {
int startpos;
int ct;
int startpos = 0;
int ct = 0;
if(selectable_cards.size() <= 5) {
startpos = 30 + 125 * (5 - selectable_cards.size()) / 2;
ct = selectable_cards.size();
Expand Down Expand Up @@ -584,8 +584,8 @@ void ClientField::ShowChainCard() {
mainGame->PopupElement(mainGame->wCardSelect);
}
void ClientField::ShowLocationCard() {
int startpos;
int ct;
int startpos = 0;
int ct = 0;
if(display_cards.size() <= 5) {
startpos = 30 + 125 * (5 - display_cards.size()) / 2;
ct = display_cards.size();
Expand Down
2 changes: 1 addition & 1 deletion gframe/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <windows.h>
#include <ws2tcpip.h>

#ifdef _MSC_VER
#if defined(_MSC_VER) or defined(__MINGW64__)
#define mywcsncasecmp _wcsnicmp
#define mystrncasecmp _strnicmp
#else
Expand Down
4 changes: 2 additions & 2 deletions gframe/deck_con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ void DeckBuilder::GetHoveredCard() {
lx = 12;
if(mainsize > 60)
dy = 66;
int px;
int px = 0;
int py = (y - 164) / dy;
hovered_pos = 1;
if(x >= 750)
Expand All @@ -1248,7 +1248,7 @@ void DeckBuilder::GetHoveredCard() {
}
}
} else if(y >= 164 && y <= 435) {
int lx = 10, px, py = (y - 164) / 68;
int lx = 10, px = 0, py = (y - 164) / 68;
hovered_pos = 1;
if(deckManager.current_deck.main.size() > DECK_MIN_SIZE)
lx = (deckManager.current_deck.main.size() - 41) / 4 + 11;
Expand Down
2 changes: 1 addition & 1 deletion gframe/deck_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ unsigned int DeckManager::CheckDeck(Deck& deck, int lfhash, int rule) {
}
int DeckManager::LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec, bool is_packlist) {
deck.clear();
int code;
int code = 0;
int errorcode = 0;
CardData cd;
for(int i = 0; i < mainc; ++i) {
Expand Down
10 changes: 6 additions & 4 deletions gframe/drawing.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <math.h>

#include "game.h"
#include "client_card.h"
#include "materials.h"
Expand Down Expand Up @@ -220,7 +222,7 @@ void Game::DrawBackGround() {
}
void Game::DrawLinkedZones(ClientCard* pcard) {
auto mark = pcard->link_marker;
ClientCard* pcard2;
ClientCard* pcard2 = nullptr;
if (dField.hovered_sequence < 5) {
if (mark & LINK_MARKER_LEFT && dField.hovered_sequence > 0) {
pcard2 = dField.mzone[dField.hovered_controler][dField.hovered_sequence - 1];
Expand Down Expand Up @@ -601,7 +603,7 @@ void Game::DrawMisc() {
driver->draw2DRectangle(Resize(632, 10, 688, 30), 0x00000000, 0x00000000, 0xffffffff, 0xffffffff);
driver->draw2DRectangle(Resize(632, 30, 688, 50), 0xffffffff, 0xffffffff, 0x00000000, 0x00000000);
DrawShadowText(lpcFont, dataManager.GetNumString(dInfo.turn), Resize(635, 5, 687, 40), Resize(0, 0, 2, 0), 0x8000ffff, 0x80000000, true, false, 0);
ClientCard* pcard;
ClientCard* pcard = nullptr;
for(int i = 0; i < 5; ++i) {
pcard = dField.mzone[0][i];
if(pcard && pcard->code != 0)
Expand Down Expand Up @@ -1195,9 +1197,9 @@ void Game::DrawDeckBd() {
DrawShadowText(numFont, dataManager.GetNumString(mainsize), Resize(380, 138, 440, 158), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
driver->draw2DRectangle(Resize(310, 160, 797, deckBuilder.showing_pack ? 630 : 436), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(309, 159, 797, deckBuilder.showing_pack ? 630 : 436));
int lx;
int lx = 0;
int dy = 68;
float dx;
float dx = NAN;
if(mainsize <= 40) {
dx = 436.0f / 9;
lx = 10;
Expand Down
86 changes: 44 additions & 42 deletions gframe/duelclient.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "config.h"
#include "duelclient.h"

#include <math.h>
#include "client_card.h"
#include "materials.h"
#include "image_manager.h"
Expand Down Expand Up @@ -724,7 +726,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
auto prep = pdata;
Replay new_replay;
std::memcpy(&new_replay.pheader, prep, sizeof(new_replay.pheader));
time_t starttime;
time_t starttime = 0;
if (new_replay.pheader.flag & REPLAY_UNIFORM)
starttime = new_replay.pheader.start_time;
else
Expand Down Expand Up @@ -1299,9 +1301,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
}
case MSG_SELECT_BATTLECMD: {
/*int selecting_player = */BufferIO::ReadUInt8(pbuf);
int desc, count, con, seq/*, diratt*/;
unsigned int code, loc;
ClientCard* pcard;
int desc = 0, count = 0, con = 0, seq = 0/*, diratt*/;
unsigned int code = 0, loc = 0;
ClientCard* pcard = nullptr;
mainGame->dField.activatable_cards.clear();
mainGame->dField.activatable_descs.clear();
mainGame->dField.conti_cards.clear();
Expand Down Expand Up @@ -1364,9 +1366,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
}
case MSG_SELECT_IDLECMD: {
/*int selecting_player = */BufferIO::ReadUInt8(pbuf);
int desc, count, con, seq;
unsigned int code, loc;
ClientCard* pcard;
int desc = 0, count = 0, con = 0, seq = 0;
unsigned int code = 0, loc = 0;
ClientCard* pcard = nullptr;
mainGame->dField.summonable_cards.clear();
count = BufferIO::ReadUInt8(pbuf);
for (int i = 0; i < count; ++i) {
Expand Down Expand Up @@ -1549,15 +1551,15 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
int count = BufferIO::ReadUInt8(pbuf);
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
int c, s, ss;
unsigned int l;
unsigned int code;
int c = 0, s = 0, ss = 0;
unsigned int l = 0;
unsigned int code = 0;
bool panelmode = false;
size_t hand_count[2] = { mainGame->dField.hand[0].size(), mainGame->dField.hand[1].size() };
int select_count_in_hand[2] = { 0, 0 };
bool select_ready = mainGame->dField.select_min == 0;
mainGame->dField.select_ready = select_ready;
ClientCard* pcard;
ClientCard* pcard = nullptr;
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
Expand Down Expand Up @@ -1615,14 +1617,14 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
int count1 = BufferIO::ReadUInt8(pbuf);
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
int c, s, ss;
unsigned int l;
unsigned int code;
int c = 0, s = 0, ss = 0;
unsigned int l = 0;
unsigned int code = 0;
bool panelmode = false;
size_t hand_count[2] = { mainGame->dField.hand[0].size(), mainGame->dField.hand[1].size() };
int select_count_in_hand[2] = { 0, 0 };
mainGame->dField.select_ready = false;
ClientCard* pcard;
ClientCard* pcard = nullptr;
for (int i = 0; i < count1; ++i) {
code = (unsigned int)BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
Expand Down Expand Up @@ -1707,9 +1709,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
int forced = BufferIO::ReadUInt8(pbuf);
/*int hint0 = */BufferIO::ReadInt32(pbuf);
/*int hint1 = */BufferIO::ReadInt32(pbuf);
int c, s, ss, desc;
unsigned int code,l;
ClientCard* pcard;
int c = 0, s = 0, ss = 0, desc = 0;
unsigned int code = 0,l = 0;
ClientCard* pcard = nullptr;
bool panelmode = false;
bool conti_exist = false;
bool select_trigger = (specount == 0x7f);
Expand Down Expand Up @@ -1826,7 +1828,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
if (mainGame->dInfo.curMsg == MSG_SELECT_PLACE && (
(mainGame->chkMAutoPos->isChecked() && mainGame->dField.selectable_field & 0x7f007f) ||
(mainGame->chkSTAutoPos->isChecked() && !(mainGame->dField.selectable_field & 0x7f007f)))) {
unsigned int filter;
unsigned int filter = 0;
if (mainGame->dField.selectable_field & 0x7f) {
respbuf[0] = mainGame->LocalPlayer(0);
respbuf[1] = LOCATION_MZONE;
Expand Down Expand Up @@ -1890,7 +1892,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
SetResponseI(positions);
return true;
}
int count = 0, filter = 0x1, startpos;
int count = 0, filter = 0x1, startpos = 0;
while(filter != 0x10) {
if(positions & filter) count++;
filter <<= 1;
Expand Down Expand Up @@ -1936,9 +1938,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->dField.selectsum_all.clear();
mainGame->dField.selectsum_cards.clear();
mainGame->dField.select_panalmode = false;
int c, s, t;
unsigned int code, l;
ClientCard* pcard;
int c = 0, s = 0, t = 0;
unsigned int code = 0, l = 0;
ClientCard* pcard = nullptr;
mainGame->dField.select_ready = false;
for (int i = 0; i < count; ++i) {
code = (unsigned int)BufferIO::ReadInt32(pbuf);
Expand Down Expand Up @@ -1976,9 +1978,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->dField.select_counter_count = BufferIO::ReadInt16(pbuf);
int count = BufferIO::ReadUInt8(pbuf);
mainGame->dField.selectable_cards.clear();
int c, s, t/*, code*/;
unsigned int l;
ClientCard* pcard;
int c = 0, s = 0, t = 0/*, code*/;
unsigned int l = 0;
ClientCard* pcard = nullptr;
for (int i = 0; i < count; ++i) {
/*code = */BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
Expand Down Expand Up @@ -2046,9 +2048,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
mainGame->dField.selectable_cards.clear();
mainGame->dField.selected_cards.clear();
mainGame->dField.sort_list.clear();
int c, s;
unsigned int code, l;
ClientCard* pcard;
int c = 0, s = 0;
unsigned int code = 0, l = 0;
ClientCard* pcard = nullptr;
for (int i = 0; i < count; ++i) {
code = (unsigned int)BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
Expand All @@ -2069,8 +2071,8 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
case MSG_CONFIRM_DECKTOP: {
int player = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
int count = BufferIO::ReadUInt8(pbuf);
unsigned int code;
ClientCard* pcard;
unsigned int code = 0;
ClientCard* pcard = nullptr;
mainGame->dField.selectable_cards.clear();
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
Expand Down Expand Up @@ -2107,8 +2109,8 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
case MSG_CONFIRM_EXTRATOP: {
int player = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
int count = BufferIO::ReadUInt8(pbuf);
unsigned int code;
ClientCard* pcard;
unsigned int code = 0;
ClientCard* pcard = nullptr;
mainGame->dField.selectable_cards.clear();
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
Expand Down Expand Up @@ -2144,11 +2146,11 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
case MSG_CONFIRM_CARDS: {
/*int player = */mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
int count = BufferIO::ReadUInt8(pbuf);
int c, s;
unsigned int code, l;
int c = 0, s = 0;
unsigned int code = 0, l = 0;
std::vector<ClientCard*> field_confirm;
std::vector<ClientCard*> panel_confirm;
ClientCard* pcard;
ClientCard* pcard = nullptr;
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) {
pbuf += count * 7;
return true;
Expand Down Expand Up @@ -2433,9 +2435,9 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
else
lst = mainGame->dField.szone;
ClientCard* mc[5]{ nullptr };
ClientCard* swp;
int c, s, ps;
unsigned int l;
ClientCard* swp = nullptr;
int c = 0, s = 0, ps = 0;
unsigned int l = 0;
for (int i = 0; i < count; ++i) {
c = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
l = BufferIO::ReadUInt8(pbuf);
Expand Down Expand Up @@ -3116,7 +3118,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
case MSG_DRAW: {
int player = mainGame->LocalPlayer(BufferIO::ReadUInt8(pbuf));
int count = BufferIO::ReadUInt8(pbuf);
ClientCard* pcard;
ClientCard* pcard = nullptr;
for (int i = 0; i < count; ++i) {
unsigned int code = BufferIO::ReadInt32(pbuf);
pcard = mainGame->dField.GetCard(player, LOCATION_DECK, mainGame->dField.deck[player].size() - 1 - i);
Expand Down Expand Up @@ -3417,7 +3419,7 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
BufferIO::ReadUInt8(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true;
float sy;
float sy = NAN;
if (ld != 0) {
soundManager.PlaySoundEffect(SOUND_ATTACK);
mainGame->dField.attack_target = mainGame->dField.GetCard(cd, ld, sd);
Expand Down Expand Up @@ -4092,7 +4094,7 @@ void DuelClient::BeginRefreshHost() {
}
int DuelClient::RefreshThread(event_base* broadev) {
event_base_dispatch(broadev);
evutil_socket_t fd;
evutil_socket_t fd = 0;
event_get_assignment(resp_event, 0, &fd, 0, 0, 0);
evutil_closesocket(fd);
event_free(resp_event);
Expand Down
2 changes: 1 addition & 1 deletion gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
}
if(mplayer != hovered_player) {
if(mplayer >= 0) {
const wchar_t* player_name;
const wchar_t* player_name = nullptr;
if(mplayer == 0) {
if(!mainGame->dInfo.isTag || !mainGame->dInfo.tag_player[0])
player_name = mainGame->dInfo.hostname;
Expand Down
2 changes: 1 addition & 1 deletion gframe/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,7 @@ int Game::OppositePlayer(int player) {
int Game::ChatLocalPlayer(int player) {
if(player > 3)
return player;
bool is_self;
bool is_self = false;
if(dInfo.isStarted || is_siding) {
if(dInfo.isInDuel)
// when in duel
Expand Down
Loading