void Enemy::setInfo(EnemyInfo* info, int enemy_type) { enemyType = enemy_type; std::map<std::string, Attribute>::iterator it = info->attrs.begin(); for (; it != info->attrs.end(); it++) { attrs[it->first] = it->second; } radius = _ATTR(radius); enemyAttackData.damage = _ATTR(melee_attack); _INIT_ATTR(drops, info->cost * 2); if (info->skills.size() > 0) skill = info->skills[0]; }
bool Enemy::onDeath(){ stage->trashPool->spawn( position, (int)_ATTR(drops)); RemoveUnit noti; noti.id = id; stage->gameroom->sendPacket(noti); return true; }
void Player::update( float dt){ updateConditions(dt); if (stiff <= 0.f) { position += moveDirection * _ATTR(speed) * dt; } Unit::update(dt); }
bool Player::initExternalData( const int player_type){ char buf[32]; sprintf_s(buf, "type%d.json", player_type); Json::Value root; if (!JsonLoader::load(buf, root)) return false; /* attr */ auto attrList = root.get("attrs", Json::Value::null); if (attrList.isNull()) return false; for (auto attr : attrList){ auto name = attr.get("name", "").asString(); float value = attr.get("value", 0).asFloat(); attrs[name].set(value); } radius = _ATTR(radius); /* max_attr */ attrList = root.get("max_attrs", Json::Value::null); if (attrList.isNull()) return false; for (auto attr : attrList){ auto name = attr.get("name", "").asString(); float value = attr.get("value", 0).asFloat(); maxAttrs[name] = value; } /* skill list */ auto skillList = root.get("skills", Json::Value::null); if (skillList.isNull()) return false; auto pool = SkillPool::getInstance(); for (auto skill : skillList){ skills.push_back( (ActiveSkill*)pool->get(skill.asInt())); cooltimes.push_back(0); } return true; }
void Enemy::updateMovement(){ auto target = getTarget(); if (!target) { if (velocity.getLengthSq() != 0.f) return; velocity = Vec2::ZERO; } else { auto delta = target->position - position; velocity = delta.getNormalized() * _ATTR(speed); } MoveNoti noti; noti.id = id; noti.start_x = position.x; noti.start_y = position.y; noti.velocity_x = velocity.x; noti.velocity_y = velocity.y; stage->gameroom->sendPacket(noti); }
int wbkgd(WINDOW *win, chtype nbkgd) { short maxx; int x, y; chtype *wcp, obkgda, obkgdc, nbkgda, nbkgdc, acolor, c; short *begch, *endch; /* if 'nbkgd' contains color information, but this is not a color */ /* terminal, erase that information. */ if ((nbkgd & A_COLOR) && (cur_term->_pairs_tbl == NULL)) nbkgd &= ~A_COLOR; if (nbkgd == win->_bkgd) return (OK); obkgdc = _CHAR(win->_bkgd); obkgda = _ATTR(win->_bkgd); nbkgdc = _CHAR(nbkgd); nbkgda = _ATTR(nbkgd); /* switch byte order if necessary */ if (ISCBIT(nbkgdc)) nbkgdc = _CHAR((RBYTE(nbkgdc) << 8) | (LBYTE(nbkgdc)|MBIT)) | CBIT; c = RBYTE(nbkgdc); if ((nbkgdc < ' ' || nbkgdc == _CTRL('?')) || _curs_scrwidth[TYPE(c)] > 1) nbkgdc = obkgdc; nbkgd = (nbkgdc & ~CBIT) | nbkgda; win->_bkgd = nbkgd; /* delete the old background from the attribute field and replace */ /* it with the new background. Note: if the same attribute was */ /* first set by wbkgd() and then by wattron(), or vice versa, it */ /* will be deleted, so the effect of wattron() will be lost. */ /* This applies to both video and color attributes. */ if ((acolor = (win->_attrs & A_COLOR)) != 0) { if (acolor == (obkgda & A_COLOR)) { win->_attrs = _ATTR((win->_attrs & ~obkgda) | nbkgda); } else { win->_attrs = _ATTR((win->_attrs & (~obkgda | A_COLOR)) | (nbkgda & ~A_COLOR)); } } else win->_attrs = _ATTR((win->_attrs & ~obkgda) | nbkgda); maxx = win->_maxx - 1; begch = win->_firstch; endch = win->_lastch; for (y = win->_maxy-1; y >= 0; --y, ++begch, ++endch) { for (x = maxx, wcp = win->_y[y]; x-- >= 0; ++wcp) { if ((c = _CHAR(*wcp)) == obkgdc) c = nbkgdc; if ((acolor = (*wcp & A_COLOR)) != 0) { if (acolor == (obkgda & A_COLOR)) *wcp = c | _ATTR((*wcp & ~obkgda) | nbkgda); else *wcp = c | _ATTR((*wcp & (~obkgda | A_COLOR)) | (nbkgda & ~A_COLOR)); } else *wcp = c | _ATTR((*wcp & ~obkgda) | nbkgda); } *begch = 0; *endch = maxx; } win->_flags |= _WINCHANGED; if (win->_sync) wsyncup(win); return (win->_immed ? wrefresh(win) : OK); }
static int _useidch(chtype *wcp, chtype *scp, int length, int maxi, int *id) { int x1, x2, blnk, idch, cost, cost_ich1, match; chtype wc; /* try deletion */ if (SP->dchok && _CHAR(*wcp) != ' ') { if ((match = _prefix(wcp, scp, length, length / 2, &idch)) > 0) cost = _COST(dcfixed) + (parm_dch ? _COST(Parm_dch) : _COST(Delete_character) * idch); else cost = _INFINITY; if (match >= cost) { /* SS: colors */ if (back_color_erase) _turn_off_background(); if (SP->dmode) { if (SP->sid_equal) { if (!(SP->phys_irm)) _ONINSERT(); } else { if (SP->phys_irm) _OFFINSERT(); _PUTS(enter_delete_mode, 1); } } if (parm_dch) _PUTS(tparm_p1(parm_dch, idch), 1); else for (x1 = 0; x1 < idch; ++x1) _PUTS(delete_character, 1); if (SP->dmode) { if (SP->eid_equal) SP->phys_irm = FALSE; _PUTS(exit_delete_mode, 1); } /* update screen image */ for (x1 = 0, x2 = idch; x2 < length; ++x1, ++x2) scp[x1] = scp[x2]; for (; x1 < length; ++x1) scp[x1] = ' '; *id = -idch; return (match); } } /* no insertion wanted or possible */ if (!(SP->ichok) || _CHAR(*scp) == ' ') return (0); /* see if insertion is worth it */ maxi = (idch = length / 2) < maxi ? idch : maxi; if ((match = _prefix(scp, wcp, length, maxi, &idch)) <= 0) return (0); /* see if inserting blanks only */ for (blnk = 0; blnk < idch; ++blnk) if (wcp[blnk] != ' ') { blnk = 0; break; } /* see if doing insertion is worth it */ cost_ich1 = idch * _COST(Insert_character); if (SP->imode) { cost = SP->phys_irm ? 0 : _COST(icfixed); if (blnk > _COST(Parm_ich) && _COST(Parm_ich) < cost_ich1) cost += _COST(Parm_ich); else if (insert_character) cost += cost_ich1; } else { if (parm_ich && _COST(Parm_ich) < cost_ich1) cost = _COST(Parm_ich); else cost = cost_ich1; } if ((cost - blnk) > match) return (0); /* perform the insertions */ /* SS: colors */ if (back_color_erase) _turn_off_background(); if (SP->imode) { if (!SP->phys_irm) _ONINSERT(); if (blnk > _COST(Parm_ich) && _COST(Parm_ich) < cost_ich1) _PUTS(tparm_p1(parm_ich, idch), 1); else if (insert_character) goto do_insert_char; else /* so that we'll do real char insertions */ blnk = 0; } else { if (parm_ich && _COST(Parm_ich) < cost_ich1) _PUTS(tparm_p1(parm_ich, idch), 1); else { do_insert_char: for (x1 = 0; x1 < idch; ++x1) _PUTS(insert_character, 1); } } /* inserting desired characters */ if (!blnk) for (x1 = 0; x1 < idch; ++x1) { wc = wcp[x1]; if (_ATTR(wc) != curscr->_attrs) _VIDS(_ATTR(wc), curscr->_attrs); (void) _outwch(_CHAR(wc) == '~' && tilde_glitch ? '`' : wc); ++cx; } /* update the screen image */ for (x1 = length - 1, x2 = length - idch - 1; x2 >= 0; --x1, --x2) scp[x1] = scp[x2]; (void) memcpy((char *) scp, (char *) wcp, idch * sizeof (chtype)); *id = idch; return (match + idch); }
static void _updateln(int wy) { chtype *wcp, *scp, *wp, *sp, wc, sc; int wx, lastx, x, mtch, idch, blnkx, idcx, video_attrx, color_attrx, maxi, endns, begns, wx_sav, multi_col; bool redraw, changed, didcolor, didvideo; redraw = (_virtscr->_firstch[wy] == _REDRAW); endns = _ENDNS[wy]; begns = _BEGNS[wy]; /* easy case */ if (!redraw && (_virtscr->_lastch[wy] == _BLANK) && (begns >= scrco)) return; /* line images */ wcp = magic_cookie_glitch <= 0 ? _virtscr->_y[wy] : _shove(wy); scp = curscr->_y[wy]; /* the interval to be updated */ if (redraw || magic_cookie_glitch >= 0) { wx = 0; lastx = scrco; } else { wx = _virtscr->_firstch[wy]; lastx = _virtscr->_lastch[wy] == _BLANK ? scrco : _virtscr->_lastch[wy] + 1; } /* skip equal parts */ if (!redraw) { /* skip the starting equal part */ wp = wcp + wx; sp = scp + wx; for (; wx < lastx; ++wx) if (*wp++ != *sp++) break; if (wx >= lastx) return; /* start update at an entire character */ for (sp = scp+wx, wp = wcp+wx; wp > wcp; --wp, --sp, --wx) if (!ISCBIT(*wp) && !ISCBIT(*sp)) break; /* skip the ending equal part */ wp = wcp + lastx - 1; sp = scp + lastx - 1; for (; lastx > wx; --lastx) if (*wp-- != *sp--) break; ++wp; ++wp; ++sp; ++sp; for (; lastx < scrco; ++wp, ++sp, ++lastx) if (!ISCBIT(*wp) && !ISCBIT(*sp)) break; } /* place to do clear-eol */ if (!clr_eol || endns >= lastx) blnkx = scrco; else if (_virtscr->_lastch[wy] == _BLANK) blnkx = -1; else { for (blnkx = lastx - 1, wp = wcp + blnkx; blnkx >= wx; --blnkx, --wp) if (_DARKCHAR(*wp)) break; for (sp = scp + blnkx + 1; blnkx < scrco - 1; ++sp, ++blnkx) if (!ISCBIT(*sp)) break; if (blnkx + _COST(Clr_eol) >= lastx) blnkx = scrco; } /* on cookie terminals, we may need to do more work */ if (marks) { /* video_attrx = color_attrx = scrco; */ video_attrx = color_attrx = (lastx >= scrco) ? lastx - 1 : lastx; /* find the last video attribute on the line */ wp = wcp + video_attrx; for (; video_attrx >= wx; --video_attrx, --wp) if (_VIDEO(*wp) != A_NORMAL) break; /* find the last color attribute on the line */ if (color_marks) { wp = wcp + color_attrx; for (; color_attrx >= wx; --color_attrx, --wp) if (_COLOR(*wp) != A_NORMAL) break; if (color_attrx < lastx) color_attrx++; } if (video_attrx < lastx) video_attrx++; if (video_attrx >= scrco) --video_attrx; if (color_marks && color_attrx >= scrco) --color_attrx; if (magic_cookie_glitch > 0 && wy == scrli - 1 && video_attrx == scrco - 1) --video_attrx; if (color_marks && magic_cookie_glitch > 0 && wy == scrli - 1 && color_attrx == scrco - 1) --color_attrx; for (wp = wcp+video_attrx; wp >= wcp+wx; --wp) if (!ISCBIT(*wp)) break; } /* place for insert/delete chars */ #define SLACK 4 if (redraw || (!SP->dchok && !SP->ichok) || !(_virtscr->_use_idc) || endns < wx || (endns >= lastx && (scrco - lastx) > SLACK)) { idcx = scrco; } else if (!marks) idcx = -1; else { /* on cookie term, only do idch where no attrs */ /* are used */ for (idcx = scrco - 1, wp = wcp + idcx; idcx >= wx; --idcx, --wp) if (_ATTR(*wp) || _ISMARK1(wy, idcx) || _ISMARK2(wy, idcx)) break; if (idcx >= scrco - SLACK) idcx = scrco; } if (idcx < lastx && endns >= lastx) lastx = scrco; /* max amount of insert allow */ if (idcx == scrco || !SP->ichok) maxi = 0; else if (lastx == scrco) maxi = scrco; else maxi = lastx - (endns + 1); /* go */ wcp += wx; scp += wx; didvideo = changed = FALSE; didcolor = (color_marks) ? FALSE : TRUE; while (wx < lastx) { /* skip things that are already right */ if (!redraw) { multi_col = 0; wx_sav = wx; for (; wx < lastx; ++wx, ++wcp, ++scp) if (*wcp != *scp) break; if (wx >= lastx) goto done; for (; wx > wx_sav; --wx, --wcp, --scp) { if (!ISCBIT(*wcp) && !ISCBIT(*scp)) break; multi_col = 1; } } /* try clear-bol, we'll assume exclusive clr_bol */ if (!changed && !marks && clr_bol && blnkx > wx && begns >= wx) { for (x = wx, wp = wcp; x < lastx; ++x, ++wp) if (_DARKCHAR(*wp)) break; /* clearing only whole screen characters */ for (sp = scp+(x-wx); x >= wx; --x, --sp) if (!ISCBIT(*sp)) break; x -= 1; if ((x - (redraw ? 0 : begns)) > _COST(Clr_bol)) { (void) mvcur(cy, cx, wy, x); /* MORE?: colors - mvcur will shuts of */ /* colors when msgr is not defined */ /* SS: colors */ if (back_color_erase) _turn_off_background(); _PUTS(clr_bol, 1); /* LINTED */ cy = (short) wy; /* LINTED */ cx = (short) x; mtch = x - wx; (void) memcpy((char *) scp, (char *) wcp, (mtch * sizeof (chtype))); wcp += mtch; scp += mtch; wx = x; } } /* screen image is changing */ changed = TRUE; /* move to the point to start refresh */ if (cy != wy || cx != wx) (void) mvcur(cy, cx, wy, wx); /* LINTED */ cy = (short) wy; /* LINTED */ cx = (short) wx; /* update screen image */ while (wx < lastx) { wc = *wcp; sc = *scp; if (!redraw && !multi_col && wc == sc) break; /* real video attributes */ if (marks) curscr->_attrs = _ATTR(sc); /* blanks only */ if (wx > blnkx) { /* SS: colors */ if (back_color_erase) _turn_off_background(); _PUTS(clr_eol, 1); /* LINTED */ curscr->_curx = (short) wx; /* LINTED */ curscr->_cury = (short) wy; (void) wclrtoeol(curscr); if (marks && wx > 0 && _ATTR(*(scp - 1)) != A_NORMAL) { _VIDS(A_NORMAL, _ATTR(*(scp - 1))); if (_VIDEO(*scp - 1)) _setmark1(wy, wx, NULL); if (_COLOR(*scp - 1)) _setmark2(wy, wx, NULL); } goto done; } /* try insert/delete chars */ if (wx > idcx && !ISCBIT(*scp) && (mtch = _useidch(wcp, scp, lastx - wx, maxi, &idch))) { maxi -= idch; wx += mtch; scp += mtch; wcp += mtch; break; } /* about to output chars, make sure insert */ /* mode is off */ if (SP->phys_irm) _OFFINSERT(); /* color and video attributes */ if (_ATTR(wc) != curscr->_attrs) { bool color_change = FALSE; bool video_change = FALSE; if (marks) if (_VIDEO(wc) != _VIDEO(curscr->_attrs)) video_change = TRUE; if (color_marks) if (_COLOR(wc) != _COLOR(curscr->_attrs)) color_change = TRUE; /* the following may occurs when, for */ /* example the application */ /* is written for color terminal and then */ /* run on a monocrome */ if (marks && !video_change && !color_change) goto no_change; /* prevent spilling out of line */ if (marks && !(didcolor && didvideo)) { if ((video_change && !_ISMARK1(wy, video_attrx)) || (color_change && !_ISMARK2(wy, color_attrx))) { int tempx; chtype sa = curscr->_attrs; bool first = FALSE; bool second = FALSE; if (!didvideo && video_change && !_ISMARK1(wy, video_attrx)) { didvideo = TRUE; (void) mvcur(wy, wx, wy, video_attrx); _VIDS(_VIDEO(_virtscr->_y[wy] [video_attrx]), _VIDEO(_virtscr->_y[wy] [video_attrx-1])); _setmark1(wy, video_attrx, NULL); first = TRUE; } if (!didcolor && color_change && !_ISMARK2(wy, color_attrx)) { didcolor = TRUE; tempx = first ? video_attrx : wx; if (tempx != color_attrx) (void) mvcur(wy, tempx, wy, color_attrx); /* * sc = _COLOR(curscr->_y[wy][color_attrx]); *_VIDS(sc, (~sc & A_COLOR)); */ _VIDS(_COLOR(_virtscr->_y[wy] [color_attrx]), _COLOR(_virtscr->_y[wy] [color_attrx-1])); _setmark2(wy, color_attrx, NULL); second = TRUE; } (void) mvcur(wy, (second ? color_attrx : video_attrx), wy, wx); curscr->_attrs = sa; } } _VIDS(_ATTR(wc), curscr->_attrs); /* on cookie terminals mark the interval */ if (video_change) _setmark1(wy, wx, scp); if (color_change) _setmark2(wy, wx, scp); } /* end-of-line */ no_change: x = 1; if (_scrmax > 1) x = _curs_scrwidth[TYPE(RBYTE(wc))]; if (wx == scrco - x) { _rmargin(wx); goto done; } if (transparent_underline && erase_overstrike && _CHAR(wc) == '_') { (void) _outch(' '); (void) mvcur(wy, wx + 1, wy, wx); } /* put out the character */ (void) _outwch(tilde_glitch && _CHAR(wc) == '~' ? '`' : wc); *scp++ = wc; wcp++; wx++; cx++; /* output entire multi-byte chars */ while (wx < lastx && ISCBIT(*wcp)) { (void) _outwch(*wcp); *scp++ = *wcp++; wx++; cx++; } } } done: if (changed) { /* update the blank structure */ for (wx = 0, scp = curscr->_y[wy]; wx < scrco; ++wx, ++scp) if (_DARKCHAR(*scp)) break; /* LINTED */ _BEGNS[wy] = (short) wx; if (wx == scrco) _ENDNS[wy] = -1; else { wx = scrco - 1; scp = curscr->_y[wy] + wx; for (; wx >= 0; --wx, --scp) if (_DARKCHAR(*scp)) break; /* LINTED */ _ENDNS[wy] = (short) wx; } /* update the hash structure */ _CURHASH[wy] = _BEGNS[wy] < scrco ? _NOHASH : 0; } }
static chtype * _shove(int wy) { chtype *wcp, *cp, prev; short curx; int x, cury, didshift; static chtype *line; static int length; /* allocate space for shifted line */ if (length < scrco) { if (line) free((char *) line); line = (chtype *) malloc(scrco * sizeof (chtype)); length = line ? scrco : 0; } /* no space to do it */ if (!line) return (_virtscr->_y[wy]); prev = A_NORMAL; cp = line; wcp = _virtscr->_y[wy]; curx = _virtscr->_curx; cury = _virtscr->_cury; didshift = FALSE; for (x = 0; x < scrco; ++x, ++wcp, ++cp) { if (_ATTR(*wcp) != prev) { /* use existing blank */ if (_CHAR(*wcp) == ' ') *cp = ' ' | _ATTR(*(wcp + 1)); /* use previous blank */ else if ((x > 0) && _CHAR(*(cp - 1)) == ' ') { *(cp - 1) = ' ' | _ATTR(*wcp); *cp = *wcp; } else { if ((curx >= x) && (cury == wy)) ++curx; *cp = ' ' | _ATTR(*wcp); --wcp; didshift = TRUE; } prev = _ATTR(*cp); } else *cp = *wcp; } /* make sure that the end of the line is normal */ cp = line + scrco - 1; if (didshift || (_ATTR(*cp) != A_NORMAL) || ((wy == scrli - 1) && (_ATTR(*(cp - 1)) != A_NORMAL))) { *cp = didshift ? ' ' : _CHAR(*cp); if (wy == scrli - 1) *(cp - 1) = didshift ? ' ' : _CHAR(*(cp - 1)); } if (wy == cury) _virtscr->_curx = curx >= scrco ? scrco - 1 : curx; return (line); }
static void _rmargin(int wx) { int x, w, ix; chtype sc; chtype *wcp = _virtscr->_y[cy]; /* screen may scroll */ if (cy == scrli - 1) { /* can't do anything */ if (!SP->ichok) return; /* the width of the new character */ w = _curs_scrwidth[TYPE(RBYTE(wcp[wx]))]; /* the place to put it without causing scrolling */ for (x = wx - 1; x > 0; --x) if (!ISCBIT(wcp[x])) break; sc = curscr->_y[cy][x]; (void) mvcur(cy, cx, cy, x); if (_ATTR(wcp[wx]) != curscr->_attrs) _VIDS(_ATTR(wcp[wx]), curscr->_attrs); (void) _outwch(tilde_glitch && _CHAR(wcp[wx]) == '~' ? '`' : wcp[wx]); for (ix = wx + 1; ix < scrco; ++ix) { (void) _outwch(wcp[ix]); } /* insert sc back in and push wcp[wx] right */ (void) mvcur(cy, x+w, cy, x); /* SS: colors */ if (back_color_erase) _turn_off_background(); if (SP->imode && !SP->phys_irm) _ONINSERT(); /* width of the old character that was overwritten */ w = _curs_scrwidth[TYPE(RBYTE(curscr->_y[cy][x]))]; if (insert_character) for (ix = 0; ix < w; ++ix) _PUTS(insert_character, 1); else if (parm_ich && !SP->imode) _PUTS(tparm_p1(parm_ich, w), 1); if (_ATTR(sc) != curscr->_attrs) _VIDS(_ATTR(sc), curscr->_attrs); for (ix = x; w > 0; --w, ++ix) (void) _outwch(curscr->_y[cy][ix]); /* make sure the video attrs are ok */ if (marks && (_ATTR(sc) || _ATTR(wcp[wx]))) _VIDS(_ATTR(wcp[wx]), ~_ATTR(sc)); /* update screen image */ /* LINTED */ cx = (short) wx; curscr->_y[cy][wx] = wcp[wx]; for (x = wx + 1; x < scrco; ++x) { (void) _outwch(wcp[x]); curscr->_y[cy][x] = wcp[x]; } return; } /* put char out and update screen image */ (void) _outwch(tilde_glitch && _CHAR(wcp[wx]) == '~' ? '`' : wcp[wx]); curscr->_y[cy][wx] = wcp[wx]; for (x = wx + 1; x < scrco; ++x) { (void) _outwch(wcp[x]); curscr->_y[cy][x] = wcp[x]; } /* make sure that wrap-around happens */ if (!auto_right_margin || eat_newline_glitch) { (void) _outch('\r'); (void) _outch('\n'); } cx = 0; ++cy; }
int waddch(WINDOW *win, chtype c) { short x = win->_curx; short y = win->_cury; chtype rawc = _CHAR(c); chtype rawattrs = _ATTR(c); int rv = OK; bool savimmed = win->_immed; bool savsync = win->_sync; win->_immed = win->_sync = FALSE; #ifdef DEBUG if (outf) if (c == rawc) fprintf(outf, "'%c'", rawc); else fprintf(outf, "'%c' %o, raw %o", c, c, rawc); #endif /* DEBUG */ win->_insmode = FALSE; if (_scrmax > 1 && _mbvalid(win) == ERR) goto next; if (_mbtrue && ISMBIT(rawc)) { rv = _mbaddch(win, rawattrs, RBYTE(rawc)); win->_immed = savimmed; win->_sync = savsync; goto nextw; } switch (rawc) { case '\n': (void) wclrtoeol(win); goto new_line; case '\r': goto move_to_begin_line; case '\b': if (--x < 0) move_to_begin_line: x = 0; win->_curx = x; win->_flags |= _WINMOVED; goto out_move_only; default: if (rawc < ' ' || rawc == _CTRL('?')) { if (rawc == '\t') { int newx; chtype space = ' ' | rawattrs; if ((newx = x + (TABSIZE - (x % TABSIZE))) > win->_maxx) newx = win->_maxx; for (; x < newx; x++) if (waddch(win, space) == ERR) goto next; } else { if ((waddch(win, (chtype) '^'|rawattrs) == ERR) || (waddch(win, (chtype) _UNCTRL(rawc)|rawattrs) == ERR)) { next : rv = ERR; } } x = win->_curx; y = win->_cury; win->_immed = savimmed; win->_sync = savsync; break; } #ifdef DEBUG if ((win->_attrs) && outf) fprintf(outf, "(attrs %o, %o=>%o)", win->_attrs, c, c | win->_attrs); #endif /* DEBUG */ /* clear any partial multi-column character */ if (_scrmax > 1 && ISMBIT(win->_y[y][x]) && (rv = _mbclrch(win, y, x)) == ERR) { x = win->_curx; y = win->_cury; win->_immed = savimmed; win->_sync = savsync; break; } if ((c = _WCHAR(win, c)|rawattrs) != win->_y[y][x]) { if (x < win->_firstch[y]) win->_firstch[y] = x; if (x > win->_lastch[y]) win->_lastch[y] = x; win->_y[y][x] = c; #ifdef _VR3_COMPAT_CODE if (_y16update) /* LINTED */ win->_y16[y][x] = _TO_OCHTYPE(c); #endif /* _VR3_COMPAT_CODE */ } if (++x == win->_maxx) { new_line: if (y == win->_bmarg) { if (wscrl(win, 1) == ERR) { rv = ERR; if (x == win->_maxx) --x; #ifdef DEBUG if (outf) { int i; fprintf(outf, "ERR because " "(%d, %d) > (%d, %d)\n", x, y, win->_maxx, win->_maxy); fprintf(outf, "line: '"); for (i = 0; i < win->_maxy; i++) fprintf(outf, "%c", win->_y[y-1][i]); fprintf(outf, "'\n"); } #endif /* DEBUG */ break; } else savimmed = 1; } else y++; x = 0; } else savimmed += 2; #ifdef FULLDEBUG if (outf) fprintf(outf, "ADDCH: 2: y = %d, x = %d, " "firstch = %d, lastch = %d\n", y, x, win->_firstch[y], win->_lastch[y]); #endif /* FULLDEBUG */ break; } win->_cury = y; win->_curx = x; nextw: /* sync with ancestor structures */ if (win->_sync) wsyncup(win); if (savimmed == 3) return ((*_quick_ptr)(win, c)); win->_flags |= _WINCHANGED; out_move_only: return ((savimmed == 1) ? wrefresh(win) : rv); }
static int _mvright(int cx, int nx, int doit) { chtype *scp; char *mks; int nt, tx, x, stcost, iscont; if (!cursor_right && !parm_right_cursor) return (LARGECOST); scp = curscr->_y[Newy]; mks = magic_cookie_glitch >= 0 ? SP->_mks[Newy] : NULL; if (cursor_right) { /* number of tabs used in stepwise movement */ nt = tab ? (nx / TABSIZE - cx / TABSIZE) : 0; tx = (nt > 0) ? (cx / TABSIZE + nt) * TABSIZE : cx; /* calculate stepwise cost */ stcost = nt * _COST(Tab); iscont = 0; for (x = tx; x < nx; ++x) { if (iscont == 0 && !ISCBIT(scp[x])) iscont = 1; if ((!ceol_standout_glitch && !mks && _ATTR(scp[x]) == curscr->_attrs) || ceol_standout_glitch || (mks && !_ISMARK2(x))) { if (!ISMBIT(scp[x])) stcost += 1; else if (iscont && !(nx - x == 1 && nx < curscr->_maxx && ISCBIT(scp[nx]))) stcost += 1; else stcost += _COST(Cursor_right); } else stcost += _COST(Cursor_right); } } else stcost = LARGECOST; if (!doit) return ((_COST(Parm_right_cursor) < stcost) ? _COST(Parm_right_cursor) : stcost); /* actually move */ if (_COST(Parm_right_cursor) < stcost) _PUTS(tparm_p1(parm_right_cursor, nx-cx), 1); else { if (SP->phys_irm) _OFFINSERT(); for (; nt > 0; --nt) _PUTS(tab, 1); iscont = 0; for (x = tx; x < nx; ++x) { if (iscont == 0 && !ISCBIT(scp[x])) iscont = 1; if ((!ceol_standout_glitch && !mks && _ATTR(scp[x]) == curscr->_attrs) || ceol_standout_glitch || (mks && !_ISMARK2(x))) { if (!ISMBIT(scp[x])) (void) _outwch(_CHAR(scp[x])); else if (iscont && !(nx - x == 1 && nx < curscr->_maxx && ISCBIT(scp[nx]))) (void) _outwch(_CHAR(scp[x])); else _PUTS(cursor_right, 1); } else _PUTS(cursor_right, 1); } } return (0); }