| 1829 | } |
| 1830 | |
| 1831 | bool serverpickup(int i, int sender) // server side item pickup, acknowledge first client that gets it |
| 1832 | { |
| 1833 | const char *hn = sender >= 0 && clients[sender]->type == ST_TCPIP ? clients[sender]->hostname : NULL; |
| 1834 | if(!sg->sents.inrange(i)) |
| 1835 | { |
| 1836 | if(hn && !m_coop) mlog(ACLOG_INFO, "[%s] tried to pick up entity #%d - doesn't exist on this map", hn, i); |
| 1837 | return false; |
| 1838 | } |
| 1839 | server_entity &e = sg->sents[i]; |
| 1840 | if(!e.spawned) |
| 1841 | { |
| 1842 | if(!e.legalpickup && hn && !m_demo) mlog(ACLOG_INFO, "[%s] tried to pick up entity #%d (%s) - can't be picked up in this gamemode or at all", hn, i, entnames[e.type]); |
| 1843 | return false; |
| 1844 | } |
| 1845 | if(sender>=0) |
| 1846 | { |
| 1847 | client *cl = clients[sender]; |
| 1848 | if(cl->type==ST_TCPIP) |
| 1849 | { |
| 1850 | if(cl->state.state != CS_ALIVE || !cl->state.canpickup(e.type)) return false; |
| 1851 | vec v(e.x, e.y, cl->state.o.z); |
| 1852 | float dist = cl->state.o.dist(v); |
| 1853 | int pdist = check_pdist(cl,dist); |
| 1854 | if (pdist) |
| 1855 | { |
| 1856 | cl->farpickups++; |
| 1857 | if (!m_demo) mlog(ACLOG_INFO, "[%s] %s %s up entity #%d (%s), distance %.2f (%d)", |
| 1858 | cl->hostname, cl->name, (pdist==2?"tried to pick":"picked"), i, entnames[e.type], dist, cl->farpickups); |
| 1859 | if (pdist==2) return false; |
| 1860 | } |
| 1861 | } |
| 1862 | sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); |
| 1863 | cl->state.pickup(sg->sents[i].type); |
| 1864 | if (m_lss && sg->sents[i].type == I_GRENADE) cl->state.pickup(sg->sents[i].type); // get two nades at lss |
| 1865 | } |
| 1866 | e.spawned = false; |
| 1867 | if(!m_lms) e.spawntime = spawntime(e.type); |
| 1868 | return true; |
| 1869 | } |
| 1870 | |
| 1871 | void checkitemspawns(int diff) |
| 1872 | { |