changeset 43:01aa5ddf7dc8

A lot of very minor improvements (deleted some unused variables, and other things like that...)
author thib
date Tue, 24 Mar 2009 19:45:48 +0000
parents 039d813d4cef
children a85cdca1980a
files music2/koedec.cc music2/music.cc music2/nwatowav.cc scn2k/scn2k_cmd.cc scn2k/scn2k_grp.cc scn2k/scn2k_impl.cc scn2k/scn2k_text.cc system/file.cc window/event.cc window/picture.cc
diffstat 10 files changed, 25 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/music2/koedec.cc
+++ b/music2/koedec.cc
@@ -168,7 +168,7 @@ AvgKoeHead::AvgKoeHead(const AvgKoeHead&
 AvgKoeHead::AvgKoeHead(FILE* _s, int _file_number, KoeType _type) {
 	char head[0x20];
 	stream = _s; file_number = _file_number;
-	int offset = ftell(stream);
+	//int offset = ftell(stream);
 	rate = 22050;
 	type = _type;
 	if (stream == 0) return;
--- a/music2/music.cc
+++ b/music2/music.cc
@@ -333,7 +333,6 @@ AvgKoeInfo OpenKoeFile(const char* path)
 }
 
 static SDL_RWops* OpenSDLRW(const char* path) {
-	char cmdline_buf[1024];
 	/* まず wav ファイルを探す */
 	ARCINFO* info = file_searcher.Find(FILESEARCH::WAV,path,".wav");
 	if (info == 0) {
@@ -341,7 +340,6 @@ static SDL_RWops* OpenSDLRW(const char* 
 		if (info == 0) info = file_searcher.Find(FILESEARCH::BGM,path,"nwa");
 		if (info) { // read NWA file
 
-			static char* nwa_buffer = 0;
 			int dummy;
 			FILE* f = info->OpenFile(&dummy);
 			static char* d = 0;
@@ -365,7 +363,6 @@ static SDL_RWops* OpenSDLRW(const char* 
 }
 
 static WAVFILE* OpenWaveFile(const char* path) {
-	char cmdline_buf[1024];
 	/* まず wav ファイルを探す */
 	ARCINFO* info = file_searcher.Find(FILESEARCH::WAV,path,".wav");
 	if (info == 0) info = file_searcher.Find(FILESEARCH::BGM,path,"wav");
--- a/music2/nwatowav.cc
+++ b/music2/nwatowav.cc
@@ -252,7 +252,7 @@ public:
 
 template<class NWAI> void NWADecode(const NWAI& info,const char* data, char* outdata, int datasize, int outdatasize) {
 	int d[2];
-	int i,j;
+	int i;
 	int shift = 0;
 	const char* dataend = data+datasize;
 	/* 最初のデータを読み込む */
--- a/scn2k/scn2k_cmd.cc
+++ b/scn2k/scn2k_cmd.cc
@@ -76,7 +76,7 @@ Flags::Flags(void) {
 
 bool Flags::IsInt(int type) const {
 	int v = type % 26;
-	return v >= 0 && v < 7 || v == 25;
+	return (v >= 0 && v < 7) || v == 25;
 }
 
 int Flags::MaxIndex(int type) const {
@@ -372,7 +372,8 @@ bool Flags::Exec(Cmd& cmd) {
 				string s = cmd.Str(cmd.args[1]);
 				const char* sc = s.c_str();
 				int len = cmd.args[2].value;
-				int i;for (i=0; i<sc[i]!=0 && len != 0; i++, len--) {
+				int i;
+				for (i=0; i < sc[i] && len != 0; i++, len--) {
 					if (sc[i]<0 && sc[i+1]!=0) i++;
 				}
 				s.erase(i); // 全角で len 文字まで切り詰める
@@ -1066,7 +1067,6 @@ int Cmd::GetSwitch(const char*& d) {
 	int i; for (i=0; i<argc; i++) {
 		dprintf("\t");
 		if (*d++ != 0x28) {SetError(); return -1;}
-		int item = -1; // default
 		if (*d != 0x29) {
 			int item = GetExpression(d);
 			if (*d++ != 0x29) {SetError(); return -1;}
@@ -1220,7 +1220,6 @@ void Cmd::GetSelection(const char*& d) {
 	return;
 }
 
-static char* op_str3[11] = { "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", "="};
 void Cmd::GetCmd(Flags& flags_orig, const char*& d ) {
 	if (d == 0) { SetError(); return;}
 	if (cmd_type != CMD_NOP) return;
@@ -1302,7 +1301,7 @@ retry:
 			else if (cmd1 == 1 && cmd2 == 0x15 && cmd3 == 0x28) GetArgsSpecial(0, d);
 			else if (cmd1 == 1 && cmd2 == 4 && (cmd3 == 0x26c || cmd3 == 0x26d || cmd3 == 0x270 || cmd3 == 0x276)) GetArgsSpecial(0, d);
 			else if (cmd1 == 1 && cmd2 == 4 && cmd3 == 0x586) GetArgsSpecial(1, d);
-			else if (cmd1 == 1 && (cmd2 == 0x21 && cmd3 == 0x4b) || (cmd2 == 0x28 && cmd3 == 0x64)) GetArgsSpecial(2,d);
+			else if (cmd1 == 1 && ((cmd2 == 0x21 && cmd3 == 0x4b) || (cmd2 == 0x28 && cmd3 == 0x64))) GetArgsSpecial(2,d);
 			else GetArgs(d);
 			dprintf("\n");
 
@@ -1413,7 +1412,7 @@ int Cmd::GetString(const char*& d) {
 			d++;
 		} else if (quote_flag) {
 			strheap[strend++] = *d++;
-		} else if (stype = StrType(d)) {
+		} else if ((stype = StrType(d))) {
 			strheap[strend++] = *d++;
 			if (stype == 2) strheap[strend++] = *d++;
 		} else break;
--- a/scn2k/scn2k_grp.cc
+++ b/scn2k/scn2k_grp.cc
@@ -306,7 +306,6 @@ void GrpObj::GetSrcGeom(int& width, int&
 			return;
 		}
 		const char* data = info->Read();
-		int srclen = read_little_endian_int(data+5);
 		if (data && *data == 2) { // 画像ファイル内にボタン情報が存在する
 			int srclen = read_little_endian_int(data+5);
 			int i;
@@ -2066,7 +2065,9 @@ 487 / 8047 : unsupported command; 0x23 -
 				// オブジェクトのどの部分を画面に表示するか(クリップ領域)の設定
 				int rx = cmd.args[1].value;
 				int ry = cmd.args[2].value;
-				g.SetClipArea(cmd.args[1].value, cmd.args[2].value, cmd.args[3].value,cmd.args[4].value);
+				int x2 = cmd.args[3].value;
+				int y2 = cmd.args[4].value;
+				g.SetClipArea(rx, ry, x2, y2); //TODO: case when cmd.args.size() == 1
 				cmd.clear();
 			} else if (cmd.cmd3 == 0x40d) { // set digit number
 				g.dig_number = cmd.args[1].value;
--- a/scn2k/scn2k_impl.cc
+++ b/scn2k/scn2k_impl.cc
@@ -311,7 +311,7 @@ if (cmd.cmd1 == 0 && cmd.cmd2 == 1 && cm
 }
 				script = script_start + cmd.args[0].value;
 				if (script < script_start || script >= script_end) {
-					fprintf(stderr,"scn %d pt %d: Cannot jump to %d; fall back to the top\n",scn_number, cmd.args[0].value);
+					fprintf(stderr,"scn %d pt %d: Cannot jump to %d; fall back to the top\n", scn_number, scn_point, cmd.args[0].value);
 					script = script_start;
 				}
 				cmd.clear();
@@ -943,7 +943,7 @@ void Scn2k::LoadSys(void) {
 
 		sprintf(buf, "KEY=%s\n", config.GetParaStr("#REGNAME"));
 		if (strncmp(savedata, buf, strlen(buf)) != 0) {
-			fprintf(stderr,"Invalid header in save file %s: it must be started with \"%s\"\n",buf);
+			fprintf(stderr,"Invalid header in save file %s: it must be started with \"%s\"\n", path.c_str(), buf);
 		} else  {
 			char* config_str = strstr(savedata, "\nCONFIG=");
 			if (config_str) {
@@ -1185,7 +1185,7 @@ void Scn2k::Load(Cmd& cmd) {
 
 	sprintf(buf, "KEY=%s\n", config.GetParaStr("#REGNAME"));
 	if (strncmp(savedata, buf, strlen(buf)) != 0) {
-		fprintf(stderr,"Invalid header in save file %s: it must be started with \"%s\"\n",buf);
+		fprintf(stderr,"Invalid header in save file %s: it must be started with \"%s\"\n", path.c_str(), buf);
 		delete[] savedata;
 		return;
 	}
@@ -1250,7 +1250,6 @@ void Scn2k::SaveImpl(string& save) {
 }
 
 void Scn2k::LoadImpl(const char* save) {
-	char buf[1024];
 	save_scn = 0;
 	save_point = 0;
 	window_title = "";
--- a/scn2k/scn2k_text.cc
+++ b/scn2k/scn2k_text.cc
@@ -767,7 +767,6 @@ External_select:
 
 		int sel_y = 0;
 		for (i=0; i<sel_size; i++) {
-			PicBase* p;
 			/* ボタン作成 */
 			const char* str = cmd.Str(cmd.args[i*2]);
 			int value = cmd.args[i*2+1].value;
@@ -1103,7 +1102,6 @@ 0x7e  fun SetExTimer              <1:Sys
 			}
 			cmd.clear();
 		} else if (cmd.cmd3 == 0x276) { // get time (multi)
-			int j = 0;
 			eprintf("get timer value\n");
 			vector<VarInfo> args = cmd.args;
 			vector<VarInfo>::iterator it = args.begin();
@@ -2000,7 +1998,7 @@ TextWindow::TextWindow(PicContainer& par
 	MakeWaku(*wid->PicNode(), event,waku_no, win_no, use_btn, config, callback);
 }
 void TextImpl::InitWindow(void) {
-	int i,j,k;
+	int i;
 	int w;
 	std::string str;
 
--- a/system/file.cc
+++ b/system/file.cc
@@ -137,7 +137,6 @@ ARCFILE::ARCFILE(char* aname) {
 }
 
 void ARCFILE::Init(void) {
-	int i;
 	if (! arc_atom.empty()) return;
 	if (arcname == 0) return;
 	/* ファイル数を得る */
@@ -265,7 +264,6 @@ char* DIRFILE::SearchFile(const char* fn
 }
 
 void ARCFILE::ListFiles(FILE* out) {
-	int i;
 	Init();
 	if (arc_atom.empty()) return;
 	// list file name...
@@ -377,7 +375,7 @@ int DIRFILE::CheckFileDeal(void) {
 	return flen;
 }
 void DIRFILE::ListupFiles(int fname_len) {
-	DIR* dir; int i;
+	DIR* dir;
 	fname_len *= 2;
 	dir = opendir(arcname);
 	if (dir == 0) { 
@@ -754,7 +752,6 @@ ARCINFO* FILESEARCH::Find(FILETYPE type,
 }
 
 char** FILESEARCH::ListAll(FILETYPE type) {
-	int i;
 	/* とりあえず searcher を初期化 */
 	Find(type, "THIS FILENAME MAY NOT EXIST IN THE FILE SYSTEM !!!");
 	if (searcher[type] == 0) return 0;
@@ -995,7 +992,7 @@ GRPCONV* GRPCONV::AssignConverter(const 
 	/* ファイルの内容に応じたコンバーターを割り当てる */
 	GRPCONV* conv = 0;
 	if (inlen < 10) return 0; /* invalid file */
-	if (conv == 0 && strncmp(inbuf, "PDT10", 5) == 0 || strncmp(inbuf, "PDT11", 5) == 0) { /* PDT10 or PDT11 */
+	if (strncmp(inbuf, "PDT10", 5) == 0 || strncmp(inbuf, "PDT11", 5) == 0) { /* PDT10 or PDT11 */
 		conv = new PDTCONV(inbuf, inlen, fname);
 		if (conv->data == 0) { delete conv; conv = 0;}
 	}
@@ -1493,7 +1490,7 @@ bool G00CONV::Read_Type0(char* image) {
 	const char* srcend = data + datalen;
 	char* dest = uncompress_data;
 	char* dstend = uncompress_data + uncompress_size;
-	while(lzExtract(Extract_DataType_G00Type0(), char(), src, dest, srcend, dstend));
+	while(lzExtract(Extract_DataType_G00Type0(), char(), src, dest, srcend, dstend)){};
 	// image にコピー
 	CopyRGB(image, uncompress_data);
 	delete[] uncompress_data;
@@ -1510,7 +1507,7 @@ bool G00CONV::Read_Type1(char* image) {
 	char* dest = uncompress_data;
 	char* destend = uncompress_data + uncompress_size;
 
-	while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend));
+	while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend)){};
 
 	int colortable[256];
 	memset(colortable, 0, sizeof(int)*256);
@@ -1555,7 +1552,7 @@ bool G00CONV::Read_Type2(char* image) {
 	const char* srcend = data + datalen;
 	char* dest = uncompress_data;
 	char* destend = uncompress_data + uncompress_size;
-	while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend));
+	while(lzExtract(Extract_DataType_SCN2k(), char(), src, dest, srcend, destend)){};
 
 	/* region_deal2 == region_deal のはず……*/
 	int region_deal2 = read_little_endian_int(uncompress_data);
@@ -1757,10 +1754,6 @@ void PNGCONV::png_read(png_structp png_p
 
 #if HAVE_LIBJPEG
 JPEGCONV::JPEGCONV(const char* _inbuf, int _inlen, const char* _filename) {
-	int w,h,type;
-	JSAMPARRAY rows, rows_orig; int i;
-	char* buf = 0;
-
 	struct jpeg_decompress_struct cinfo;
 	struct jpeg_error_mgr jerr;
 	cinfo.err = jpeg_std_error(&jerr);
--- a/window/event.cc
+++ b/window/event.cc
@@ -35,8 +35,8 @@
 
 using namespace std;
 
-extern bool save_req = false, load_req = false, grpdump_req = false; //  scn2k/scn2k_impl.cc: キーボードからセーブ・ロードできるように
-extern bool pressAreq=false,pressFreq=false,pressDreq=false;
+bool save_req = false, load_req = false, grpdump_req = false; //  scn2k/scn2k_impl.cc: キーボードからセーブ・ロードできるように
+bool pressAreq=false,pressFreq=false,pressDreq=false;
 namespace Event {
 /* Impl: struct Event::Video */
 
@@ -532,7 +532,7 @@ bool Container::Exec(unsigned int time) 
 	ret = ret && pimpl_video->Exec();
 	ret = ret && pimpl_time->Exec(time);
 	int i; int mask = 1;
-	int new_button_pressed = pimpl_video->button_pressed;
+
 	for (i=0; i<BUTTON_MAX; i++) {
 		if (pimpl_video->button_released&mask) {
 			button_presscount[i]++;
--- a/window/picture.cc
+++ b/window/picture.cc
@@ -42,7 +42,6 @@
 using namespace std;
 
 int print_blit=0;
-inline void dprintf(const char* fmt, ...) {}
 /* render.cc */
 void DSurfaceBlitAlpha(Surface* src_o, const Rect& srcrect_o, Surface* dst_o, const Rect& dstrect_o, const unsigned char* alpha, const Rect& alpharect);
 void DSurfaceBlitSaturate(Surface* src_o, const Rect& srcrect, Surface* dst_o, const Rect& dstrect, unsigned char alpha);
@@ -958,20 +957,19 @@ inline SDL_Rect SDLed(const Rect& rect) 
 void PicRoot::BlitSurface(Surface* src, const Rect& src_r, const unsigned char* alpha, const Rect& alpha_r, Surface* dest, const Rect& dest_r, int attribute) const {
 if (print_blit) fprintf(stderr," s %08x %d:%d:%d:%d;",src, dest_r.lx, dest_r.ty, dest_r.rx, dest_r.by);
 	SDL_Rect sr = SDLed(src_r); SDL_Rect dr = SDLed(dest_r);
-special_blit:
+
 	if (attribute & PicBase::BLIT_MULTIPLY) {
 if (print_blit) fprintf(stderr,"M");
 		DSurfaceBlitMultiply(src, src_r, dest, dest_r);
 		return;
-	} else if (attribute & PicBase::BLIT_SATURATE) {
-		if (src->format->Amask != 0) goto normal_blit;
+	} else if (attribute & PicBase::BLIT_SATURATE && src->format->Amask == 0) {
 if (print_blit) fprintf(stderr,"S");
 		unsigned char a = 255;
 		if (alpha && alpha_r.width() >= 1 && alpha_r.height() >= 1) a = *alpha;
 		DSurfaceBlitSaturate(src, src_r, dest, dest_r, a);
 		return;
 	}
-normal_blit:
+
 if (print_blit) fprintf(stderr,"N");
 	if (alpha == 0 || alpha_r.width() == 0) { // simple blit
 if (print_blit) fprintf(stderr,"X");