Open, human-readable minesweeper video format

Area to discuss development and bugs of official clones (Clone, Arbiter, MSX, Viennasweeper)
crazyks
Posts: 4
Joined: Wed Jan 08, 2014 4:16 pm

Re: Open, human-readable minesweeper video format

Post by crazyks » Fri Apr 18, 2014 1:55 am

Hi, there is also 2 bugs in rawvf2rawvf.c, function valeq.

Code: Select all

int valeq(const char *val, const char* str)
{
	int i=0;
	while(val[i++]==' ');
	while(str[i] && val[i]!='\n' && val[i]!=' ' && val[i] && tolower(str[i])==tolower(val[i])) ++i;
	return (val[i]=='\n' || val[i]==' ') && str[i]==0;
}
Bug #1.
The index "i" is increased incorrectly. eg, if val is " Beginner", for your purpose, after "while(val[i++]==' ');" the "i" should be 1 and val is 'B'. However, you increase i in the "[]", so when it gets out of "while", the "i" will be 2. It's wrong.

Bug #2.
The index of str should always starts from 0, not the same with i. eg, if val is " Beginner" and str is "beginner", after "while(val[i++]==' ');", the index "i" will be increased, so in the next line "tolower(str)==tolower(val)" will always be FALSE! So I fixed this function like the following:

Code: Select all

int valeq(const char *val, const char* str)
{
	int i=0, j=0;
	while(val[i]==' ') i++;
	while(str[j] && val[i]!='\n' && val[i]!=' ' && val[i] && tolower(str[j])==tolower(val[i])) ++i,++j;
	return (val[i]=='\n' || val[i]==' ') && str[j]==0;
}
The attached is my edited version.
Attachments
rawvf2rawvf.zip
function valeq fixed
(47.02 KiB) Downloaded 241 times

Cryslon
Posts: 122
Joined: Sun Dec 28, 2008 7:41 pm

Re: Open, human-readable minesweeper video format

Post by Cryslon » Sun Apr 27, 2014 1:52 pm

crazyks wrote:Hi, there is also bugs in rawvf2rawvf.c
Indeed, silly me. Nice job, crazyks.

May i ask, what are you using this program for?
Go IRC! (try mibbit)

crazyks
Posts: 4
Joined: Wed Jan 08, 2014 4:16 pm

Re: Open, human-readable minesweeper video format

Post by crazyks » Tue Apr 29, 2014 10:36 am

Cryslon wrote:
crazyks wrote:Hi, there is also bugs in rawvf2rawvf.c
Indeed, silly me. Nice job, crazyks.

May i ask, what are you using this program for?
Hi Cryslon, I wrote a program to do some statistic & analysis jobs for all the videos, which is based on your rawvf project. Do you want a try? The program is attached.

BTW, I'm also trying to write a minesweeper game. however, I don't have much knowledge of C++, everything to me is new. I doubt that It would take me many many nights of the following months. :)
Attachments
MSVideoAnalyzer_V1.0.zip
Minesweeper Video Analyzer V1.0
(1.46 MiB) Downloaded 269 times

Cryslon
Posts: 122
Joined: Sun Dec 28, 2008 7:41 pm

Re: Open, human-readable minesweeper video format

Post by Cryslon » Thu Jun 12, 2014 8:42 pm

I wrote a program to do some statistic & analysis jobs for all the videos
Mhm, nice. I see you mentioned some competition for which the program was written; was it a success?
Go IRC! (try mibbit)

Post Reply