fix narrowing conversion

This commit is contained in:
Chris Cromer 2019-05-01 17:54:43 -04:00
parent 0426daffe5
commit f5f3ee3155
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
2 changed files with 61 additions and 61 deletions

View File

@ -1,7 +1,7 @@
/*
* QT AGI Studio :: Copyright (C) 2000 Helen Zommer
*
* Almost all of the picture processing code is taken from showpic.c
* Almost all of the picture processing code is taken from showpic.c
* by Lance Ewing <lance.e@ihug.co.nz>
*
* This program is free software; you can redistribute it and/or modify
@ -38,7 +38,7 @@
BPicture *ppicture;
//********************************************
//"bytemap" picture for preview - it is not going to be edited,
//"bytemap" picture for preview - it is not going to be edited,
//so there is no need for the linked list and other things from the Picture class
BPicture::BPicture()
@ -414,8 +414,8 @@ void BPicture::absoluteLine(byte **data)
** on the pattern code.
**************************************************************************/
void BPicture::plotPattern(byte x, byte y)
{
static char circles[][15] = { /* agi circle bitmaps */
{
static unsigned char circles[][15] = { /* agi circle bitmaps */
{0x80},
{0xfc},
{0x5f, 0xf4},
@ -476,7 +476,7 @@ void BPicture::plotPattern(byte x, byte y)
}
}
}
}
/**************************************************************************
@ -518,7 +518,7 @@ void BPicture::show(byte *picdata,int picsize)
priDrawEnabled = false;
picColour = priColour = 0;
do {
do {
action = *(data++);
switch (action) {
case 0xFF: stillDrawing = 0; break;
@ -539,7 +539,7 @@ void BPicture::show(byte *picdata,int picsize)
case 0xFA: plotBrush(&data); break;
default: printf("Unknown picture code : %X\n", action); break;
}
}while((data < (data + picsize)) && stillDrawing);
}while((data < (data + picsize)) && stillDrawing);
}
//****************************************************

View File

@ -72,7 +72,7 @@ char *Picture::showPos(int *code,int *val)
int Picture::setBufPos(int inputValue)
//set current picture buffer position to inputValue
{
if ((inputValue < 0) || (inputValue > bufLen)) return 1;
if (inputValue == bufLen) {
@ -94,7 +94,7 @@ int Picture::setBufPos(int inputValue)
bufPos++;
}
}
/* Find current action position */
while (picPos->node < 0xF0) {
picPos = picPos->prior;
@ -494,8 +494,8 @@ void Picture::absoluteLine(struct picCodeNode **temp)
** on the pattern code.
**************************************************************************/
void Picture::plotPattern(byte x, byte y)
{
static char circles[][15] = { /* agi circle bitmaps */
{
static unsigned char circles[][15] = { /* agi circle bitmaps */
{0x80},
{0xfc},
{0x5f, 0xf4},
@ -556,7 +556,7 @@ void Picture::plotPattern(byte x, byte y)
}
}
}
}
/**************************************************************************
@ -588,12 +588,12 @@ void Picture::load(byte *picdata,int picsize)
byte nodeData;
struct picCodeNode *temp=NULL;
bool stillLoading=true;
//init link list
picPos = picStart = picLast = NULL;
addMode = INS_MODE;
bufPos = bufLen = 0;
do {
nodeData = *picdata++;
picsize--;
@ -627,19 +627,19 @@ int Picture::open(char *filename)
{
FILE *fptr = fopen(filename,"rb");
if(fptr==NULL){
menu->errmes("Can't open file %s ! ",filename);
return 1;
}
struct stat buf;
fstat(fileno(fptr),&buf);
ResourceData.Size=buf.st_size;
fread(ResourceData.Data,ResourceData.Size,1,fptr);
fclose(fptr);
load(ResourceData.Data,ResourceData.Size);
fclose(fptr);
load(ResourceData.Data,ResourceData.Size);
refill_pic = refill_pri = false;
draw();
init();
@ -653,7 +653,7 @@ int Picture::open(int ResNum)
int err = game->ReadResource(PICTURE,ResNum);
if(!err){
load(ResourceData.Data,ResourceData.Size);
load(ResourceData.Data,ResourceData.Size);
refill_pic = refill_pri = false;
draw();
init();
@ -672,9 +672,9 @@ int Picture::save(int ResNum)
//*************************************************
int Picture::save(char *filename)
{
{
FILE *fptr = fopen(filename,"wb");
if(fptr==NULL){
menu->errmes("Can't open file %s ! ",filename);
return 1;
@ -691,21 +691,21 @@ void Picture::save()
{
byte *ptr=ResourceData.Data;
struct picCodeNode *temp;
if (picStart == NULL) { /* Black picture */
*ptr = 0xFF; /* End of picture marker */
ResourceData.Size=1;
return ;
}
temp = picStart;
*ptr++ = temp->node;
do {
temp = temp->next;
*ptr++ = temp->node;
} while (temp->next != NULL);
*ptr++ = 0xFF; /* End of picture marker */
ResourceData.Size = (int)(ptr-ResourceData.Data);
@ -794,9 +794,9 @@ void Picture::refill( struct picCodeNode *temp_fill_start, struct picCodeNode *t
else{//!picDrawEnabled_orig
if(col_pic!=15){
addCode(0xf0);
addCode(col_pic);
addCode(col_pic);
}
}
}
}
if((refmode|2) && priDrawEnabled0){
@ -826,9 +826,9 @@ void Picture::refill( struct picCodeNode *temp_fill_start, struct picCodeNode *t
else{//!priDrawEnabled_orig
if(col_pri!=4){
addCode(0xf2);
addCode(col_pri);
addCode(col_pri);
}
}
}
}
@ -859,10 +859,10 @@ void Picture::refill( struct picCodeNode *temp_fill_start, struct picCodeNode *t
if(col_pri_new==-1)draw_pri_new=true;
}
break;
}
}
temp = temp->next;
}while(temp && (col_pic_orig==-1 || col_pri_orig==-1));
picPos = temp_fill_end;
if((refmode|1) && picDrawEnabled0){
@ -870,7 +870,7 @@ void Picture::refill( struct picCodeNode *temp_fill_start, struct picCodeNode *t
if(draw_pic_new){
if(picDrawEnabled_orig){
addCode(0xf0);
addCode(col_pic_orig);
addCode(col_pic_orig);
}
else{
if(col_pic!=0x15){
@ -880,13 +880,13 @@ void Picture::refill( struct picCodeNode *temp_fill_start, struct picCodeNode *t
}
}
}
if((refmode|2) && priDrawEnabled0){
if(col_pri != col_pri_orig){
if(draw_pri_new){
if(priDrawEnabled_orig){
addCode(0xf2);
addCode(col_pri_orig);
addCode(col_pri_orig);
}
else{
if(col_pri!=0x4){
@ -896,7 +896,7 @@ void Picture::refill( struct picCodeNode *temp_fill_start, struct picCodeNode *t
}
}
}
}
picPos = picPos0;
draw();
@ -908,7 +908,7 @@ void Picture::draw()
byte action;
struct picCodeNode *temp,*temp_fill_start,*temp_fill_end;
int refmode;
bool finishedPic=false;
bool finishedPic=false;
int pC, pN;
memset(picture, 15, MAX_W*MAX_H); /* Visual screen default, white */
@ -945,11 +945,11 @@ void Picture::draw()
case 0xF5: tool=T_STEP; xCorner(&temp); break;
case 0xF6: tool=T_LINE; absoluteLine(&temp); break;
case 0xF7: tool=T_PEN; relativeDraw(&temp); break;
case 0xF8: tool=T_FILL;
case 0xF8: tool=T_FILL;
temp_fill_start = temp->prior;
fill(&temp);
temp_fill_end = temp;
if(refill_pic || refill_pri){
temp_fill_end = temp;
if(refill_pic || refill_pri){
//find which FILL filled the selected area
refmode=0;
if(refill_pic && picGetPixel(refill_x,refill_y)!=15){
@ -980,20 +980,20 @@ void Picture::draw()
patCode = pC;
patNum = pN;
}
}
//**************************************************
void Picture::init()
{
clear_tools();
priDrawEnabled = picDrawEnabled = false;
addMode = INS_MODE;
curp = &points0;
points0.n=points1.n=0;
newp=&points;
add_pic=add_pri=false;
add_pic=add_pri=false;
}
//**************************************************
@ -1019,7 +1019,7 @@ void Picture::addCode(byte code) /* To the list */
dlstore(temp);
}
//**************************************************
void Picture::replaceCode(byte code)
void Picture::replaceCode(byte code)
{
struct picCodeNode *temp;
@ -1121,7 +1121,7 @@ void Picture::wipe_proc()
}
//**************************************************
void Picture::tool_proc(int k)
{
{
tool=k;
numClicks=0;
stepClicks=0;
@ -1142,7 +1142,7 @@ void Picture::set_brush(int mode,int val)
brushTexture = val;
break;
}
numClicks=0;
numClicks=0;
}
//**************************************************
@ -1188,13 +1188,13 @@ void Picture::choose_color(int button,int color)
//**************************************************
int Picture::move_action(int newX, int newY)
{
int ret=0; //1 - draw "temporary" line on screen
int ret=0; //1 - draw "temporary" line on screen
switch(tool){
case T_LINE:
if(numClicks==0)break;
normline2(clickX>>1, clickY, newX>>1, newY);
ret=1;
ret=1;
break;
case T_PEN:
if(numClicks==0)break;
@ -1202,7 +1202,7 @@ int Picture::move_action(int newX, int newY)
dY = ((newY) - (clickY));
adjustDisp(&dX, &dY);
normline2(clickX>>1, clickY,(clickX>>1)+dX, clickY+dY);
ret=1;
ret=1;
break;
case T_STEP:
if(stepClicks==0)break;
@ -1215,7 +1215,7 @@ int Picture::move_action(int newX, int newY)
normline2(clickX>>1, clickY, (clickX>>1)+dX, clickY+dY);
ret=1;
break;
default:
dX = ((newX>>1) - (clickX>>1));
dY = ((newY) - (clickY));
@ -1255,7 +1255,7 @@ int Picture::button_action(int newX, int newY)
}
switch(tool){
case T_LINE:
case T_LINE:
switch (numClicks++) {
case 0: break;
case 1:
@ -1271,7 +1271,7 @@ int Picture::button_action(int newX, int newY)
break;
}
clickX = newX;
clickY = newY;
clickY = newY;
curp = &points0;
points0.n=points1.n=0;
break;
@ -1300,7 +1300,7 @@ int Picture::button_action(int newX, int newY)
clickX = clickX + (dX<<1);
clickY = clickY + dY;
break;
}
}
curp = &points0;
points0.n=points1.n=0;
break;
@ -1357,10 +1357,10 @@ int Picture::button_action(int newX, int newY)
stepClicks++;
curp = &points0;
points0.n=points1.n=0;
break;
break;
case T_FILL:
if(!(okToFill(newX>>1, newY))){
status(0);
status(0);
refill_x = newX>>1;
refill_y = newY;
refill_pic = refill_pri = true;
@ -1389,7 +1389,7 @@ int Picture::button_action(int newX, int newY)
addCode(0xFA);
}
numClicks++;
patCode = brushSize;
if (brushShape == SQUARE) patCode |= 0x10;
if (brushTexture == SPRAY) patCode |= 0x20;
@ -1456,7 +1456,7 @@ void Picture::putpix2(int x,int y)
}
x>>=1;
}
else{ //save the pixels
else{ //save the pixels
curp->p[curp->n].x=x;
curp->p[curp->n].y=y;
curp->p[curp->n].c=pptr[y*MAX_W+(x<<1)];
@ -1489,7 +1489,7 @@ void Picture::normline2(int x1, int y1, int x2, int y2)
for (x=x1; x!=x2; x+=addX) {
putpix2(round(x, addX), round(y, addY));
y+=addY;
}
}
putpix2(x2,y2);
}
else {
@ -1520,12 +1520,12 @@ void Picture::viewData(TStringList *data)
data->add("ff");
return ;
}
temp = picStart;
tmp[0]=0;
for(temp=picStart;temp!=NULL;temp=temp->next){
c = temp->node;
if(c>=0xf0 && tmp[0]){
if(c>=0xf0 && tmp[0]){
data->add(tmp);
sprintf(tmp,"%02x ",c);
}
@ -1539,7 +1539,7 @@ void Picture::viewData(TStringList *data)
data->add(tmp);
}
data->add("ff");
}
//***************************************************