-rw-r--r-- | noncore/games/kcheckers/kcheckers.cpp | 1 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/currency.c | 7 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp index a27dd18..433c68f 100644 --- a/noncore/games/kcheckers/kcheckers.cpp +++ b/noncore/games/kcheckers/kcheckers.cpp @@ -241,346 +241,347 @@ void KCheckers::closeEvent(QCloseEvent* event) if(skill==EXPERT) entry="expert"; if(skill==MASTER) entry="master"; config.writeEntry("skill",entry); if(rules==ENGLISH) entry="english"; if(rules==RUSSIAN) entry="russian"; config.writeEntry("rules",entry); if(pattern==GREEN) entry="green"; if(pattern==MARBLE) entry="marble"; if(pattern==WOODEN) entry="wooden"; config.writeEntry("theme",entry); event->accept(); } void KCheckers::setSkill(int set) { skillMenu->setItemChecked(skill,false); skill=set; skillMenu->setItemChecked(skill,true); game->setLevel(skill); } void KCheckers::setRules(int set) { optionsMenu->setItemChecked(rules,false); rules=set; optionsMenu->setItemChecked(rules,true); colorChange(); newGame(); } void KCheckers::setPattern(int set) { optionsMenu->setItemChecked(pattern,false); pattern=set; optionsMenu->setItemChecked(pattern,true); switch(pattern) { case GREEN: imagePat1=imageGreen1; imagePat2=imageGreen2; imageFrame=imageGreen3; break; case MARBLE: imagePat1=imageMarble1; imagePat2=imageMarble2; imageFrame=imageMarble3; break; case WOODEN: imagePat1=imageWood1; imagePat2=imageWood2; imageFrame=imageWood3; } for(int i=0; i<32;i++) field[i]->setPattern(imagePat2); for(int i=32;i<64;i++) field[i]->setPattern(imagePat1); if(selected) field[from]->setFrame(imageFrame); } void KCheckers::showNumeration() { if(optionsMenu->isItemChecked(numID)) { optionsMenu->setItemChecked(numID,false); for(int i=0;i<32;i++) field[i]->setLabel(""); } else { optionsMenu->setItemChecked(numID,true); drawNumeration(); } } void KCheckers::drawNumeration() { if(rules==ENGLISH) { if(userFirst) for(int i=0;i<32;i++) field[i]->setLabel(enNumeration.mid(i*2,2)); else for(int i=0;i<32;i++) field[i]->setLabel(enNumeration.mid(62-i*2,2)); } else { if(userFirst) for(int i=0;i<32;i++) field[i]->setLabel(ruNumeration.mid(i*2,2)); else for(int i=0;i<32;i++) field[i]->setLabel(ruNumeration.mid(62-i*2,2)); } } void KCheckers::drawBoard(int i) { switch(game->board[t[i]]) { case MAN1: field[i]->setPicture(imageMan1); break; case MAN2: field[i]->setPicture(imageMan2); break; case KING1: field[i]->setPicture(imageKing1); break; case KING2: field[i]->setPicture(imageKing2); break; default: field[i]->setPicture(NULL); } } void KCheckers::help() { QMessageBox::information(this,"Rules of Play", "In the beginning of game you have\n" "12 checkers (men).\n" "The men move forward only.\n" "The men can capture:\n" "- by jumping forward only (english\n" " rules);\n" "- by jumping forward or backward\n" " (russian rules).\n" "A man which reaches the far side of\n" "the board becomes a king.\n" "The kings move forward or\n" "backward:\n" "- to one square only (english rules);\n" "- to any number of squares (russian\n" " rules).\n" "The kings capture by jumping\n" "forward or backward.\n" "Whenever a player is able to make a\n" "capture he must do so.", QMessageBox::Ok|QMessageBox::Default); } void KCheckers::about() { QMessageBox::about(this,"About KCheckers", "KCheckers, a board game. Ver 0.3\n" "(C) 2002, A. Peredri <andi@ukr.net>\n\n" "http://kcheckers.tuxfamily.org\n\n" "Contributors:\n" "S. Rosen <srosen@erols.com>\n\n" "Qtopia version: S.Prud'homme\n" "<prudhomme@laposte.net>\n\n" "This program is distributed under the\n" "terms of the GNU General Public\n" "License."); } void KCheckers::aboutQt() { QMessageBox::aboutQt(this); } void KCheckers::newGame() { if(game) delete game; switch(rules) { case ENGLISH: game=new ECheckers(skill); CHECK_PTR(game); break; case RUSSIAN: + default: game=new RCheckers(skill); CHECK_PTR(game); } unselect(); gameOver=false; gameMenu->setItemEnabled(undoID,false); undoButton->setEnabled(false); colorChange(); for(int i=0;i<32;i++) drawBoard(i); if(optionsMenu->isItemChecked(numID)) drawNumeration(); if(!userFirst) compGo(); statusLabel->setText(tr("Go!")); } // Undo the last computer and user moves void KCheckers::undoMove() { for(int i=0;i<32;i++) { game->board[t[i]]=undoBoard[i]; drawBoard(i); } unselect(); gameOver=false; gameMenu->setItemEnabled(undoID,false); undoButton->setEnabled(false); statusLabel->setText(tr("Go!")); } void KCheckers::colorChange() { userFirst=!userFirst; QImage* image; image=imageMan1; imageMan1=imageMan2; imageMan2=image; image=imageKing1; imageKing1=imageKing2; imageKing2=image; } void KCheckers::unselect() { if(selected) field[from]->setFrame(NULL); selected=false; } void KCheckers::click(int fieldNumber) { if(gameOver) return; switch(game->board[t[fieldNumber]]) { case MAN1: case KING1: // User selected if(!selected) { from=fieldNumber; selected=true; field[fieldNumber]->setFrame(imageFrame); return; } // User reselected else { field[from]->setFrame(NULL); from=fieldNumber; field[fieldNumber]->setFrame(imageFrame); return; } case FREE: if(!selected) return; if(!userGo(fieldNumber)) return; unselect(); if(!(game->checkMove2() || game->checkCapture2())) { gameOver=true; statusLabel->setText(tr("Congratulation! You have won!")); return; } statusLabel->setText(tr("Please wait...")); qApp->processEvents(); compGo(); if(!(game->checkMove1() || game->checkCapture1())) { gameOver=true; statusLabel->setText(tr("You have lost. Game over.")); return; } statusLabel->setText(tr("Go!")); } } void KCheckers::compGo() { int save[32]; for(int i=0;i<32;i++) save[i]=game->board[t[i]]; game->go2(); for(int i=0;i<32;i++) { if(game->board[t[i]]==save[i]) continue; drawBoard(i); } } bool KCheckers::userGo(int to) { int save[32]; for(int i=0;i<32;i++) save[i]=game->board[t[i]]; if(!game->go1(t[from],t[to])) { statusLabel->setText(tr("Incorrect course.")); return false; } for(int i=0;i<32;i++) undoBoard[i]=save[i]; gameMenu->setItemEnabled(undoID,true); undoButton->setEnabled(true); for(int i=0;i<32;i++) { if(game->board[t[i]]==save[i]) continue; drawBoard(i); } return true; } diff --git a/noncore/todayplugins/stockticker/libstocks/currency.c b/noncore/todayplugins/stockticker/libstocks/currency.c index e0090e2..82cd654 100644 --- a/noncore/todayplugins/stockticker/libstocks/currency.c +++ b/noncore/todayplugins/stockticker/libstocks/currency.c @@ -1,67 +1,66 @@ /* libstocks - Library to get current stock quotes from Yahoo Finance * * Copyright (C) 2000 Eric Laeuffer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #define __CURRENCY_C__ #include <stdio.h> #include <string.h> #include <malloc.h> #include <stdlib.h> #include "stocks.h" /*****************************************************************************/ /* returns the currency exchange rate of "from" currency into */ /* "into" currency. */ /*****************************************************************************/ libstocks_return_code get_currency_exchange(char *from, char *into, float *exchange) { char *symbol; stock *data; libstocks_return_code error; if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) { fprintf(stderr,"Memory allocating error (%s line %d)\n" ,__FILE__, __LINE__); exit(1); } strcpy(symbol, from); strcat(symbol, into); strcat(symbol, "=X"); error = get_stocks(symbol, &data); free(symbol); if (error) { *exchange = 0; - return(error); + return error; } - free_stocks(data); - *exchange = data->CurrentPrice; - return(error); + free_stocks(data); + return error; } |