~flosoft/s25rttr/trunk

« back to all changes in this revision

Viewing changes to src/nofBaker.cpp

  • Committer: FloSoft
  • Date: 2014-04-25 15:35:50 UTC
  • Revision ID: flosoft@siedler25.org-20140425153550-9muu4vodhlqu58m0
committing subversion revision 9357 by FloSoft
astyle

modified:
s25client/trunk/
s25client/trunk/contrib/lua/lin32/include/
s25client/trunk/contrib/lua/lin64/include/
s25client/trunk/contrib/lua/mac/include/
s25client/trunk/contrib/lua/win32/include/
s25client/trunk/contrib/lua/win64/include/
s25client/trunk/driver/audio/SDL/src/
s25client/trunk/driver/src/
s25client/trunk/driver/video/GLFW/src/
s25client/trunk/driver/video/SDL/src/
s25client/trunk/driver/video/WinAPI/src/
s25client/trunk/src/
s25client/trunk/win32/
s25client/trunk/win32/prebuild-mutex/src/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// $Id: nofBaker.cpp 9199 2014-02-27 10:21:26Z marcus $
 
1
// $Id: nofBaker.cpp 9357 2014-04-25 15:35:25Z FloSoft $
2
2
//
3
3
// Copyright (c) 2005 - 2011 Settlers Freaks (sf-team at siedler25.org)
4
4
//
34
34
///////////////////////////////////////////////////////////////////////////////
35
35
// Makros / Defines
36
36
#if defined _WIN32 && defined _DEBUG && defined _MSC_VER
37
 
        #define new new(_NORMAL_BLOCK, THIS_FILE, __LINE__)
38
 
        #undef THIS_FILE
39
 
        static char THIS_FILE[] = __FILE__;
 
37
#define new new(_NORMAL_BLOCK, THIS_FILE, __LINE__)
 
38
#undef THIS_FILE
 
39
static char THIS_FILE[] = __FILE__;
40
40
#endif
41
41
 
42
 
nofBaker::nofBaker(const unsigned short x, const unsigned short y,const unsigned char player,nobUsual * workplace)
43
 
: nofWorkman(JOB_BAKER,x,y,player,workplace)
 
42
nofBaker::nofBaker(const unsigned short x, const unsigned short y, const unsigned char player, nobUsual* workplace)
 
43
    : nofWorkman(JOB_BAKER, x, y, player, workplace)
44
44
{
45
45
}
46
46
 
47
 
nofBaker::nofBaker(SerializedGameData * sgd, const unsigned obj_id) : nofWorkman(sgd,obj_id)
 
47
nofBaker::nofBaker(SerializedGameData* sgd, const unsigned obj_id) : nofWorkman(sgd, obj_id)
48
48
{
49
49
}
50
50
 
51
51
void nofBaker::DrawWorking(int x, int y)
52
52
{
53
 
        signed char offsets[NATION_COUNT][2] = { {40,-4},{-16,8},{-5,9},{-8,7},{-16,8} };
54
 
        signed char walkoffsets[NATION_COUNT][8][2] = { //nation, schrit, x-y
55
 
            { {10,10},{17,12},{24,14},{32,14},{34,9},{36,4},{38,-1},{40,-4} },
56
 
            { {9,11},{11,13},{7,17},{3,20},{-1,17},{-5,14},{-9,12},{-13,10} },
57
 
            { {9,9},{11,11},{9,13},{7,15},{4,13},{1,11},{-2,9},{-5,9} },
58
 
            { {9,11},{11,13},{9,15},{7,17},{4,15},{1,13},{-2,11},{-5,9} },
59
 
            { {9,11},{11,13},{7,17},{3,20},{-1,17},{-5,14},{-9,12},{-13,10} }
60
 
            };
61
 
    signed char walkdirection[NATION_COUNT][6]= {
62
 
        {3,3,2,5,0,0},
63
 
        {4,5,0,3,2,1},
64
 
        {4,5,0,3,2,1},
65
 
        {4,5,0,3,2,1},
66
 
        {4,5,0,3,2,1}
67
 
        };
 
53
    signed char offsets[NATION_COUNT][2] = { {40, -4}, { -16, 8}, { -5, 9}, { -8, 7}, { -16, 8} };
 
54
    signed char walkoffsets[NATION_COUNT][8][2] =   //nation, schrit, x-y
 
55
    {
 
56
        { {10, 10}, {17, 12}, {24, 14}, {32, 14}, {34, 9}, {36, 4}, {38, -1}, {40, -4} },
 
57
        { {9, 11}, {11, 13}, {7, 17}, {3, 20}, { -1, 17}, { -5, 14}, { -9, 12}, { -13, 10} },
 
58
        { {9, 9}, {11, 11}, {9, 13}, {7, 15}, {4, 13}, {1, 11}, { -2, 9}, { -5, 9} },
 
59
        { {9, 11}, {11, 13}, {9, 15}, {7, 17}, {4, 15}, {1, 13}, { -2, 11}, { -5, 9} },
 
60
        { {9, 11}, {11, 13}, {7, 17}, {3, 20}, { -1, 17}, { -5, 14}, { -9, 12}, { -13, 10} }
 
61
    };
 
62
    signed char walkdirection[NATION_COUNT][6] =
 
63
    {
 
64
        {3, 3, 2, 5, 0, 0},
 
65
        {4, 5, 0, 3, 2, 1},
 
66
        {4, 5, 0, 3, 2, 1},
 
67
        {4, 5, 0, 3, 2, 1},
 
68
        {4, 5, 0, 3, 2, 1}
 
69
    };
68
70
 
69
71
    unsigned int max_id = 120;
70
 
        unsigned now_id = GAMECLIENT.Interpolate(max_id,current_ev);
71
 
        unsigned char wpNation = workplace->GetNation();
72
 
        unsigned int plColor = GAMECLIENT.GetPlayer(player)->color;
73
 
 
74
 
        //position zum rauslaufen berechnen
75
 
        int walkx = x+walkoffsets[wpNation][now_id%8][0];
76
 
        int walky = y+walkoffsets[wpNation][now_id%8][1];
77
 
        //position zum reinlaufen berechnen
78
 
    int walkx_r = x+walkoffsets[wpNation][7-(now_id%8)][0];
79
 
    int walky_r = y+walkoffsets[wpNation][7-(now_id%8)][1];
80
 
 
81
 
 
82
 
    if(now_id<2){  //hinauslaufen teil 1
83
 
        LOADER.GetNationImageN(wpNation,250+5*BLD_BAKERY+4)->Draw(x,y,0,0,0,0,0,0);
84
 
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][0]][now_id%8].draw(walkx, walky, COLOR_WHITE, COLORS[plColor]);
 
72
    unsigned now_id = GAMECLIENT.Interpolate(max_id, current_ev);
 
73
    unsigned char wpNation = workplace->GetNation();
 
74
    unsigned int plColor = GAMECLIENT.GetPlayer(player)->color;
 
75
 
 
76
    //position zum rauslaufen berechnen
 
77
    int walkx = x + walkoffsets[wpNation][now_id % 8][0];
 
78
    int walky = y + walkoffsets[wpNation][now_id % 8][1];
 
79
    //position zum reinlaufen berechnen
 
80
    int walkx_r = x + walkoffsets[wpNation][7 - (now_id % 8)][0];
 
81
    int walky_r = y + walkoffsets[wpNation][7 - (now_id % 8)][1];
 
82
 
 
83
 
 
84
    if(now_id < 2) //hinauslaufen teil 1
 
85
    {
 
86
        LOADER.GetNationImageN(wpNation, 250 + 5 * BLD_BAKERY + 4)->Draw(x, y, 0, 0, 0, 0, 0, 0);
 
87
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][0]][now_id % 8].draw(walkx, walky, COLOR_WHITE, COLORS[plColor]);
85
88
//        LOADER.GetBobN("jobs")->Draw(17,walkdirection[wpNation][0],true,now_id%8,walkx,walky,COLORS[plColor]);
86
89
    }
87
 
    if((now_id>=2) && (now_id<4) ){  //hinauslaufen teil 2
88
 
        LOADER.GetNationImageN(wpNation,250+5*BLD_BAKERY+4)->Draw(x,y,0,0,0,0,0,0);
89
 
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][1]][now_id%8].draw(walkx, walky, COLOR_WHITE, COLORS[plColor]);
 
90
    if((now_id >= 2) && (now_id < 4) ) //hinauslaufen teil 2
 
91
    {
 
92
        LOADER.GetNationImageN(wpNation, 250 + 5 * BLD_BAKERY + 4)->Draw(x, y, 0, 0, 0, 0, 0, 0);
 
93
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][1]][now_id % 8].draw(walkx, walky, COLOR_WHITE, COLORS[plColor]);
90
94
//        LOADER.GetBobN("jobs")->Draw(17,walkdirection[wpNation][1],true,now_id%8,walkx,walky,COLORS[plColor]);
91
95
    }
92
 
    if((now_id>=4) && (now_id<8) ){  //hinauslaufen teil 3
93
 
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][2]][now_id%8].draw(walkx, walky, COLOR_WHITE, COLORS[plColor]);
 
96
    if((now_id >= 4) && (now_id < 8) ) //hinauslaufen teil 3
 
97
    {
 
98
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][2]][now_id % 8].draw(walkx, walky, COLOR_WHITE, COLORS[plColor]);
94
99
//        LOADER.GetBobN("jobs")->Draw(17,walkdirection[wpNation][2],true,now_id%8,walkx,walky,COLORS[plColor]);
95
100
    }
96
 
    if((now_id>=8) && (now_id<16) ){ //brot in den ofen schieben
97
 
        LOADER.GetImageN("rom_bobs", 182+(now_id%8))
98
 
            ->Draw(x+offsets[wpNation][0],y+offsets[wpNation][1],0,0,0,0,0,0,COLOR_WHITE, COLORS[plColor]);
 
101
    if((now_id >= 8) && (now_id < 16) ) //brot in den ofen schieben
 
102
    {
 
103
        LOADER.GetImageN("rom_bobs", 182 + (now_id % 8))
 
104
        ->Draw(x + offsets[wpNation][0], y + offsets[wpNation][1], 0, 0, 0, 0, 0, 0, COLOR_WHITE, COLORS[plColor]);
99
105
 
100
 
                // "Brot-rein/raus"-Sound
101
 
                if((now_id%8) == 4)
102
 
                {
103
 
                        SoundManager::inst().PlayNOSound(68,this,now_id);
104
 
                        was_sounding = true;
105
 
                }
 
106
        // "Brot-rein/raus"-Sound
 
107
        if((now_id % 8) == 4)
 
108
        {
 
109
            SoundManager::inst().PlayNOSound(68, this, now_id);
 
110
            was_sounding = true;
 
111
        }
106
112
    }
107
 
    if((now_id>=16) && (now_id<max_id-16) ){ //warten
 
113
    if((now_id >= 16) && (now_id < max_id - 16) ) //warten
 
114
    {
108
115
        LOADER.GetImageN("rom_bobs", 189)
109
 
            ->Draw(x+offsets[wpNation][0],y+offsets[wpNation][1],0,0,0,0,0,0,COLOR_WHITE, COLORS[plColor]);
 
116
        ->Draw(x + offsets[wpNation][0], y + offsets[wpNation][1], 0, 0, 0, 0, 0, 0, COLOR_WHITE, COLORS[plColor]);
110
117
    }
111
 
    if((now_id>=max_id-16) && (now_id<max_id-8) ){ //brot aus dem ofen holen
112
 
        LOADER.GetImageN("rom_bobs", 182+7-(now_id%8))
113
 
            ->Draw(x+offsets[wpNation][0],y+offsets[wpNation][1],0,0,0,0,0,0,COLOR_WHITE, COLORS[plColor]);
 
118
    if((now_id >= max_id - 16) && (now_id < max_id - 8) ) //brot aus dem ofen holen
 
119
    {
 
120
        LOADER.GetImageN("rom_bobs", 182 + 7 - (now_id % 8))
 
121
        ->Draw(x + offsets[wpNation][0], y + offsets[wpNation][1], 0, 0, 0, 0, 0, 0, COLOR_WHITE, COLORS[plColor]);
114
122
 
115
 
                // "Brot-rein/raus"-Sound
116
 
                if((now_id%8) == 4)
117
 
                {
118
 
                        SoundManager::inst().PlayNOSound(68,this,now_id);
119
 
                        was_sounding = true;
120
 
                }
 
123
        // "Brot-rein/raus"-Sound
 
124
        if((now_id % 8) == 4)
 
125
        {
 
126
            SoundManager::inst().PlayNOSound(68, this, now_id);
 
127
            was_sounding = true;
 
128
        }
121
129
    }
122
 
    if((now_id>=max_id-8) && (now_id<max_id-4) ){ //reingehn teil 1
123
 
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][3]][now_id%8].draw(walkx_r, walky_r, COLOR_WHITE, COLORS[plColor]);
 
130
    if((now_id >= max_id - 8) && (now_id < max_id - 4) ) //reingehn teil 1
 
131
    {
 
132
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][3]][now_id % 8].draw(walkx_r, walky_r, COLOR_WHITE, COLORS[plColor]);
124
133
//        LOADER.GetBobN("jobs")->Draw(17,walkdirection[wpNation][3],true,now_id%8,walkx_r,walky_r,COLORS[plColor]);
125
134
    }
126
 
    if((now_id>=max_id-4) && (now_id<max_id-2) ){ //reingehn teil 1
127
 
        LOADER.LOADER.GetNationImageN(wpNation,250+5*BLD_BAKERY+4)->Draw(x,y,0,0,0,0,0,0);
128
 
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][4]][now_id%8].draw(walkx_r, walky_r, COLOR_WHITE, COLORS[plColor]);
 
135
    if((now_id >= max_id - 4) && (now_id < max_id - 2) ) //reingehn teil 1
 
136
    {
 
137
        LOADER.LOADER.GetNationImageN(wpNation, 250 + 5 * BLD_BAKERY + 4)->Draw(x, y, 0, 0, 0, 0, 0, 0);
 
138
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][4]][now_id % 8].draw(walkx_r, walky_r, COLOR_WHITE, COLORS[plColor]);
129
139
//        LOADER.GetBobN("jobs")->Draw(17,walkdirection[wpNation][4],true,now_id%8,walkx_r,walky_r,COLORS[plColor]);
130
140
    }
131
 
    if((now_id>=max_id-2) && (now_id<max_id) ){ //reingehn teil 2
132
 
        LOADER.LOADER.GetNationImageN(wpNation,250+5*BLD_BAKERY+4)->Draw(x,y,0,0,0,0,0,0);
133
 
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][5]][now_id%8].draw(walkx_r, walky_r, COLOR_WHITE, COLORS[plColor]);
 
141
    if((now_id >= max_id - 2) && (now_id < max_id) ) //reingehn teil 2
 
142
    {
 
143
        LOADER.LOADER.GetNationImageN(wpNation, 250 + 5 * BLD_BAKERY + 4)->Draw(x, y, 0, 0, 0, 0, 0, 0);
 
144
        Loader::bob_jobs_cache[wpNation][JOB_BAKER][walkdirection[wpNation][5]][now_id % 8].draw(walkx_r, walky_r, COLOR_WHITE, COLORS[plColor]);
134
145
//        LOADER.GetBobN("jobs")->Draw(17,walkdirection[wpNation][5],true,now_id%8,walkx_r,walky_r,COLORS[plColor]);
135
146
    }
136
147
 
138
149
 
139
150
GoodType nofBaker::ProduceWare()
140
151
{
141
 
        return GD_BREAD;
 
152
    return GD_BREAD;
142
153
}
143
154